0

I have my project plist file and in it there are some default key-values and some custom key-values.

Now I created my appconfig.xcconfig file and I would like to know if I can obtain the value according to some key in the plist file?

So for example, I added a key-value pair in the plist like this:

<key>custom_key</key><value>custom_string</value>

Now in my xcconfig file, how can I get the custom_string? Is it able to do that in Xcode?

12
  • you can read value from xcconfig to plist using $(custom_key)
    – a.masri
    Apr 10, 2018 at 9:21
  • @a.masri have you tried this, is it working? Since I tried and it doesn't work for me.
    – bolizhou
    Apr 11, 2018 at 1:31
  • Yes it's working i'm sure
    – a.masri
    Apr 11, 2018 at 5:57
  • how to you add xcconfig in to your project ?
    – a.masri
    Apr 11, 2018 at 5:59
  • @a.masri, thanks for replying, I added it in Info -> Configurations -> Debug/Release -> myxcconfig
    – bolizhou
    Apr 11, 2018 at 6:15

1 Answer 1

0

If you need read xcconfig value into plist, you can use:

$(KEY_NAME) 

If you need read plist value info xcconfig, you can use run script, as follows:

1- Go to targets and select your target.

2- Select build phases.

3- Click on add -> select new run script phase.

4- Add this command for example:

BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "${BUILD_ROOT}/${INFOPLIST_PATH}") 

echo "BUNDLE = $BUNDLE_ID" >> BUILDROOT/NAME.xcconfig 

5- Build your project (command + B).

6- Open your xcconfig you will find the value has been added.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.