I wrote a very detailed blog post about creating a static library from ObjC code last year that works on Xamarin.iOS binding projects and you can find it here (just in case :wink::wink:).
That being said if you already have a fat static library in your hands and it is already added into your Xamarin.iOS Binding Project as shown here:
The issue could be that your libxyz.linkwith.cs
is missing some information, if it looks like this:
using ObjCRuntime;
[assembly: LinkWith ("libFoo.a", SmartLink = true, ForceLoad = true)]
it is definitely missing some important information about the architectures supported by your fat library (it is missing the second argument target
), you can use the following command to retrieve what architectures your current static library supports
xcrun -sdk iphoneos lipo -info path/to/your/libFoo.a
and you should get something like this as output
Architectures in the fat file: Foo/libFoo.a are: i386 armv7 x86_64 arm64
So we know this static library supports i386 armv7 x86_64 arm64
and we should provide our LinkWith
attribute the supported archs by providing the second argument target
as follows:
using ObjCRuntime;
[assembly: LinkWith ("libFoo.a", LinkTarget.ArmV7 | LinkTarget.Arm64 | LinkTarget.Simulator | LinkTarget.Simulator64, SmartLink = true, ForceLoad = true)]
Also make sure that the first parameter of the LinkWith
attribute matches your static library file name ("libFoo.a" in my case).
The other thing I would suggest double checking is that the Build Action
of your static library (libFoo.a
in my case) is correctly set to ObjcBindingNativeLibrary
as show here:
Hope this helps!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…