3

In a 3rd party library i have the definition

FOUNDATION_EXPORT NSString * __nonnull const kFIRInstanceIDTokenRefreshNotification;

and I need to import it under delphi, so that i can access it under ios at runtime. how to do it ? i look the source code of delphi, they do like this :

FrameworkMod := LoadLibrary(PWideChar(FwkPath));
result := GetProcAddress(FrameworkMod, PWideChar(ConstStr));

but as it's a 3rd party library how to do LoadLibrary(PWideChar(FwkPath)); ? what path to use in FwkPath ?

  • That doesn't make sense.. Frameworks are Mach-O packages. You can't use `GetProcAddress` since that is a WINDOWS function.. and you're trying to load an OSX/iOS framework. Instead, try: `dlopen("FrameWorkPath/3rdPartyFramework.framework/3rdPartyFramework", RTLD_NOW);` – Brandon Apr 24 '17 at 17:28
  • But my framework is the firebaseSDK, on my computer the name of the file is FirebaseInstanceID.a and it is located in c:\dev\firebase\FirebaseInstanceID.a ... so what path to use ? also ios forbid us to load dynamically some 3rd library (as i know). –  Apr 24 '17 at 19:36
  • But you are loading it in Delphi so the iOS restriction should not apply. Are you asking how to load a Delphi library in iOS? Or are you asking how to load an iOS library in Delphi? Firebase.a is a static library and you can link to it by doing `{$linklib Firebase.a}` – Brandon Apr 24 '17 at 19:51
  • i mean when the app run in the ios off course ... dlopen seam to be a runtime instruction ? –  Apr 24 '17 at 20:34
  • You are confusing me. Are you trying to load a delphi library on iOS? Your post says: "I need to import it under delphi". So it looks like you are trying to load an iOS library in a Delphi app. – Brandon Apr 24 '17 at 20:36
  • no off course, i mean i develop WITH delphi and i need to open under IOS a library :) i update my question ;) –  Apr 24 '17 at 21:21
  • @Brandon In this case, GetProcAddress is simply a wrapper around dlsym. Jean's main issue is that the framework cannot be loaded dynamically, as it's a 3rd party framework - he needs to bind statically, which is possible by simply renaming the framework file, in this case FirebaseInstanceID, to FirebaseInstanceID.a. The trick is: how to bind to an exported symbol that's a constant - in this case: kFIRInstanceIDTokenRefreshNotification – Dave Nottage Apr 24 '17 at 23:02
  • @Dave Nottage; But why?? 3rd party frameworks can be loaded just fine on iOS 8+. In fact, you can go to `"General -> Frameworks -> Add -> AddOther -> 3rdPartyFramework.framework"`. If that doesn't work, you can even "Embed" it instead. This is how AFNetworking and all other libraries work. Then you import the header and use the constant. The same technique works for dynamic libraries and static ones. Otherwise you can add them to `"Build Settings -> Other LinkerFlags -> -lmylib.a" If it's really a dynamic module (.dylib) then you can still load them http://stackoverflow.com/a/24266440/1462718 – Brandon Apr 24 '17 at 23:29
  • by `"General -> Frameworks -> Add -> AddOther -> 3rdPartyFramework.framework"` you mean under xcode not under Delphi right ? –  Apr 24 '17 at 23:33
  • @Brandon i don't really understand how to do what you mean under delphi :( i just want to access my const declared in FirInstanceID.a –  Apr 24 '17 at 23:55

0 Answers0