Below is a build number generator script that ensures all extensions get the same build number as the main app.
First, replace MyApp, MyTodayWidget etc. with the actual app and extension names from your project. Then in Xcode, add the script to the main app build phases as a "New Run Script Phase", after the "Copy Bundle Resources" phase.
# Set the build number to the count of Git commits
buildNumber=$(git rev-list HEAD | wc -l | tr -d ' ')
# Enlist app name and extension names
app="MyApp"
todayExtension="MyTodayWidget"
watchKitExtension="MyWatchExtension"
watchKitApp="MyWatchApp"
# Ensure extension build numbers are the same as the main app
appDir="${app}.app"
todayExtensionDir="${appDir}/PlugIns/${todayExtension}.appex"
watchKitExtensionDir="${appDir}/PlugIns/${watchKitExtension}.appex"
watchKitAppDir="${watchKitExtensionDir}/${watchKitApp}.app"
plistDirs=( "$appDir" "$todayExtensionDir" "$watchKitExtensionDir" "$watchKitAppDir" )
for dir in "${plistDirs[@]}"
do
plist=${dir}/Info.plist
echo "Updating ${TARGET_BUILD_DIR}/$plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${TARGET_BUILD_DIR}/${plist}"
done
No comments:
Post a Comment