How do you do it? I saw one video tutorial on it, but the screen was too small. Also, other than changing the view size, are there any other major changes I would have to
Open up the XIB in XCode 4 using "view as source code."
Back up the nib in question.
Substitute this goo
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
<integer value="1056" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
<integer value="3100" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">301</string>
for this other goo
<string key="IBDocument.TargetRuntimeIdentifier">IBIPadFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
<integer value="3100" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">301</string>
Then, for each view in the nib using the integrated IB, delete it and then hit undo.
Then shower in hot water to wipe off that disgusting feeling you might have.
Jag's answer is great. But there is a catch if an XIB is opened/ created in Xcode 5.
For Xcode 5
1) Make a copy of the iPhone xib file and add it to your project
2) Right click the file (in xcode) and Open As > Source Code
3) The 2nd line should look like:
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4510"
change it to
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="4510"
4) 8th line should look like this:
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
change it to
<rect key="frame" x="0.0" y="64" width="768" height="960"/>
That's it and there you have iPad XIB. But still the real credit goes to Jag.
XCode4:
In xcode 4 we can't do that for a single xib,but we can create respective ipad versions all at once.
Before configuring your project to ipad,when it is configured only for iphone, right click on target and click on duplicate.
Now select "duplicate and transition to ipad".A new target and new set of xibs are created.It should reduce some work.
Hope it helps.
Just replace
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14854.2" targetRuntime="iOS.CocoaTouch"
with
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="14854.2" targetRuntime="iOS.CocoaTouch.iPad"
Sounds like the best solution is to always develop as iphone first, then once you are complete done, add the ipad target, letting xcode do the update. I made the same mistake, selected universal to start, which creates the first few files, but then every other xib had to be hand recreated in the ipad folder. Big PAIN
I will document what I did in Xcode 4.5:
fixpattern.sh
cp REPLACEME_Iphone.h REPLACEME_Ipad.h
sed -e 's/REPLACEME_Iphone/REPLACEME_Ipad/g' REPLACEME_Ipad.h > REPLACEME_Ipad_tmp.h
mv REPLACEME_Ipad_tmp.h REPLACEME_Ipad.h
cp REPLACEME_Iphone.m REPLACEME_Ipad.m
sed -e 's/REPLACEME_Iphone/REPLACEME_Ipad/g' REPLACEME_Ipad.m > REPLACEME_Ipad_tmp.m
mv REPLACEME_Ipad_tmp.m REPLACEME_Ipad.m
cp REPLACEME_Iphone.xib REPLACEME_Ipad.xib
sed -e 's/com.apple.InterfaceBuilder3.CocoaTouch.XIB /com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB/g' REPLACEME_Ipad.xib > REPLACEME_Ipad_tmp.xib
mv REPLACEME_Ipad_tmp.xib REPLACEME_Ipad.xib
sed -e 's/IBCocoaTouchFramework/IBIPadFramework/g' REPLACEME_Ipad.xib > REPLACEME_Ipad_tmp.xib
mv REPLACEME_Ipad_tmp.xib REPLACEME_Ipad.xib
sed -e 's/320, 416/768, 1004/g' REPLACEME_Ipad.xib > REPLACEME_Ipad_tmp.xib
mv REPLACEME_Ipad_tmp.xib REPLACEME_Ipad.xib
sed -e 's/REPLACEME_Iphone/REPLACEME_Ipad/g' REPLACEME_Ipad.xib > REPLACEME_Ipad_tmp.xib
mv REPLACEME_Ipad_tmp.xib REPLACEME_Ipad.xib
Create a list of file you want to convert in fixfile
, each line will be a file name without extension. If you original file name is AAA_Iphone.h
, just put AAA
. If your original file is not of this pattern, you need to revise the script.
Run in command line
cat fixfile | while read line ; do sed -e "s/REPLACEME/${line}/g" fixpattern.sh ; done > fixall.sh
Review and run fixall.sh
Add newly created file into project