I am new to the Cordova CLI.
I need to perform the following steps programmatically via Cordova.
You can use the PlistBuddy utility inside a Cordova hook script to modify the *-Info.plist file.
For example, I have the following script under
which adds a dictionary property and adds an entry within that dictionary:
#!/bin/bash
PLIST=platforms/ios/*/*-Info.plist
cat << EOF |
Add :NSAppTransportSecurity dict
Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool YES
EOF
while read line
do
/usr/libexec/PlistBuddy -c "$line" $PLIST
done
true
Be sure to make the script executable (chmod +x
).
The true
at the end of the script is because PlistBuddy
returns with an error exit code if the key being added already exists, and doesn't provide a way to detect if the key already exists. Cordova will report a build error if the hook script exits with an error status. Better error handling is possible but a pain to implement.