Last active
August 4, 2023 08:23
-
-
Save andrius-k/b43d8b235b507dc17330b04e114e7583 to your computer and use it in GitHub Desktop.
Shell script to generate and modify Info.plist values based on original file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Get content of original Info.plist file | |
originalFileContent="$(cat Info.plist)" | |
# Save build configuration passed by IDE | |
buildConfiguration=$1 | |
# Get CFBundleIdentifier value from original Info.plist file | |
bundleId=$(defaults read $(pwd)/Info CFBundleIdentifier) | |
# Overwrite Info.Generated.plist with content of original file | |
echo $originalFileContent > Info.Generated.plist | |
# Append appropriate prefix to CFBundleIdentifier | |
# and replace iconAssets value | |
if [ $buildConfiguration = "Debug_Dev" ] || [ $buildConfiguration = "Release_Dev" ]; then | |
bundleId+="-development" | |
iconAssets="Assets.xcassets/AppIcon-Dev.appiconset" | |
elif [ $buildConfiguration = "Debug_Staging" ] || [ $buildConfiguration = "Release_Staging" ]; then | |
bundleId+="-staging" | |
iconAssets="Assets.xcassets/AppIcon-Staging.appiconset" | |
else | |
iconAssets="Assets.xcassets/AppIcon-Production.appiconset" | |
fi | |
# replace CFBundleIdentifier | |
plutil -replace CFBundleIdentifier -string $bundleId Info.Generated.plist | |
# Use command below if binary .plist format is needed | |
#defaults write $(pwd)/Info.Generated CFBundleIdentifier $bundleId | |
# replace XSAppIconAssets | |
plutil -replace XSAppIconAssets -string $iconAssets Info.Generated.plist | |
# Use command below if binary .plist format is needed | |
#defaults write $(pwd)/Info.Generated XSAppIconAssets $iconAssets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment