Start a Xamarin iOS Project
Warning
The Xamarin SDK is deprecated. For more details, contact Support.
Xamarin iOS uses AOT (Ahead of time) compilation, as opposed to other C# targets, which use JIT (Just in time) compilation. Because of this, you must ensure that Monotouch links to the native libraries so that they are available at compile-time. To do this, add the following MSBuild directive to your Xamarin iOS .csproj
file:
<MtouchExtraArgs>-gcc_flags "-L${ProjectDir}/libs/native -lvpxfm-iOS -lopusfm-iOS -lyuvfm-iOS -force_load ${ProjectDir}/libs/native/libvpxfm-iOS.a -force_load ${ProjectDir}/libs/native/libopusfm-iOS.a -force_load ${ProjectDir}/libs/native/libyuvfm-iOS.a"</MtouchExtraArgs>
If you don't want to edit the .csproj
file directly, you can instead specify this through the IDE. Open the project property window and look for the "Monotouch Arguments" property. Copy the contents of the MTouchExtraArgs
element here.
If you do not specify this, then Xamarin iOS won't compile for physical devices and there are going to be run-time exceptions when the app is run on the iOS simulator.
As with other platforms, you need to include architecture-specific native libraries for Xamarin iOS. Include the libraries that can be found in the Xamarin/Libraries/iOS/native folder. The following rules apply:
- If you are using
FM.LiveSwitch.Opus.dll
, includelibopusfm-iOS.a
andlibopus-iOS.a
. - If you are using **
FM.LiveSwitch**.Vpx.dll
, includelibvpxfm-iOS.a
andlibvpx-iOS.a
. - If you are using **
FM.LiveSwitch**.Yuv.dll
, includelibyuvfm.iOS.a
andlibyuv-iOS.a
.
If you want to be safe, you can include the entire lib folder in your project. This ensures that you always have the correct native libraries.
Mono Dynamic Registrar Flag
If you are using Mono 5.10.x or higher there is a know issue with Xamarin iOS where the dynamic linker is removed at runtime. The native libraries fail to load without the dynamic linker. A work around is to add "--optimize=-remove-dynamic-registrar" flag to MTouchExtraArgs
in the .csproj
file . Adding this flag prevents Mono from removing the dynamic linker.
After you add this in your .csproj
file, your .csproj
file should have the following:
<MtouchExtraArgs>--optimize=-remove-dynamic-registrar -gcc_flags "-L${ProjectDir}/libs/native -lvpxfm-iOS -lopusfm-iOS -lyuvfm-iOS -force_load ${ProjectDir}/libs/native/libvpxfm-iOS.a -force_load ${ProjectDir}/libs/native/libopusfm-iOS.a -force_load ${ProjectDir}/libs/native/libyuvfm-iOS.a"</MtouchExtraArgs>