Xamarin iOS binding library (Swift) build error due linker issues


I have Xamarin.iOS project and I’m trying to use Vivalnk sdk (a Swift 5 framework) in it.

I’m attempting to walk through this guide:

So, I used objective sharpie to generate ApiDefinitions.cs and StructsAndEnums.cs files.

Once used this command : (Objective c)

sharpie bind --sdk=iphoneos14.2 --output="XamarinApiDef" --namespace="Binding" --scope="/VivalnkSDK.framework/Headers/" "/VivalnkSDK.framework/Headers/VVBleManager.h"

and once used this : (Swift)

sharpie bind -sdk iphoneos14.2 -scope VivalnkSDK.framework/Headers/ VivalnkSDK.framework/Headers/VVBleManager.h

And finally I used following command’s results:

sharpie bind -sdk iphoneos14.2 -scope VivalnkSDK.framework/Headers/ VivalnkSDK.framework/Headers/VivalnkSDK-swift.h

Then, I created iOS binding library, replaced these files with old ones, and set the build action according to Microsoft’s document.

Then, I added Vivalnk framework to Native References, set smartlink to true, and force load to false.
After a successful binding library build, I referenced this iOS binding library to my Xamarin.iOS project and use it but when I bulid Xamarin.iOS project, got 249 errors like following errors:

Could not find or use auto-linked library 'swiftFoundation' (Vivalnk) Native linking
Native linking failed, undefined symbol: nominal type descriptor for Swift.Double. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. (MT5210) (Vivalnk)

I search a lot on the internet and also tried these:

  • Set Linker behavior to Link Framework SDKs only.
  • Install Xamarin.Swift in both projects.
  • Add this :
-/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/ -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -Wl,-rpath -Wl,@executable_path/Frameworks

to Linker Flags of native reference in iOS binding library.

Add this :

--gcc_flags -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/ -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -Wl,-rpath -Wl,@executable_path/Frameworks

in additional mtouch arguments in the executable project’s iOS Build options.

I checked the location of Xcode, it is exactly there.
But none of them worked for me. I tested in both Visual Studio for mac and windows and nothing changed.

I created a sample project here which contains everything you need to reproduce build errors:


Vivalnk architecture sdk:  Arm64 
Visual Studio for mac Version: 8.8.4
Visual Studio for windows : 16.8.3
Xamarin.iOS version :
XCode Version: 12.2
Swift Version: 5


If I add "Foundation" to frameworks of native reference, those errors will disappear and we will have the following error

Vivalnk.iOS/Vivalnk/error MT5209: Error: in XCode/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCompatibility50.a(Overrides.cpp.o),
building for iOS, but linking in object file built for iOS Simulator, for architecture arm64 (Vivalnk) Native linking

Source: Xamarin.ios Questions

Categorised as Uncategorised Tagged , ,


Leave a Reply

Your email address will not be published. Required fields are marked *

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us