Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building a project in Xcode5.1 that was modified in Xcode 6 GM for testing older versions of iOS

My app has been supporting at least iOS6 using Xcode5.1 storyboard.

After I did several work in Xcode 6 GM, I need to test on iOS 6 Simulator. Xcode 6 GM does not have iOS 6 Simulator.So, I opened my project in Xcode 5.1.

But It fails to build. I cannot even open the storyboard in Xcode5.1.

At the navigation pane, it says

Main_iPhone.storboard
Interface Builder Storyboard Compiler Error
The document"(null)" requires Xcode6.0 or later.

And when I click it, a prompt appears

The document "Main_iPhone.storyboard" requires Xcode 6.0 or later.
This version does not support constraints to layout margins. Open this document with Xcode 6.0 or later.
like image 765
Kyle KIM Avatar asked Dec 03 '22 18:12

Kyle KIM


1 Answers

Adding almost any type of layout constraint with Xcode 6 will render a storyboard (or .xib file) incompatible with Xcode 5.1. If you need to work with a storyboard in Xcode 5.1 that has been modified with Xcode 6.0 it will be necessary to remove all "margin" based constraints.

Perform these steps to make a storyboard modified by Xcode 6 load and compile again with Xcode 5:

Using Xcode 6:

  1. Set the "Opens in" to Xcode 5.1 in the Interface Builder Document Section of the storyboard File Inspector. When this is set, Xcode 6.0 will generate a warning if there are any incompatible margin constraints present.

    Layout attributes relative to the layout margin on iOS versions prior to 8.0

  2. One easy way to identify the margin constraints is to open the storyboard in a text editor (preferably one that auto refreshes when the file is changed on disk). Search for the word "Margin" and look for lines like this:

    <constraint firstItem="gZc-ET-UKM" firstAttribute="leading" secondItem="MMQ-IT-qOo" secondAttribute="leadingMargin" constant="-8" id="H3i-wo-2Mm"/>
    
  3. These constraints need to be either deleted or updated to be based directly on the superview rather than a margin. It is possible to update the constraint instead of deleting it by selecting the constraint in the outline view and then going to the Size Inspector and unchecking "Relative to margin" option in the drop down menu for the First Item or Second Item settings. Once you do that, you'll also need to add a constant that matches the margin (usually 8).

    Relative To Margin Image

As you delete or update each constraint you should see the storyboard file in the text editor update and remove the word "Margin". Once you have deleted all of the incompatible constraints the warning will go away and this line will disappear from the storyboard file:

    <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
  1. If you deleted the constraints, the final step is to open the project in Xcode 5 and recreate them.
like image 127
Mark Edington Avatar answered Dec 05 '22 06:12

Mark Edington