Using PlistBuddy to Manage Info.plist
PlistBuddy is a cli tool provided by macOS which allows manipulation of Property List (.plist
) files.
One useful example for iOS apps is modifing entries in Info.plist
. React Native apps by default, allow content hosted locally to run via http. This is required for local development since React Native apps communicate with a bundler on localhost
. This is done through an ATS rule in Info.plist
:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
Before distributing your app into production however, its a good to reenable ATS fully. So removing that NSExceptionDomains
entry. For apps that are built using a build server, this step can be automated using PlistBuddy.
/usr/libexec/PlistBuddy -c "Delete :NSAppTransportSecurity:NSExceptionDomains" /path/to/your/project/Info.plist