Skip to content

Instantly share code, notes, and snippets.

@Andrew0000
Last active March 30, 2026 09:01
Show Gist options
  • Select an option

  • Save Andrew0000/976f796811acd86e394e591236cd9956 to your computer and use it in GitHub Desktop.

Select an option

Save Andrew0000/976f796811acd86e394e591236cd9956 to your computer and use it in GitHub Desktop.
Build, upload iOS ipa from KMP
# Update build version and develipment team
/usr/libexec/Plistbuddy -c "Set CFBundleVersion ${BUILD_NUMBER}" "${WORKSPACE}/iosApp/iosApp/Info.plist"
sed -i '' 's/TEAM_ID=;/TEAM_ID=paste_here;/' "${WORKSPACE}/iosApp/Configuration/Config.xcconfig"
sed -i bak -e 's|CURRENT_PROJECT_VERSION=.*|CURRENT_PROJECT_VERSION='"${BUILD_NUMBER}"'|g' "${WORKSPACE}/iosApp/Configuration/Config.xcconfig"
sed -i '' 's/DEVELOPMENT_TEAM = "${TEAM_ID}";/DEVELOPMENT_TEAM = paste_here;/' "${WORKSPACE}/iosApp/iosApp.xcodeproj/project.pbxproj"
echo "build num: ${BUILD_NUMBER}"
./gradlew -v
./gradlew clean
rm -rf "${WORKSPACE}/iosApp/iosApp/${APPNAME}.xcarchive" > /dev/null
cd "${WORKSPACE}/iosApp/"
xcodebuild \
-workspace iosApp.xcodeproj/project.xcworkspace \
-scheme "${APPNAME}" \
-configuration Release \
clean \
-destination 'generic/platform=iOS' \
-archivePath "iosApp/${APPNAME}.xcarchive" \
archive | xcbeautify
cd "${WORKSPACE}/iosApp/iosApp"
xcodebuild -exportArchive \
-archivePath "${WORKSPACE}/iosApp/iosApp/${APPNAME}.xcarchive" \
-exportPath "${WORKSPACE}/build/ios" \
-exportOptionsPlist "${WORKSPACE}/iosApp/iosApp/exportOptions-app-store.plist" \
-allowProvisioningUpdates
IPA="${WORKSPACE}/build/ios/${APPNAME}.ipa"
xcrun altool --validate-app \
--file "${IPA}" \
--username "paste_here" \
--password "@keychain:itunesconnect" \
--type ios || exit 1
xcrun altool --upload-app \
--file "${IPA}" \
--username "paste_here" \
--password "@keychain:itunesconnect" \
--type ios || exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment