iOS 9 and Ionic Build Errors

Why?

I ran into a lot of gotchas trying to publish my recent Ionic app to the App Store. It was bad timing because iOS 9 was just released and Apple is in the process of updating all the dev tools which means breaking changes for all of us. So here are a few of the majors warnings/errors I ran into. Hope they help :)

Latest Xcode GM

First make sure you are using the latest Xcode https://developer.apple.com/xcode/download/

Housekeeping/Updates

After updating Xcode to the latest version I went through and made sure I had all the latest Ionic/Cordova build tools.

npm update -g cordova ionic ios-deploy ios-sim  

I also removed my ios platform and then re-added it just to be sure there was no old code or references. Make sure you backup any custom files that may be in your platforms folder first.

ionic platform rm ios  
ionic platform add ios  

New iPad Settings Error

ERROR: Invalid Bundle. iPad Multitasking support requires launch story board in bundle...

If you're trying to upload your app to the App Store from Xcode you might be getting the above error. This is a new setting for iPad Pro that lets the device know how your app should behave with iPad's split-view/multitasking feature.

If you go into the "General" menu for your app in Xcode under "Deployment Info" you will find an iPad tab click on this and check all the "Device Orientation" check boxes. Then select the "Requires full screen" checkbox under "Status Bar Style". This tells the new iPad to run your app in fullscreen only and not allow the new splitview functionality. This will get rid of the invalid bundle error you received.

The error alt

The Fix alt

File Not Found Error

Cordova/CDVViewController.h file not found

This issues seems to appear in Xcode 7.2 due to search path/include.

The Fix:

  1. Select your in Xcode "TARGETS".
  2. Go to "Build Settings" tab.
  3. Search "Header Search Paths"
  4. Double click and add this path: $(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include
  5. Now clean the Project, restart the Xcode.
  6. Able to make the "Build", and "Archive".
  7. That's All.

http://stackoverflow.com/questions/34546607/xcode-7-2-in-archive-getting-the-issue-cordova-cdvviewcontroller-h-file-n

Breaking Change in Angular Navigation Stack

There is a breaking change with Angular and iOS 9 that involves navigation and you may be getting a console error as you nav around in your app. The Ionic team has released a pretty simple patch for this that works well for the time being.

You can read their full post about it here http://blog.ionic.io/ios-9-potential-breaking-change/.

To apply the patch you just need to copy this Custom Controller and inject it into your app dependencies.

App Transport Security Policy Error

Failed to load resource: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

Apple is tightening up security in iOS 9 and they are discouraging unsecure connections. Which is good, but if you're like me you may have an app the requires unsecure connections to function. You can get around this restriction by adding the line below to your app's AppName-info.plist under "platforms/ios/AppName/"

<key>NSAppTransportSecurity</key>  
<dict>  
    <key>NSAllowsArbitraryLoads</key><true/>  
</dict>  

Here is the article I pulled my solution from https://forums.developer.apple.com/thread/3544

Update: You'll also need to add the snippet above to your plist in iOS 9 if you want to use Ionic's livereload. Otherwise your app will freeze on the splash screen.

reference: https://gist.github.com/mlynch/284699d676fe9ed0abfa

Pro Tips

If your app isn't launching or is behaving strangely on a real device or the simulator it could be because of Xcode's debugger called "lldb" if you run killall lldb when your app is behaving strangely it will restart the service and should start building and running more smoothly.

The lldb tool has been around for a while so you can try this technique on older versions of Xcode as well. It does seem to be more of a problem on the latest version, so hopefully they will get it running smoother in the future.

A set of UI components for React Native.
Get Carbon Native!