Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to migrate from iPhone/iPad storyboards to universal storyboard

I have a project created in Xcode 5. The "Deployment Info" settings says Devices: Universal but has separate iPhone and iPad settings and corresponding iPhone and iPad storyboards.

Now I'm developing the same project in Xcode 6 and I want to use one universal storyboard instead of two storyboards. I have only worked on the iPhone storyboard and haven't touched the iPad one. Is it possible to ditch the iPad storyboard and convert the existing iPhone storyboard to be my main universal storyboard?

like image 704
rmp251 Avatar asked Sep 27 '14 02:09

rmp251


People also ask

How do I use the same storyboard on my iPad and iPhone?

If you had created a universal project, by default empty iPad storyboard would have been created, you just have to select iPhone storyboard select all (Command+A), copy (Command+C) and paste it on iPad storyboard.

How do I make multiple storyboards in Xcode?

1. Create storyboards by File -> New -> File -> Select Storyboard -> Next -> Give it a name -> Create.


2 Answers

I adapted this tutorial and a similar solution by @tharkay to create this solution below.

  • Rename Main_iPhone.storyboard to Main.storyboard
  • Delete Main_iPad.storyboard
  • ***If you want to use the iPad storyboard instead of the iPhone, rename the Main_iPad.storyboard to Main.storyboard and delete the Main_iPhone.storyboard file. You will then need to go to the File Inspector and right-click your storyboard, then select “Open as Source Code”. This will display all that XML code. Change targetRuntime from "iOS.CocoaTouch.iPad" to "iOS.CocoaTouch"

From:

targetRuntime="iOS.CocoaTouch.iPad" 

to:

targetRuntime="iOS.CocoaTouch"
  • In the project file, under general settings, select Main.storyboard for both iPhone and iPad.

enter image description here

  • On Main.storyboard, on the right-hand panel choose the Show the File inspector icon.

enter image description here

  • Check the box named Use Size classes

enter image description here

  • XCode will prompt with an Xcode 5 compatibility message, Select YES.
  • Compile and run.
  • Of course, all your views should be messed up and you'll need to redo auto-layout.
like image 163
DogEatDog Avatar answered Jan 04 '23 11:01

DogEatDog


In xCode 9 I also had to add useTraitCollections="YES" property into document tag (same place where targetRuntime="iOS.CocoaTouch" is).

like image 23
Chuck Boris Avatar answered Jan 04 '23 12:01

Chuck Boris