xamarinxamarin.iosxamarin.ios-binding

Native linking error: framework not found for architecture arm64


I'm binding a Xcode Project like this:

enter image description here

enter image description here

Then, I created a static library contains code in DevQPSDKCore directory and reference QPSDKCore.framework, produces library libQupaiSDK.a

Finally, created a new Xamarin binding library

enter image description here

libQupaiSDK.linkwith.cs

enter image description here

Run the project get error:

MTOUCH: error MT5209: Native linking error: framework not found QPSDKCore for architecture arm64
MTOUCH: error MT5202: Native linking failed. Please review the build log.

When I remove the libQupaiSDK.a, this project run successfully.

I can't get the reason from xamarin logs, any body can help me, thanks.

Update:

These two libraries are fat libraries.

$ lipo -info libQupaiSDK.a  
Architectures in the fat file: libQupaiSDK.a are: i386 armv7 x86_64 arm64  
$ lipo -info QPSDKCore.a  
Architectures in the fat file: QPSDKCore.a are: armv7 i386 x86_64 arm64 

Xamarin Studio 6.1.2(build 44)
Xcode 8.1(8B62)

BTW,-lz is dylib or tdb in Xamarin.iOS ?

SDK Source


Solution

  • The file libQupaiSDKBinding.a was compiled referencing QPSDKCore.framework, not QPSDKCore.a library

    .a file references framework

    What you need to do is remove QPSDKCore.a file from the binding project and reference QPSDKCore.framework correctly (see topic on embedding frameworks).

    Basically, copy over QPSDKCore.framework to the Qupai.iOS project folder and edit .csproj file adding these lines:

      <ItemGroup>
        <NativeReference Include="QPSDKCore.framework">
          <IsCxx>False</IsCxx>
          <Kind>Framework</Kind>
        </NativeReference>
      </ItemGroup>
    

    After reloading project you will see your framework as a reference project and you will be able to compile and run the app.

    Note the change in .csproj on the left and native reference on the right.

    running your app after suggested changes

    Must say the error you had was kind of cryptic and if your post didn't include details about the XCode part, I would not able to find the solution.