BlinkID / blinkid-ios

Everything you need to add AI-driven ID scanning into your native iOS app.
https://microblink.com/products/blinkid
380 stars 90 forks source link

Customized Framework Causes Linker Errors When Archiving #152

Closed bleedsy closed 6 years ago

bleedsy commented 6 years ago

I created a custom dynamic framework from v2.16.1 per the instructions with the following features:

 set( FEATURE_DEFAULT_OPTION                 OFF CACHE BOOL "" ) # disable all recognizers
 set( FEATURE_MRTD                           ON  CACHE BOOL "" ) # enable MRTD recognizer
 set( FEATURE_USDL                           ON  CACHE BOOL "" )
 set( FEATURE_DETECTOR                       ON  CACHE BOOL "" )

I am able to successfully build the app but run into linker errors when trying to archive.

screen shot 2018-04-02 at 5 06 17 pm
culoi commented 6 years ago

Hello @bleedsy

I didn't manage to recreate the issue exactly, but I notice when I include recognizers that are not built with enabled-features.cmake, I got a similar error (which is expected).

I included features from your post, simply run ./create-custom-build.sh script, select dynamic build and include framework and bundle in the project. On purpose I include USDLCombinedRecognizer (instead USDL) and got this error: screen shot 2018-04-03 at 11 12 25

But once I put correct USDLRecognizer, I manage to build the app without the issues.

Can you please explain in a bit more details how did you build framework? Did you use the script from a terminal or you build it from the project?

You also have an interesting warning in the screenshot. Are you linking simulator build in device app?

Regards

bleedsy commented 6 years ago

Hi @culoi

Building for device and simulator works but archiving does not. Did you try to build for the generic device or archive?

The steps I took to create the dynamic library were:

  1. ran ./create-custom-build.sh
  2. selected dynamic

I used the all library. This is the output when I ran the file command:

Release/all/MicroBlink.framework/MicroBlink: Mach-O universal binary with 2 architectures: [x86_64: Mach-O 64-bit dynamically linked shared library x86_64] [arm64]
Release/all/MicroBlink.framework/MicroBlink (for architecture x86_64):  Mach-O 64-bit dynamically linked shared library x86_64
Release/all/MicroBlink.framework/MicroBlink (for architecture arm64):   Mach-O 64-bit dynamically linked shared library arm64

armv7 is missing. If I create a static library, armv7 is there. Can you share your output?

Thanks

culoi commented 6 years ago

Looks like the output is the same:

MicroBlink: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64]
MicroBlink (for architecture x86_64):   Mach-O 64-bit dynamically linked shared library x86_64
MicroBlink (for architecture arm64):    Mach-O 64-bit dynamically linked shared library arm64

Please try this method to add arm7 in dynamic build: add this line to CMakeLists.txt: set( CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "8.0" )

under this text in 15th line: set( CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE[variant=Release] "bitcode" ) and build again.

It was building architectures with default installed XCode and SDK, and in this case was Xcode 9 with base SDK iOS 11. You will get all architectures without armv7s because Apple removed it completely.

With above fix you should get output like this:

MicroBlink: Mach-O universal binary with 4 architectures: [i386:Mach-O dynamically linked shared library i386] [arm64]
MicroBlink (for architecture i386): Mach-O dynamically linked shared library i386
MicroBlink (for architecture x86_64):   Mach-O 64-bit dynamically linked shared library x86_64
MicroBlink (for architecture armv7):    Mach-O dynamically linked shared library arm_v7
MicroBlink (for architecture arm64):    Mach-O 64-bit dynamically linked shared library arm64

We will fix this in next release.

Regards

bleedsy commented 6 years ago

Ah got it. Makes sense. This fixed it. Thank you for your help!