Issue with Xamarin.iOS Native Binding - CocoaTouch Framework

sahilkhannasahilkhanna Member
edited January 9 in Xamarin.iOS

I have created a CocoaTouch Framework using Swift and want to import it in a Xamarin.iOS app. Below are the steps I followed with reference to this blog

1) Generated APIDefinations using the below command
sharpie bind -sdk iphoneos12.1 /MyFirstFramework.framework/Headers/MyFirstFramework-Swift.h

2) Added Native reference

3) Added the below Swift 4 packages in the Xamarin.iOS app (that consumes the framework)

When I build and run the app on device or simulator, it crashes. The crash logs are as below

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Description: DYLD, Library not loaded: @rpath/libswiftos.dylib | Referenced from: /private/var/containers/Bundle/Application/27F3E785-3CE9-4293-9045-A0E643163F6A/SHApp.app/Frameworks/libswiftMetal.dylib | Reason: image not found

I then, in Xcode Framework project, set Always Embed Swift Standard Libraries = Yes and included the framework in Xamarin. After this, the Xamarin.iOS app doesn't crash, but does not perform any action on invoking the Framework methods

SHLib.MyFirstFramework.Launch();
Console.Write(SHLib.MyFirstFramework.Print);

I need help in understanding the things that I may be doing wrong for Xamarin.iOS app

Sign In or Register to comment.