Page 1 of 1

Internet app - OpenLibrary(dylib) returns 0

Posted: Fri Dec 04, 2020 12:21 pm
by Offin
Hello,

My software contains a binary file (.app) and a library file (.dylib).
Both are compiled with PB 5.73.
They are signed (with hardened runtime option).
A DMG is made with these files.
The DMG is signed and notarized (with my Apple ID developper)
No problem until now.
The DMG is uploaded on internet.
I download the DMG from internet.
I extract the folder with the app & dylib files.

When i run the app file, there is the following error message "error loading library 'xxx.dylib !' (means "OpenLibrary() returns 0)'.

Does somebody know what i am missing ?


Some remarks

If i import the same DMG file from my local network (not internet), there is no problem.

The signature check for the dylib file command shows: "Info.plist=not bound".
But in my opinion, it is not possible to embeed a plist file with a dylib file.

The notarization procedure shows this message:
2020-12-04 10:30:41.505 altool[4134:88747] CFURLRequestSetHTTPCookieStorageAcceptPolicy_block_invoke: no longer implemented and should not be called
No errors uploading 'xxxxx.dmg'.
RequestUUID = 16f31155-3115-4468-930e-c0446828b706
But i think this is just a warning not important because the app file works correctly when it is packaged without the dylib file.

Re: Error loading library 'xxx.dylib' !

Posted: Fri Dec 04, 2020 12:46 pm
by mk-soft
Where do you put the DyLib?

It is best to put the own library into the APP package. "MyApp.app/Contents/Library" or "MyApp.app/Contents/Resources".
For this I have written a tool for PB-IDE.

Link: PB-IDE Tool MyAppData

Re: Error loading library 'xxx.dylib' !

Posted: Fri Dec 04, 2020 4:13 pm
by Offin
The dylib is presently at same level than the app file/folder.
We were a bit lazy to do this change.
But this time we may not have other choice with the recent new OS "Big Sur".

We will work on that.

Thank you for your answer.

Re: Internet app - OpenLibrary(...dylib) returns 0

Posted: Fri Dec 04, 2020 8:22 pm
by Offin
We made an APP package with all files (including the dylib file) into the folder "OurProgram.app/Contents/".
But still same problem: the function OpenLibrary(#PB_Any, "OurPBLibrary.dylib") in the app returns 0.

May be some keys to add in the plist file ?

PS: any example of an app with a PB dylib in would be welcome.

Re: Internet app - OpenLibrary(dylib) returns 0

Posted: Fri Dec 04, 2020 9:39 pm
by mk-soft
The entire path to the library must be specified.

also copy the library into the App folder Contents/Resources or Contents/Library. Order must be.
Remember: PB-IDE Tool MyAppData

Even if I haven't installed Big Sur yet, it has to be done this way.

Code: Select all

libpath.s = GetLibraryPath() + "OurPBLibrary.dylib"
Debug libpath
lib = OpenLibrary(#PB_Any, libpath)
PathHelper

Code: Select all

;- TOP

; Comment: PathHelper v1.01 by mk-soft

Macro GetParentPath(Path)
  GetPathPart(RTrim(Path, #PS$))
EndMacro

Procedure.s GetProgramPath()
  Protected r1.s
  r1 = GetPathPart(ProgramFilename())
  CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
    r1 = GetParentPath(r1)
    r1 = GetParentPath(r1)
  CompilerEndIf
  ProcedureReturn r1
EndProcedure

Procedure.s GetResourcesPath()
  Protected r1.s
  r1 = GetPathPart(ProgramFilename())
  CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
    r1 = GetParentPath(r1)
  CompilerEndIf
  r1 + "Resources" + #PS$
  ProcedureReturn r1
EndProcedure

Procedure.s GetLibraryPath()
  Protected r1.s
  r1 = GetPathPart(ProgramFilename())
  CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
    r1 = GetParentPath(r1)
  CompilerEndIf
  r1 + "Library" + #PS$
  ProcedureReturn r1
EndProcedure

CompilerIf #PB_Compiler_IsMainFile
  Debug GetProgramPath()
  Debug GetResourcesPath()
  Debug GetLibraryPath()
CompilerEndIf

Re: Internet app - OpenLibrary(dylib) returns 0

Posted: Fri Dec 04, 2020 11:18 pm
by Paul
I've always used
OpenLibrary(#PB_Any, "mylib.dylib")

and simply placed the .dylib file in myapp.app\Contents\
next to Info.plist and it just works ;)


Has Apple broken all backward compatibility with the latest OS update ?

Re: Internet app - OpenLibrary(...dylib) returns 0

Posted: Fri Dec 04, 2020 11:44 pm
by Paul
Offin wrote: PS: any example of an app with a PB dylib in would be welcome.
You can see if this works...
https://reelmedia.org/test/testdll.zip

It contains 2 PB files that were used to make the compiled app and the compiled file to test with.
Running the app should return MessageBox containing "SUM" "10"

Works here on MacOS 10.12, 10.14, 10.15 (I don't have anything higher)

Re: Internet app - OpenLibrary(dylib) returns 0

Posted: Sat Dec 05, 2020 11:48 am
by Mindphazer
Works here, i'm on Big Sur and PB 5.73
Launching the app returns the messagebox

Re: Internet app - OpenLibrary(dylib) returns 0

Posted: Mon Dec 07, 2020 6:16 pm
by Offin
@ mk-soft
Thank you very much for this code.
It works now.

FYI, we were using a relative path to load the library, and it does not work with Big Sur.
It is now ok with an absolute path, whatever is the library location (in folder "library" or at "app" folder level).

Thank you all for your precious help.