Xcode 4.3 - preprocess plist no longer works for #define with "http: //"?

I just upgraded to 4.3 Xcode. I have my plist.which preprocessed and compared to 4.2 it doesn't seem to work anymore.

I set the flag Info.plist other pre-processor -traditional (to skip // , considered as a comment).

I have installed

  #define MYSERVER http://127.0.0.1:1234/ 

and in my plist

  <key>myhost</key> <string>MYSERVER</string> 

When I test the new Xcode 4.3, I see inside NSDictionary *bundle = [[NSBundle mainBundle] infoDictionary];

  myhost = "http:/ /127.0.0.1:1234/" 

I have a quick hack for him.

  NSString *hack = [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"myhost"] stringByReplacingOccurrencesOfString:@" " withString:@""]; url = [NSURL URLWithString:hack]; 

This makes my application work again, but I would like to have a clean solution. Any ideas?

+6
source share
2 answers

This is actually a bug in the clang preprocessor that ships with Xcode 4.3 (clang 3.1), and this affects all the preprocessing, not just Info.plists. I filed an error ( LLVM error 12035 , rdar: // 10883862).

A workaround for this is to force Xcode 4.3 to use llvm-gcc to preprocess Info.plist instead of clang. The only way I've found so far is to rewrite the symbolic link "cc" that is used in the preprocessing phase of Info.plist:

sudo ln -fs /usr/bin/llvm-gcc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc

To return this hack, simply rewrite it back to clang: sudo ln -fs /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc

+3
source

You can skip the pre-processor and use PlistBuddy.

Something like this in the build script phase should work:

 #!/bin/sh MYSERVER = 'http://127.0.0.1:1234/' /usr/libexec/PlistBuddy -c "Set :myhost ${MYSERVER}" path/to/Info.plist 

Please note that if you do this in ProejctName-Info.plist in the standard Xcode setting, the file will be marked as modified svn / github every time you build it and depending on your needs, which may not be ideal.

0
source

Source: https://habr.com/ru/post/908760/


All Articles