I have just noticed, that if you have an .plist file in your Xcode project (it does not matter whether it is the Info.plist file or other - in my case it was other .plist file) and you edit the file as a source code file (right-click on file Open As->Source Code File) and then you switch back to XML property List (right-click on file Open As->XML Property List), make some changes and save, then all your formatting and comments are dropped when you open it again as a source code.
Does anyone know how to deal with such behaviour? Do I have to stick editing the file as source code ALWAYS?
Xcode seems to believe that the <comment> tag corrupts the data. It will also strip out XML-style <!-- comments --> when viewing the plist in Xcode.
It seems that a string entry, e.g.
<key>Comment</key>
<string>My comment</string>
is the only way to reliably persist the comments.
Interesting thing, fully reproducible even with external property list editor all XML comments disappear. Seems like you have to always open it as source file to keep your comments.
Alternatively you may put your comments within tags:
<comment>my comments</comment>
I just tried out to edit my test.plist in the Eclipse XML editor. There I can do whatever I want. Maybe you should use a different XML editor, if you want your comments preserved.
I have also observed that if you place CDATA within String elements in a PList file, XCode will automatically strip the CData and XML encode all entities.
Related
After upgrading to iphone xcode 4.1 build 4B110F all of my localizable.strings files are showing up as gibberish in the xcode editor. I created these files using UTF-16. I can not find a way to tell the editor that they are UTF-16. I am able to view the Localizable.strings files by viewing as a property list, but if I view them as Source Code, I see gibberish. I like to translate the entire localization.strings file and paste it into the editor. I don't want to have to cut and paste one line at a time in the property editor. There should be some way to tell xcode to show the file as UTF-16. Does anyone have any ideas?
I tried removing the files and re-adding them. I used to get prompted for the UTF type, but it does not do this any more.
You can find the text encoding setting for a file in the Utility area of Xcode 4.1. The utility area is the right-handside lateral area.
In the utility area, look for and select the first pane, named "File Inspector".
There, you will find the text encoding in the "Text Settings" block. Expand if necessary using the triangle.
I had this same problem. I was able to work around it (without much actual investigation) by simply opening the previous string files in TextWrangler, then copy from TextWrangler and paste into XCode4's view of the string file. Things seem to be working fine as a result.
To fix XCode 4.1 UTF-16 encoding issues:
1: Open the file you want to change
2: Put your cursor into the file, which will give the editor focus (VERY IMPORTANT).
3: Proceed to look under the Utilities Pane (very far right) for Text Settings and use the Text Encoding drop down to select UTF-16 or whatever other encoding you want.
If you forget step 2, and only highlight the file in the Project Navigator, you will not see encoding options.
I renamed my project.. and step by step I renamed all the targets, AppDelegate classes etc. Anyway it builds now but crashes as it can't find the .momd in the below code:
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:#"MyApp" withExtension:#"momd"];
How do I get it to 'refresh' or build this momd file again? I have read various potential solutions involving adding a version on the .xdatamodeld file but heres the other thing.
When I click on the .xdatamodeld file it doesn't open up the editor anymore. It just does nothing. Right click bring me zero options.
I tried deleting the xdatamodeld file and creating a new one, but it has the same problem. When I press on it it doesn't open the editor.
When I create a brand new core data xcode project template, it does open the editor when I press on it. What am I doing wrong here?
I re-added the .xcdatamodeld file to my project and deleted the old reference. Works again now.
I'm still using Xcode 3, but when I double-click an .xdatamodeld file, it just opens the organizer. If I double-click an .xdatamodel file, it launches the project. This is probably because the xdatamodeld a folder, not a single file. It sounds like your problem is that the project file has lost its tracking to the mom you're using.
Here are some notes I made during past troubleshooting:
Troubleshooting dbase access — getting the right mom:
The first thing to suspect is that the managedObjectContext is not pointing to the correct data model (or managed object model, “mom”). (Actually, you are probably using the type:#“momd”, but it’s the target mom that’s been lost.)
In your app delegate, look for the accessor method managedObjectModel (created by Xcode when you stipulated Core Data store upon creating the project). Put a breakpoint in this method at the line that returns the mom.
Execute the program, and when it hits the breakpoint, go to the debugger model, and type “po” followed by the name of the mom variable being returned. (This is gdb’s “print object” command.)
What prints out will include “entities {” followed by a description of the entities in your data model. If nothing follows the brace, a blank mom is being returned — you’re not accessing the correct data model.
If clicking on the xcdatamodel in Xcode shows the full data model as expected, is it enclosed in an xcdatamodeld? That’s a sort of bundler/router/path file, and it may have lost its way. Do this:
- First, is the current xcdatamodel, the one with the green check icon, the first one? If not, drag it into first place, then test the app again.
- In Finder, make a copy of your xcdatamodel elsewhere for safekeeping.
- Get rid of the xcdatamodeld, in Finder and/or Xcode (I’m not sure which order I did this in). When done, it should not appear in Xcode.
- Drag the xcdatamodel (the one in the project folder) from the Finder to Xcode’s Groups & Files pane for the project, and choose the option that makes a copy for the project.
- Select the xcdatamodel, Design>DataModel>AddModelVersion. Now you should have a new xcdatamodeld file.
- Run the test again, doing the gdb print object command at breakpoint. Hopefully you’ll get a nice long printout, representing your data model.
- In future, avoid grouping the xcdatamodel/d files into a folder in Xcode. That seems to confuse things.
Examining the contents of the xcdatamodel/d files in Finder:
These are actually folders in disguise, as you will see if you remove their extensions. The guts of the data model is a plist, which you can open by double-clicking.
If you do this, test your app afterward and make sure it is still able to access your database. If not, follow the steps above.
I was in same situation, and finally fixed.
In my case, problem come from Xcode project group property: path.
Check path property of your project group that has xcdatamodeld file.
In my situation, it was different from xcdatamodeld file really exists,
and path of xcdatamodeld file was ../Model/XX.xcdatamodeld (example)
Anyway there were no problem, but someday I removed directory that is group's path property.
So Xcode couldn't find xcdatamodeld file. I add new xcdatamodled file, but this situation repeated.
Check if your xcdatamodeld file really exists in your project setting.
The solution for me was to revert back to a working copy of my .xcdatamodeld. Then, instead of renaming it via finder or the navigator pane of XCode 4, I selected the .xcdatamodeld file in the left navigation pane and edited the .xcdatamodeld's group name in the right pane of XCode 4 under the identity heading at the top.
Once I changed the name there to match my new project name, XCode automatically updated the name of the file on the file system for me.
I did not have to edit the path property as moon6pence suggested.
I am receiving the following error message:
2011-02-11 14:47:13.815 myProject[13177:207] Could not load the "icon-troubleshoot.png" image referenced from a nib in the bundle with identifier "com.myCompany.myProject"
This file is an old file that was being used before, but has now been deleted. As far as I know icon-troubleshoot.png is not used anywhere in my project. I tried cleaning and rebuilding, emptying caches but it didn't work. Searching for the string troubleshoot as a textual reference and "contains" selected returned nothing. Does anyone know how I can find what is causing this error?
The warning message suggests there is a reference to this png file in your .xib or .nib file(s).
Now the question is how to find it. Xcode is poor at doing this. Opening every nib file in a text editor like textedit and manual searching is time consuming.
The best solution I have for such searching tasks is to fire up terminal and use grep command. Go to source folder of your project in terminal then you can run the following in your case:
grep -i -r --include=*.xib "my-icon.png" ./
This will return all *.xib files where my-icon.png is referenced.
Later when you will see those *.xib files in xcode you'll find a '?' sign in place of my-icon.png showing that image is indeed missing as you deleted it. Now you deleted it to replace it with another image. So select '?' mark symbol, open Utilities area (to the right) and choose the correct file name. That is all.
as far as I know the search tool of x-code do not search inside the xib files that's why your search returns nothing. Anyway It's really probable there's still a reference in a xib file somewhere. Because xib files are just xml, if you don't want to check all them manually, try to open all your xib with a text editor like TextMate and perform a global text search over the content for the .png filename.
Hope this helps.
Ciao!
Clean the whole project and recompile.
There must be a reference to this file in one of the nibs. If you can't find it, try deleting the nib file where the image was used, and create a new one.
Also, check your bundle for a reference to the image file.
I had this exact same issue and I found that when I included this file in the project I didn't specify both my Development and Distribution targets, only Development, so as soon as I tried building Distribution target, it wasn't found. You have to delete reference to this image, then re-add it and make sure you checkmark all of the targets that it should be found in.
This could happen if you only have an imageName#2x.png image and have run a low resolution non-retina display build.
Cut the height and width in half in your favorite image editor and then save it in the same folder as the #2x as imageName.png
Select your storyboard object in solution explorer, right click on storyboard->"Open As"->"Source Code", now you will see xml code from storyboard. Search your image name with Cmd+F and replace or remove it.
I have a project with two Info.plist files (one for each target). In the second Info.plist, when I add a field it shows the internal name instead of the English name. For example UISupportedInterfaceOrientations instead of "Supported Interface Orientations".
Also, when I click on the dropdown list to see all options, some of the options that are available in the first .plist file are not in the second (eg CFBundleIconFiles). The two problems are really the same thing (anything which shows the internal name does not appear in the dropdown).
The Bundle Verion is 1.1 in both files, the CFBundleInfoDictionaryVersion are both the same, as are the plist version and the DTD.
What's stopping the second plist from giving me these options? Thanks.
alt text http://img.skitch.com/20100708-ctia2e6yfwgd7twdnepryidayr.jpg
Xcode has a couple of different editors to show the contents of plist files. One of them is the generic plist editor, which shows the names of the keys without translation. The plist editor can also be in the specialized Info.plist mode, where it knows about the structure of this special type of plist file and translates keys to english.
I don't know how Xcode decides which editor to use, so the following is just guessing: I assume Xcode looks into the selected target to check the path to the Info.plist file and if it is the edited file, uses the specialized editor. So if you have one target selected, but open the other targets Info.plist it might use the generic editor instead.
Xcode also manages file types for each file in the project. You can override Xcode's automatic guesses by opening the file's settings (click on the file in the outline view and press command-I). Maybe there's a file type to identify Info.plist files.
As a last resort, you can always open the file by right clicking it in the outline view. In the context menu from "Open as ..." you can choose how to open it. I usually use "Source Code File" since I like to see the original XML.
Typically, there are times when not all options are shown. If you know it is supposed to exist, you can just add the key (via copy/paste) from the XML file of the other info.plist. I normally just open it up as XML and work in that mode (which gives non-English names).
All keys can be found here: http://developer.apple.com/iphone/library/documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html
In the latest XCode, it has been converting everything automatically to English names for me though even when I try to paste as a non-English name in the property list editor.
Short Answer
Select iPhone Info.plist from the View > Property List Type menu.
Explanation
This actually has nothing to do with the plist file itself. It's how Xcode (via the Property List Editor) presents the file.
You can test this by, in Finder, making a copy of a correctly-displaying plist file. Open the copy in the Property List Editor (usually the default application). The copy usually won't display the English names (until you change the Property List Type).
Xcode will remember the type you select and save it in the .xcodeproj file.
For some reason I cannot get the Settings.bundle to recognize my additional languages. I must be missing something obvious, but I just cannot figure it out. Here's what I've got:
Project Structure in XCode:
Root.plist file:
Root.plist file http://img227.imageshack.us/img227/571/screenshot20100624at334.png
French Root.strings file
french Root.strings file http://img121.imageshack.us/img121/571/screenshot20100624at334.png
From everything I've read, I believe the project structure is right. The StringsTable in the Root.plist matches the name of the individual .strings files, and the Key for each item in the Root.plist has a match in the .strings files as well.
Why don't I see French text in my settings when I change the default iPhone language?
Thanks in advance!
For me, the problem was leaving off a semi-colon!
In localizable.strings, you get a runtime error if you omit the ";", but in Root.strings, you don't get any warnings, you can run it fine, but it just won't work!
So double-check to make sure you punctuate each key:value pair with a semi-colon!
I'll go ahead and answer my own question since I solved the problem myself through testing and failing. Hopefully this will help someone else in the future.
First, I think my Root.plist file may have been corrupted. I'm not exactly sure why, but I completely deleted the Settings.bundle, and re-created it to be sure.
Second, and perhaps most importantly, the main issue was the "key" in the root.strings file didn't match to the "key" field in the Root.plist, it actually matches the "Title" field.
Once I made those changes to the Root.strings file, it all started to work.
All you have to do is keep (or Add, if it's not there) "Strings Filename" in the Root.plist, after your settings.
Then, add Value "Root" (or, the name of your file and the translations) to make the created lang.lproj translations functional.
In my case, it appeared as if "Strings Filename" was set to "Root" in the Property List View of Root.plist, but when viewed the file in Source Code View, it was actually "StringsTable" pointing to "Root". The solution is to add another entry where "Strings Filename" points to "Root". (I also tried deleting the previous entry, but then it stops working, so you need both.)
In Xcode 5 there is still no obvious way to localize the Settings.bundle.
The problem
Xcode doesn't allow you to localize a file that is only shown because it is a file inside a folder that's directly shown in Xcode (hence the blue folder icons in the tree).
The Solution:
right-click the Root.strings file and select "Show in Finder"
List item
move the Root.strings file one folder up, so that the en.lproj folder is empty and the
Cmd-Drag the Root.strings file is next to the Root.plist.
delete the now empty en.lproj
go back to Xcode, notice that the tree will reflect the changes you now made
cmd-drag the file in the tree outside to outside the settings-bundle, so that it appears next to your source-code.
Do not copy the file
a dialog will appear asking you what to do with the file.
DO NOT select the checkbox to copy the file (you need this to be a reference)
DO NOT select a target to include the strings-file (the settings.bundle is already assigned to the correct target)
in the file inspector you can now choose to localize the file and to add languages to the localizations. The files will be placed correctly inside the settings.bundle and the tree will automatically reflect these changes, too.
After some repeated tries to activate localization,following steps worked for me:
Close xcode
Drag and duplicate the settings bundle onto the desktop (or wherever)
Open bundle contents
Drag Root.strings into
the en.lproj folder
Duplicate the en.lproj folder and rename to
whatever language you want (using 2-letter code ie fr.lproj)
Replace the original settings bundle with the new one(without
opening xcode).
Now Open xcode and the new files and folders
should be there
Now delete the older app and run xcode,Works fine in simulator and on device.
NOTE:Closing xcode,updating of duplicated setting bundle outside xcode and replacing updated back only will help.