41

I just hit a brick wall with xCode not wanting to parse my Info.plist file. I've replaced the file several times with older (identical) versions of the file that I had previously backed up, and I'm still getting the same error.

Here is the complete error message:

couldn't parse contents of '/Users/...Info.plist': The data couldn’t be read because it isn’t in the correct format.

I'm clueless on this one. I'm using xCode 5.0.1, Mavericks

AstroCB
  • 12,337
  • 20
  • 57
  • 73
jhilgert00
  • 5,479
  • 2
  • 38
  • 54

9 Answers9

85

This is one of the best way to detect on which line the error is occurring.

Just go the directory where the plist file is present then write this command on terminal->

plutil filename.plist
Vizllx
  • 9,135
  • 1
  • 41
  • 79
  • 12
    I know that SO is weary of gratitude, but this small tip just made my day! I would have found the merge indicators with a text editor eventually, but the utility pointed me right to it! Thank you! – Tony Adams Jan 30 '16 at 01:02
  • Perfect answer. Ran the command and it gave me the line number. Through xcode, right clicked on plist, opened as source code and went to the line. It turned out that bundle number had got repeated 2 times. So I removed one. Cleaned and Built. Project ran successfully. – TharakaNirmana Jul 26 '16 at 04:59
  • This is particularly useful as your plist can be valid xml but still an invalid plist – lewis Nov 09 '16 at 09:45
  • 1
    Nailed like chuck norris! – Marlhex Oct 31 '19 at 20:01
15

Another cause of this issue can be from attempting to put URLs (really just slashes etc.) in your app-Info.plist.

Get around it by simply raising the -traditional flag inside of the Info.plist Other Preprocessor Flags option in your project build settings.

enter image description here

capikaw
  • 12,232
  • 2
  • 43
  • 46
  • 4
    OMG that is SO OBSCURE, but it fixes my problem! Thank you!! In my case, I have a Sparkle SUFeedURL in my plist which apparently caused the preprocessor to go bonkers. Where did you even find the documentation for `-traditional`?? And what does it mean? – nevyn Dec 17 '15 at 02:25
4

I think you have used source-control tools, you can use basic text-edit tool without Xcode to open this plist, command + F to find "<<<<<" or ">>>>>", then you will probably find error string such as:

<<<<<<< .mine

>>>>>>> .r605

select the correct string, and delete the other one, error is resolve!

Immanito
  • 49
  • 5
2

Looks like replacing the file with a backup, then deleting the derived data for the project in Organizer was the cure. Hope this helps someone else later on.

jhilgert00
  • 5,479
  • 2
  • 38
  • 54
  • I tried to replace the plist file, as well as the project file and I'm still getting errors. ugh! – ganders Jan 16 '14 at 16:26
2

I personally ruined the file when git merge raised conflicts. .plist is an XML file and git conflict added <<<< and >>>> in there to tag the differences.

Find the .plist file in Finder (in one of your project's folders). Open it in a text editor, find the lines that don't look like proper XML, remove them and be sure to remove the duplicate XML line/node (due to pre and post git recorded changes).

Surpher
  • 517
  • 4
  • 10
2

This may also simply happen because you have moved the Info.plist file into a new folder, or removed it from a folder (basically, if its path changed).

Go to Build Settings and search for "Info.plist file". Edit the value. For instance, if you have moved your plist file from the main folder to a subfolder called Resources, you will have to do the following change:

Before:

TargetName/Info.plist

After:

TargetName/Resources/Info.plist
Kqtr
  • 5,824
  • 3
  • 25
  • 32
1

When building for iOS, the Info.plist may be corrupted whenever Default Orientation is set to Auto Rotation. The Info.plist file is created properly on the first build, but subsequent builds results in...

<key>UIInterfaceOrientation</key>
<string></string>
</string>

... at this point Xcode fails to build the project.

Jason King
  • 649
  • 7
  • 13
  • Is there a fix for this besides deleting the file and regenerating it? – Andrew Sep 13 '14 at 01:13
  • I was having the same error,according to @Vizllx way to do, still error. Then I use Sublime Text to open info.plist, found that the code conflict. – Kathen Mar 31 '17 at 08:26
0

I was having the same error, and realized the issue was that I had a URL (e.g. http://example.com/something) as a value in my Info.plist, and I just switched on pre-processing for it (without the -traditional flag). Apparently Xcode will treat the // as a comment marker, and omit the rest of the line.

A work-around I found is to embrace the pre-processor, like so: http:/${}/example.com/something, which breaks up the // by putting an empty string substation in the middle so it doesn't look like a comment to Xcode, but after pre-processing it's back to a normal URL.

Kelan
  • 2,296
  • 1
  • 15
  • 17
0

This error comes whenever Xcode preprocessor is not able to parse the info.plist file.

So to find out the error in the specific line do the following steps :

  1. Open your project.xcworkspace in Xcode
  2. Go to the project's navigator
  3. Inside your project click on the info file, if an error exists then it will popup the dialog with the line number where the error exists

You can see the below image of the popup dialog for reference, which is in my case was showing the error on line 35

enter image description here

Hope this will help you or somebody else. Thanks!

Happy Coding :-)

Aman Kumar Gupta
  • 2,640
  • 20
  • 18