Under delphi Tokyo, If you look for example iOSapi.MapKit.pas you can see that the initialization section is fired only if NOT defined(CPUARM) (basically the initialization section is run only for iOS Simulator):
{$IF defined(IOS) and NOT defined(CPUARM)}
initialization
MapKitModule := dlopen(MarshaledAString(libMapKit), RTLD_LAZY);
finalization
dlclose(MapKitModule);
{$ENDIF IOS}
But when you see iOSapi.CoreTelephony.pas it’s not the case :
initialization
CoreTelephonyModule := dlopen(MarshaledAString(libCoreTelephony), RTLD_LAZY);
finalization
dlclose(CoreTelephonyModule);
end.
Any idea why ? Today i face a strange bug, I implement the PHPhotoLibrary (Photos Framework) in the same way they do with iOSapi.MapKit.pas, so doing
{$IF defined(IOS) and NOT defined(CPUARM)}
initialization
PhotosModule := dlopen(MarshaledAString(libPhotos), RTLD_LAZY);
finalization
dlclose(PhotosModule);
{$ENDIF IOS}
and it’s work in my ipad Pro but not on iphone 7 where i have the error :
ObjectiveC class PHPhotoLibrary could not be found
when i execute TPHPhotoLibrary.OCClass.authorizationStatus
removing {$IF defined(IOS) and NOT defined(CPUARM)} make the code working correctly on Iphone 7. So what is the rule to follow to link correctly apple Ios library (Library from the apple framework) ? always using dlopen or not ?