Search code examples
xcodeplist

Substitute variables in XCode for plist files (not Info.plist!)


I have multiple PList Files in XCode and added via Editor -> Add Build Setting -> Add User-Defined Setting some settings to the XCode projekt. When I use the variables (for example $(MY_COOL_SETTING) in the Ìnfo.plist this works fine. But I have some other plist files that get embedded via a Linker command to the executable (via -sectcreate). The variables in this PList file will NOT get substituted. Is there any way to tell XCode to replace the variables with the values before the Linker?


Solution

  • As someone favorited this question I will post my solution here. I do not have the source or XCode at hand right now, but I will do it as best as possible via memory. What I have done is add a custom BASH script, added this as a custom build step to be executed before the linker. You can do this in xcode. This is well explained here:

    https://www.hockeyapp.net/help/runscriptbuildphase/

    In the script you can use the tool PListBuddy to alter your PLists according to what you want. The usage of PListBuddy is very well explained here:

    https://fgimian.github.io/blog/2015/06/27/a-simple-plistbuddy-tutorial/