Create iPad xib from iPhone xib for Universal Binary iOS App Development

If you are creating a universal binary iOS app in Xcode to run on both the iPhone and iPad, you’ll need xib files for each. In my case, I created the iPhone xibs first and then needed to create the iPad xib files.

Here’s the process to create iPad xibs from iPhone xibs:

1) Open Finder and make a copy of the iPhone xib file. Add “~ipad” to the end of the name. For example, if your iPhone xib is myView.xib, duplicate this file in Finder and name it myView~ipad.xib. You might also want to create a folder in Finder called ipad-resources and move the iPad xib there to stay organized.

2) Add the new iPad xib file to your project by dragging it from Finder into the Xcode Project Navigator. You might want to create a new folder in the Project Navigator called iPad Resources to keep everything a bit more organized.

3) In Xcode right click the iPad xib file and Open As > Source Code

4) The 2nd line should look like:

Replace this line with:

5) Search within the source code for “IBCocoaTouchFramework” and replace all occurrences with “IBIPadFramework”

6) Save the file and Open As > Interface Builder – iOS

Initially, the file might still look like a regular iPhone xib. To activate the iPad version, change the Status Bar to “Black” in the Attributes inspector and the xib with change to an iPad version. Change the Status Bar back to none, if you like.

That’s it – you now have an iPad version of your xib. Take some time to modify the layout for iPad use.

Please leave a comment below or on Twitter @steinarknutsen.

Thanks,
Steinar

Related Posts

This is a great time to sign up to my newsletter where you'll receive tons of great content only available to my subscribers.

Thanks,
Steinar