I upgraded an Xcode 3 project having three targets to Xcode 4. My targets' bundles no longer have any NIB files -- only XIB files. A new Xcode 4 project has both (at least in the simulator). I don't see any difference between the old and the new Xcode projects' settings to account for this difference.
How do I get Xcode 4 to compile the XIB files and put NIBs in my bundle?
Solution: Select all of the XIB files, change the file type to something outlandish ("Objective-C Preprocessed Source" is handy), and then set the file type BACK to the Default type (IB CocoaTouch XIB). De-select all of the files (Xcode might spin on that for a while), clean the project, delete the prior version(s) from the simulator(s), and now the build should contain only NIBs, no XIBs.
Man Always Wins In The End. (With help from BaldEagle.)
I found another solution:
Go into the 'Build Settings' or your project target, look for 'Other Interface Builder Compiler Flags' and add the flag '-all'.
That's it.
Related
I get this message from Xcode when I try to edit the xib for one of my apps.
_The document "ViewController_iPhone.xib" could not be opened. This version of Xcode does no support Auto Layout for iOS documents. Edit
this document with a newer version of Xcode.
I have Xcode version "4.4"
You may have this problem if the XIB file was originally created in Xcode version 4.5+ (current preview version as of now is 4.5). Auto Layout is a new feature that wasn't supported previously with older versions of Xcode.
Go to the developer portal and download 4.5 Preview Xcode and try that out.
Simple Solution:
Right click on .xib file -> open as "Source Code".
Find & delete object (some int/Hex) from xib source code.
Save File.
Again right click & open xib as "Interface Builder".
It will open your corrupt .xib file & u will not loss whole update in project.
I recently upgraded to XCode 4 and adjusting. I have a folder called "Unused" in which I keep some .h and .m files. They are basically code which are no longer associated with the project and I keep them because they serve as a reference. The compiler doesn't look what it sees in there so I change the .h and .m files to .h.txt and .m.txt. However, I get this warning:
warning: no rule to process file '$(PROJECT_DIR)/Classes/AddViewController.m.txt' of type text for architecture i386
Does anyone have any solution for this?
Thanks.
Select the target in XCode, then in the Build Phases tab, under Compile Sources, remove the unused files that you don't want. XCode will only compile the files listed.
If you don't want the files to link, you can select the relevant file on the left side project navigator, then go to your right side bar and select the File inspector (left most icon on top right bar), then scroll down to "Target Membership" and unclick the checkbox so the file is not associated with any of your targets.
well, i've just faced with localization problem on my projet and decided to make an experiment to reveal the problem:
experiment:
create universal iOS application;
change the text on main windows from "My Universal iPhone (iPad) App" to "Hello" both for MainWindow_iPhone.xib and MainWindow_iPad.xib files;
build and run app in iPhone and iPad simulators - both displaying "Hello" message - everything is fine;
add spanish localization for MainWindow_iPhone.xib and for MainWindow_iPad.xib (english localization was already there)
change the text on main windows from "Hello" to "Hola" both for spanish version of MainWindow_iPhone.xib and MainWindow_iPad.xib files;
change language in simulator to spanish;
build and run app in iPhone and iPad simulators - both still displaying "Hello" message - what?!?!?!
fix:
open project properties and go to "build phases" tab;
in "copy bundle resources" add xib files: locate MainWindow_iPhone.xib and MainWindow_iPad.xib files in es.lproj directory of project and add them
build and run app in iPhone and iPad simulators - both displaying "Hola" message - OK
well, what conclusion can i make? when adding new localization to xib file, xcode is forgetting to add this file to copy bundle resources target. so after running app on different localization (spanish in example) iOS can't find spanish localization (of course, Xcode forgot to copy it!!!) and load english version of xib.
manual adding localized versions of files makes mess in the project tree - added files will be displayed in project hierarchy, but they are already displayed when we expand xib file with localizations. (in example we will have MainWindow_iPhone.xib and MainWindow_iPad.xib in project structure tree, but at the same time they are available in iPhone and iPad file groups after expanding localized MainWindow_iPhone.xib or MainWindow_iPad.xib files)
or am i missing something cruicial?
If you manually add resources to Xcode, you'll often need to (K)lean your project to rebuild the links. Command-K should do the trick.
I can't remember having to do this in Xcode 3 and it may already be fixed in later version of Xcode 4.
I have an iPhone xib I want to turn into an iPad xib. In Xcode 3 there was a "Create iPad Version" menu option. How do I do this in Xcode 4?
I currently resized my xib, but when I turn on the simulated items (Navigation Bar, etc.) it shrinks the view back down to iPhone size.
This worked for me:
Make a copy of the .xib in the Finder.
Open the copied file in a text editor.
Change "com.apple.InterfaceBuilder3.CocoaTouch.XIB" to "com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB".
Change all instances of "IBCocoaTouchFramework" to "IBIPadFramework".
Search for sizes like {480, 320} and edit them. Or just reopen the file in Xcode and use the GUI to resize items as needed.
This also works in reverse, if you need to change an iPad xib into an iPhone xib.
in Xcode 4 it's quite hidden, but the option to convert XIBS in the app still exists.
Select the target (in XCODE4 it's shown when you select the project). Once selected use the contextual menu to "Duplicate" it. It will ask if you want to "Duplicate and transition to iPad". Then all the XIBS will be duplicated with the new iPad size.
On assessing my options, these were my thoughts:
Too much of a hassle to install xcode 3 and downgrade project
Don't want to mess with .xib file format - afraid it might break something that will show itself much later
Copying the same nib is imperfect (see the explanations in this thread)
So finally, what I ended up doing that works fine is:
Create a new file, choose "UIViewController derived" class
Check the "intended for iPad" checkbox
Name the file -iPad
Delete the .h and .m corresponding to the uiviewcontroller
Now populate the new nib with the same objects, structure and connections as the original nib
Check if on iPad, if so then load the new nib else load the old nib
The feature has been removed from Xcode 4.
Right now the easiest way is to use Xcode 3 for the conversion, since the nib (.xib) file format did not change.
Xcode 3 & 4 can now be both installed on the same system by simply selecting a different folder (see installation instructions on the disk image).
Another simple way in XCode4 is: Just copy the iPhone XIB in Finder; drag the copy in your project. Open the copied XIB in XCodes build in interface builder. Change the size of the top view in your NIBs hirarchy to iPads dimensions (e.g. 1024x748 for landscape with statusbar) - everything else resizes according to the autoresizing masks.
Works perfect for me.
If you make a new nib, it will ask you if it should be sized for iPad. That might be the easiest unless you've already done a bunch of work on it.
You will have to use the older version of Interface Builder to use the "Create iPad version using autoresizing masks". There currently is no option in Xcode 4 that will do this.
Using XCode 4, all you have to do is select the (iPhone-specific) .xib file in the project navigator, then select File... --> Duplicate...
Name the new .xib file the same as your iphone-specific one, but append ~ipad to the name. All your previous connections in the view hierarchy should be unchanged in your brand-new iPad-specific .xib file.
You can use this tool I made, based on the answer from "arlomedia":
http://iphone.dizzystudios.net/ConvertToiPad
just give it the iPhone xib path
This has been annoying me for a while in several XCode projects. I really don't like to have compiler warnings when I build. When I build my current project, I get the following warning from a bunch of XIB files:
/.../CaseInformationView.xib:3:0 UIScrollView's 'Bounce Zoom' option will be ignored on iPhone OS versions prior to 2.1.
Since I'm building for 3.0, I don't care if it will be ignored. If I want to use the Bounce Zoom option in my XIB file, how can I not see this warning?
In IB, select "Document Info" from the Window menu and set your Deployment target to 3.0.
EDIT: In more current versions of Xcode
Choose the xib
Go to the File Inspector
In the Interface Builder Document section, set Deployment and Development
Also, set Deployment Target on Project's Summary page (choose main project, then Summary tab)