Xcode does not respect encoding declaration in XML-plist xcodeproj.

Originator:eloy.de.enige
Number:rdar://13565397 Date Originated:03-Apr-2013 11:21 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 4.x
Classification:Other Bug Reproducible:Always
 
Summary:

Disclaimer: I’m from the CocoaPods team (http://cocoapods.org).

CocoaPods uses the CFPropertyList APIs to read and write ‘xcodeproj’ documents. The encoder no longer supports encoding to kCFPropertyListOpenStepFormat, which means we have to encode to XML.

This works all nicely as long as all the content in the document is in MacRoman. When it’s not, the Xcode plist encoder will insert a magic-comment at the top of the plist to indicate that the encoding is UTF-8, this is then checked for by the Xcode decoder before reading the complete plist.

In our case (an XML plist), however, we can’t insert the magic-comment, because it would be invalid XML. The XML actually has the proper encoding specified in its declaration, but Xcode ignores this and reads the data as MacRoman nonetheless.

We are of course aware that this is a somewhat private implementation detail, but it would still be great if Xcode would support reading XML plists with the declared encoding, so that developers from all over the world can use Xcode and CocoaPods without worrying about encoding issues.

Steps to Reproduce:

1. Create project
2. Add file with characters not found in MacRoman
3. Save
4. Convert project.pbxproj to XML plist (See notes [2])
5. Open project in Xcode

Expected Results:

That Xcode (or rather its plist decoder) would respect the XML encoding declaration.

Actual Results:

Treats it as MacRoman instead.

Regression:

I think this has been the case forever.

Notes:

[1] CocoaPods ticket on the subject: https://github.com/CocoaPods/CocoaPods/issues/926#issuecomment-15778982
[2] Sample XML plist xcodeproj: http://cl.ly/2c0n2v3C022S

Comments

We have found a interim workaround, which is to encode everything outside of ASCII with XML entities: https://github.com/CocoaPods/Xcodeproj/blob/0.5.4/lib/xcodeproj/project.rb#L257…L286.

By eloy.de.enige at April 4, 2013, 7:46 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!