Migrating to Xcode 8 — What You Need to Know

Written by petrpavlik | Published 2016/09/22
Tech Story Tags: ios | swift | xcode | xcode-8

TLDRvia the TL;DR App

I wanted to try what it would take to migrate my little side project to Xcode 8 and write this article as summary of all the struggles I had to face.

Logging madness

Apple has introduced new super fast logging APIs with iOS 10, there is a WWDC talk about it, and boy have they started logging absolutely everything you can think of.

We can fortunately add an enviromental variable that disables this as described here.

Crash when accessing media library

I experienced a crash when accessing my photos library.

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app’s Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.

The solution is simple, do as described above.

Broken Facebook login

Facebook login started returning a good old Error 308 when trying to log in. Few minutes of googling gave me a hint that there are changes in how facebook handles the keychain on iOS 10 and that I need to enable Keychain Sharing under Capabilities tab in project settings. That did the trick for me.

Broken Fastlane and archiving in general

Apple has introduced some some black magic that is supposed to manage the code signing for you. I just turned it off and everything ranging from archive button in Xcode to Fastlane and Buddybuild started to work again.

edit: Apple seem to have removed the option to automatically add UDID of connected device to dev provisioning profile unless you’re using automating code signing 🙁.

edit: I’ve started experimenting with switching to automatic code signing, here is what you need to do.

  • Switch to automatic code signing in your project settings.
  • Set both both your debug and release configuration to iPhone Developer. Yes, it does not make sense, but it’s what Xcode told me and it works.

Archiving using Xcode should not work fine. I tried fastlane as well, which threw an error towards the end but the binary have made it and appeared in iTunes Connect eventually.

Migrating to Swift 3

This will be a separate article when I get to it.

If you don’t want to convert to Swift 3 just yet

Swift 2.3 is basically Swift 2.2 including the fact that Apple simply couldn’t resist including at least a few breaking changes, I’ve experienced few changes in Core Graphics framework where certain APIs suddenly return an optional variable and vice versa, so you’ll need to fix those.

Regarding Swift cocoapods, you’ll need to add a post_install stem to your podfile that tells the build system to use swift 2.3. Please note that at the time of writing this, the latest stable version of cocoapods was 1.0.1, and it may not be necessary when using a version >= 1.1

post_install do |installer|

installer.pods_project.targets.each do |target|

target.build\_configurations.each do |config|

  config.build\_settings\['SWIFT\_VERSION'\] = '2.3'

end

end

end


Published by HackerNoon on 2016/09/22