updating your xamarin.ios apps to ios9 -...

Post on 11-Feb-2018

215 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

//

Updating your Xamarin.iOS apps to iOS9

Mark Smith | mark.smith@xamarin.com

Information in this document is subject to change without notice. The example companies, organizations, products, people, and events depicted herein are fictitious. No association with any real company, organization, product, person or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user.

Xamarin may have patents, patent applications, trademarked, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any license agreement from Xamarin, the furnishing of this document does not give you any license to these patents, trademarks, or other intellectual property.

© 2015 Xamarin. All rights reserved.

Xamarin, MonoTouch, MonoDroid, Xamarin.iOS, Xamarin.Android, and Xamarin Studio are either registered trademarks or trademarks of Xamarin in the U.S.A. and/or other countries.

Other product and company names herein may be the trademarks of their respective owners.

1. Explore the update options2. Make your app iOS9 compatible3. Integrate iOS9 features into your app4. Know the breaking changes

Agenda

Two phases to think about

Ensure your app is compatible with iOS9

Update your app to take advantage of new iOS9 features

1. Due to iOS changes, you mustrecompile your app

2. Might have to make some minor tweaks based on what you use today

3. Resubmit to the App Store ASAP to make sure users don't encounter problems

Steps to compatibility

v Update to the Xamarin stable channel (XS and VS)

v Can use either Xcode 6.4 or Xcode 7.0

v Can keep iOS 8 (or earlier) as your deployment target to continue to run on older devices

Recompiling your app

v iOS9 has a few breaking changes with initializers that apps might run into; should add new exported constructors to be compatible

Improving compatibility with iOS9

Custom UICollectionViewCell classes require parameterized constructor

public class MyCustomCell : UICollectionViewCell{

[Export ("initWithFrame:")]public MyCustomCell (CGRect frame) : base (frame) {

... // Call common init code}...

}

v iOS9 has a few breaking changes with initializers that apps might run into; should add new exported constructors to be compatible

Improving compatibility with iOS9

UIViews loaded from .XIB files now use initWithCoder: constructor

public class AnimatedButton : UIButton{

[Export ("initWithCoder:")]public AnimatedButton (NSCoder coder) : base (coder) {

... // Call common init code}...

}

v Xamarin is collecting known issues developers have encountered while moving to iOS9 in a single place - http://bit.ly/ios9-issues

Troubleshooting iOS9 issues

v Make sure to test all screens and workflows; several APIs are now more strict with parameter checking§ E.g. Constraints in Auto Layout

v Make sure you test on real devices, Xamarin Test Cloud is great for this – use your free minutes!

Test your app thoroughly!

v Xcode only includes latest iOS images – but can download older versions of iOS Simulators from Xcode > Preferences > Downloads

Testing on older versions of iOS

v Get your updated and tested app into the queue for the AppStore

v Currently taking about a week to get through the review process

v Can then focus on new features and really taking advantage of iOS9

Resubmit to the AppStore

v Update to Xcode 7 to get access to the new iOS9 APIs

Installing Xcode 7

Several great new features in iOS9

Multitasking on the iPad

3DTouch

SearchEnhancements

Game APIs VariousFramework APIs

v Be careful about using new features if your deployment target isn't 9.0

Targeting iOS9 features

Xamarin Studio will try to warn you when your deployment target is

lower than an API being used through tooltips

v Using a new API on an older version of iOS results in a runtime exception

Targeting iOS9 features

v Should check the runtime version before using new APIs to continue to be backward compatible

Targeting iOS9 features

// Make sure we are on iOS 9.0 or greaterif (UIDevice.CurrentDevice.CheckSystemVersion(9, 0)) {

if (TraitCollection.ForceTouchCapability== UIForceTouchCapability.Available)

{...

}}

v When moving fully to iOS9 and Xcode 7, can check for updates to components or Nuget packages your application utilizes; should be a little cautious here to make sure you don't introduce problems

Update components / Nuget

v Xamarin iOS Designer does not support the new UI features added to Xcode 7 (yet)

v On XS, can right-click and select Open With > Xcode Interface Builder

v Make changes, save and return to Xamarin Studio to edit code

Storyboard Designer

Check out the walkthrough on using UIStackView in the Xamarin documentation, or watch the Lightning Lecture on using UIStackView in iOS9 for examples of this approach

v Recommended to add a Launch File to provide the launch screen on iOS8 and beyond; required to support split-screen on iPad

Launch File vs. Launch Images

Create it with the designer as either a .xib or .storyboard and then assign it in the info.plist

This is becoming more important as more devices are introduced such as the iPad Pro

v The Address Book and Address Book UI frameworks have been replaced with a new, simpler Contacts and Contacts UI API which is the preferred way to interact with the contact information on the device

Replacing deprecated APIs (iOS9 only!)

// Create a new contact pickervar picker = new CNContactPickerViewController {

DisplayedPropertyKeys = new[] {CNContactKey.EmailAddresses},PredicateForEnablingContact = NSPredicate.FromFormat("emailAddresses.@count > 0"),PredicateForSelectionOfContact = NSPredicate.FromFormat("emailAddresses.@count == 1"),Delegate = new ContactPickerDelegate()

};

// Display pickerPresentViewController(picker,true, null);

developer.xamarin.com/guides/ios/platform_features/introduction_to_ios9/contacts/

v Apple has made some security and privacy changes to iOS9 which will affect any application linked to the iOS9 SDK

v Even if your application does not use iOS9 APIs, if you link to the latest SDK, these changes will apply to your app!

Security changes in iOS9

v New security policy enforces tighter requirements on network connections§ Requires TLS 1.2 or better (https)§ Must use a modern key exchange

algorithm that provides forward security§ Certificates must be signed with SHA256,

2048-bit RSA key, or better

App Transport Security

Read the Apple technical note for more details: http://apple.co/1JbkkRV

v New security policy enforces tighter requirements on network connections§ Requires TLS 1.2 or better (https)§ Must use a modern key exchange

algorithm that provides forward security§ Certificates must be signed with SHA256,

2048-bit RSA key, or better

App Transport Security

If your application is currently using https and good certificates, then this change will likely not affect you

v ATS secures the native iOS stack:§ NSUrlSession/Connection§ Embedded web views§ Background transfers§ ModernHttpClient (Nuget)

v Test edge areas of your app that perform network access such as ad-revenue, in-app OAuth logins, social media integration, etc.

What APIs does this affect?

v ATS policy violations result in an exception + debug output, most common cause is connection to an http (not https) endpoint, but can also happen when older algorithms are negotiated

v Two possible solutions: update the connection to comply to the policy, or tell ATS to ignore the connection

Detecting ATS problems

v Can add exceptions into info.plist if your app cannot comply to restrictions – use new NSAppTransportSecurity key

Adding exceptions for ATS

<key>NSAppTransportSecurity</key><dict>

<key>NSExceptionDomains</key><dict>

<key>xam150.azurewebsites.net</key><dict>

<!-- specific options here --></dict>

</dict></dict>

Try to identify the specific endpoints your app uses and configure just those endpoints

<key>xam150.azurewebsites.net</key><dict>

<key>NSExceptionMinimumTLSVersion</key><string>TLSv1.0</string><key>NSExceptionRequiresForwardSecrecy</key><false/><key>NSExceptionAllowsInsecureHTTPLoads</key><true/><key>NSIncludesSubdomains</key><true/>

</dict>

Exclusion options

Minimum version of TLS to allow

<key>xam150.azurewebsites.net</key><dict>

<key>NSExceptionMinimumTLSVersion</key><string>TLSv1.0</string><key>NSExceptionRequiresForwardSecrecy</key><false/><key>NSExceptionAllowsInsecureHTTPLoads</key><true/><key>NSIncludesSubdomains</key><true/>

</dict>

Exclusion options

Allow non-https data transfer

v Can also disable App Transport Security for all unspecified URLs, allows arbitrary data access when the endpoint is unknown

Turn off ATS by default

<!-- Turn off ATS in iOS9 --><key>NSAppTransportSecurity</key><dict>

<key>NSAllowsArbitraryLoads</key><true/>

</dict>

Should then turn ATS back on for known endpoints by including specific URL endpoint definitions with this key set to false

v UIApplication.SharedApplication.CanOpenUrl can now only check for specific URL schemes listed in info.plist, all unlisted schemes always return false even if the associated app is installed

CanOpenUrl whitelisting

<key>LSApplicationQueriesSchemes</key><array>

<string>fbapi</string><string>fb-messenger-api</string><string>fbauth2</string><string>fbshareextension</string>

</array>

Support Facebook URLs for login, share, etc.

This change does not impact system-provided URLs such as http:, https:, tel:, etc.

v Using UIStackView in iOS9

v Adding 3D Touch to your apps

v Adding support for iOS9 Multitasking to your iPad apps

Other Lightning Lectures

Thank You!

//

Mark Smith | mark.smith@xamarin.com

top related