Xamarin.iOS

Mono TLS Removal: This version of Xamarin.iOS does not ship with the old Mono (managed) SSL/TLS provider, which only supported the SSLv3 and TLSv1 standards. TLS support (up to version 1.2) is provided by the newer AppleTLS provider (already the default since XI 9.8 / C7).

Requirements

  • The latest features and API requires Xcode 8.2 and the bundled iOS, tvOS and watchOS SDKs;
  • Apple Xcode 8.2 requires a Mac running OSX 10.11.5 (El Capitan) or newer;

What's New

This release is built upon our open sourced SDK, using the d15-1 branch, and is based on Mono 4.8.0.

Memory usage and executable size improvements

We have reworked how managed types are registered with the Objective-C runtime, improving executable size and memory usage significantly (for a sample application the executable size decreased by ~200 kb and the memory usage decreased by ~400 kb).

Binding NSValue, NSNumber and NSString to better managed types

The [BindAs] attribute allows binding NSNumber, NSValue and NSString (enums) into more accurate C# types. The attribute can be used to create a nicer .NET API over the native API.

You can decorate properties and methods (on return value and parameters) with [BindAs] attributes. The only restriction is that your member must not be inside a [Protocol] or [Model] interface.

For example:

[return: BindAs (typeof (bool?))]
[Export ("shouldDrawAt:")]
NSNumber ShouldDraw ([BindAs (typeof (CGRect))] NSValue rect);

Would output:

[Export ("shouldDrawAt:")]
bool? ShouldDraw (CGRect rect) { ... }

Internally the generated code will do the required bool? <-> NSNumber and CGRect <-> NSValue conversions.

The [BindAs] attribute also supports arrays of NSNumber NSValue and NSString (enums).

For example:

[BindAs (typeof (CAScroll []))]
[Export ("supportedScrollModes")]
NSString [] SupportedScrollModes { get; set; }

Would output:

[Export ("supportedScrollModes")]
CAScroll [] SupportedScrollModes { get; set; }

CAScroll is a NSString backed enum, we will fetch the right NSString value and handle the type conversion.

Please see our [BindAs] documentation to see supported conversion types.

Single object strong notifications support

When Binding Notifications we generate a nested class MyClass.Notifications that holds strongly typed notifications. In the past it was only possible to observe a notification posted to all objects.

var token = MyClass.Notifications.ObserverDidStart ((notification) => {
    Console.WriteLine ("Observed the 'DidStart' event!");
});

But now it is possible to observe a specific object notifications by using the provided overload.

var token = MyClass.Notifications.ObserverDidStart (objectToObserve, (notification) => { 
    Console.WriteLine ("Observed the 'DidStart' event on objectToObserve!");
});

Experimental control over native optimizations of watchOS applications

We are now providing optional control over the clang compiler optimizations used to generate bitcode. For a basic test, changing the default -O2 to -Oz (optimize for size) reduces the application size by approximatively 5%.

This option is manually passed as an additional mtouch argument in the project's iOS Build options:

--llvm-opt=assembly1.dll=<optimization> --llvm-opt=assembly2.dll=<optimization>

or it's possible to change the optimizations for all assemblies at once:

--llvm-opt=all=<optimization>

For example:

--llvm-opt=all=-Oz

is what showed a 5% application size reduction.

The valid options are the same ones that clang accepts. Keep in mind that clang optimization options are vast and some are not compatible with Mono and may break the application at runtime. For this release the only supported optimizations is the default set, but you can experiment and share your result on our mailing list.

mtouch warnings

We've added support for treating mtouch warnings as errors, as well as ignoring mtouch warnings.

This support is modeled after the same feature in the C# compiler, and can be configured by passing the following options as an additional mtouch argument in the project's iOS Build options:

  • --nowarn will disable all warnings.
  • --nowarn:30,32 will disable the warnings MT0030 and MT0032.
  • --warnaserror will report all warnings as errors.
  • --warnaserror:30,32 will make the warnings MT0030 and MT0032 show up as errors.

MSBuild error codes

The 7xxx range of errors is now reserved for MSBuild errors and we started documenting the first ones. Their description include the task that generated the error as well as some troubleshooting steps when applicable.

Note that this range of error is handled by msbuild (or xbuild) tool and the new mtouch options (above) cannot be used on them.

Xamarin Analysis

We added a new rule to our project analysis tool which ensures that no IPA is generated in debug mode as it's only needed for distribution.

As a reminder you can run the Xamarin Analysis rules from Xamarin Studio's menu bar by selecting Project > Run Code Analysis.

Miscellaneous Enhancements

Performance

  • 49087 - [mtouch] Speed up marking types referenced in attributes
  • 51298 - [msbuild] Parallelized codesigning of *.dylibs and frameworks
  • PR1011 - [msbuild] Do not process mscorlib.dll in UnpackLibraryResources

Tools

  • 28106 - [msbuild] Added support for <Link>'d ImageAsset project files
  • 43165 - [generator] Allow the use of [Async] attribute on [Abstract] decorated methods
  • 43995 - [generator] Support [Sealed] attribute on types (not just methods)
  • 46285 - [generator] Allow identical (numeric) values in smart enums
  • 46292 - [generator] Copy [Obsolete] attributes on smart enums
  • 52241 - [mtouch][watchos] Automatically enable bitcode if LLVM is enabled
  • PR1249 - [generator] Optimize smart enums support to reduce the required metadata
  • PR1446 - [generator] Remove internal *Wrapper.ctor(IntPtr) constructors
  • PR1557 - [msbuild] Added ProcessEnums property for ObjC binding projects
  • PR1707 - [generator] Have [WrapAttribute] optionally generate virtual members when IsVirtual=true

API

  • 33163 - [uikit] Add convenience constructors for UISegmentedControl
  • 39789 - [foundation] Add a number of missing [Flags] in various enums

Better error/warnings reporting

  • PR1174 - [generator] Improve warning about missing [CCallback] or [BlockCallback] attributes
  • PR1188 - [msbuild] Log warnings and errors for the ibtool --link stage as well
  • PR1507 - [linker] Less general MT2001 errors in favor of precise (step/metadata) MT2xxx errors
  • 40835 - [mtouch] Improve enable managed linker error message (MT0091)
  • 46552 - [mtouch][watchos] Make MT2015 (invalid HttpMessageHandler) a warning
  • 51212 - [generator] Provide a better error than BI0000 for TypeloadException in NeedStret

External Contributions

  • PR1545 - [msbuild] Recognize networkextension extensions (and avoid build warning)

Bug Fixes

  • 25499 - [msbuild] Fixed EmbedMobileProvision to lookup provisions by name/uuid correctly
  • 39535 - [mtouch] Update .mdb files even if the corresponding assembly didn't change
  • 46626 - [corefoundation] Store strings in the exception data when converting CFError to CFException
  • 50407 - [foundation] Fix NSFormatter.IsPartialStringValid
  • 51514 - [generator] Missing [Wrap] from protocol/interface when parent has a [Wrap] itself
  • 52279 - [corefoundation] Fix CallbackDelegate signature to be 32bits safe (enum)

  • 52682 - [foundation] Fix POST/PUT issues with NSUrlSessionHandler (10.8.0.10+)

  • 52745 - [msbuild] Make sure to codesign appex dylibs (10.8.0.10+)
  • 52847 - [msbuild] sanity check TargetiOSDevice property for conflicts (10.8.0.10+)
  • 52851 - [msbuild] Ignore .DS_Store files when cloning asset catalogs (10.8.0.10+)
  • 52860 - [msbuild] Index into the correct item array when printing an error message (10.8.0.10+)
  • 52868 - [registrar] Fix generic argument check to allow INativeObject (10.8.0.10+)

  • 52758 - [msbuild] Ensure the MainAssembly path is absolute (10.8.0.20+)

  • 53007 - [msbuild] Run the _ComputeTargetArchitectures target before cleaning (10.8.0.20+)
  • 53066 - [mono] Fix a MT3001 Could not AOT the assembly error (10.8.0.20+)
  • 53176 - [msbuild] Fixed PathUtils.AbsoluteToRelative() logic (10.8.0.20+)
  • 53232 - [mtouch] Don't put frameworks in WatchKit 1 extensions (10.8.0.20+)

API diff

The following documents contains a complete list of the API changes since our latest stable release: XI 10.4.0 (C9)

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.