I have two values in my info.plist file let's say string1 , string 2
I want to add a run script that compare the two values and invoke a build error if the values are not equal.
I'm new to scripting to I'm facing some syntax issues, here's what I've accomplished so far
set string1 to $(/usr/libexec/PlistBuddy -c "Print string1" "${PROJECT_DIR}/${INFOPLIST_FILE}")
set string2 to $(/usr/libexec/PlistBuddy -c "Print string2" "${PROJECT_DIR}/${INFOPLIST_FILE}")
echo string1
echo string2
if string1 = string2 then
echo "no errors" else
echo "generate build error in xcode"
Any pointers are highly appreciated. Thanks
Error you are facing its because of wrong syntax in if else loop and setting value to the variables
# Basic value settings to the variable from the command execution
string1=$(/usr/libexec/PlistBuddy -c "Print string1" "${PROJECT_DIR}/${INFOPLIST_FILE}")
string2=$(/usr/libexec/PlistBuddy -c "Print string2" "${PROJECT_DIR}/${INFOPLIST_FILE}")
#Below is the basic if else loop in shell scripting with string comparison
if [ "$string1" = "$string2" ]
then
echo "EQUAL"
else
echo "NOT EQUAL"
fi
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With