0

I have an iOS application that is using the Agentry framework to define the Agentry server URL to connect. The agentryServerURL parameter is included in a separate branding.plist file as per the SAP specs. What I am trying to do is tie my iOS schemes for the different environments to a pre-build action in order to change the Agentry URL value.

Here is my current script but it is not working.

#!/bin/sh

plist=$SRCROOT"/branding.plist"

if [ ${CONFIGURATION} = "DEV" ]; then
/usr/libexec/PlistBuddy -c "Set :agentryServerURL https://smpdevURL" "$plist"

if [ ${CONFIGURATION} = "QA" ]; then
/usr/libexec/PlistBuddy -c "Set :agentryServerURL https://smpqaURL" "$plist"

if [ ${CONFIGURATION} = "Release" ]; then
/usr/libexec/PlistBuddy -c "Set :agentryServerURL https://smpprodURL" "$plist"
    fi

This is the first time I have written a pre-build script so it is likely something with my syntax

Michael Hulet
  • 3,253
  • 1
  • 16
  • 33
Nate23VT
  • 423
  • 8
  • 27

1 Answers1

2

Try this:

#!/bin/sh

plist="${SRCROOT}/branding.plist"

if [ "${CONFIGURATION}" == "DEV" ]; then
/usr/libexec/PlistBuddy -c "Set :agentryServerURL https://smpdevURL" "$plist"
elif [ "${CONFIGURATION}" == "QA" ]; then
/usr/libexec/PlistBuddy -c "Set :agentryServerURL https://smpqaURL" "$plist"
elif [ "${CONFIGURATION}" == "Release" ]; then
/usr/libexec/PlistBuddy -c "Set :agentryServerURL https://smpprodURL" "$plist"
fi
clarus
  • 2,455
  • 18
  • 19
  • This did not work, one difference that I realized is my configuration is actually Debug/QA/Release so I changed that in the IF statement but still no luck. Is there something I need to do to install plistbuddy? – Nate23VT Sep 20 '17 at 16:04
  • Hmm it worked for me here when I set it up as a script build phase for the target. Like your original, it requires that the plist you're changing already be in the same directory as your project file, with the key you're going to change present in that. So, top level of the plist should be the root dictionary, and then in that you should have a key of agentryServerURL with a string value. Do you have that? – clarus Sep 20 '17 at 17:30
  • 1
    The issue was that I had not selected the 'provide build settings from' value. – Nate23VT Sep 21 '17 at 19:01