Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kibotu/09f45b2a26f38fe8fa3166a796335c75 to your computer and use it in GitHub Desktop.
Save kibotu/09f45b2a26f38fe8fa3166a796335c75 to your computer and use it in GitHub Desktop.
Build iOS Project on command line. Set MARKETING_VERSION and CURRENT_PROJECT_VERSION.
#!/bin/bash
# https://stackoverflow.com/a/76070326/1006741
# Set the version and build numbers
VERSION_NUMBER="2.1.0"
BUILD_NUMBER="29"
APP_NAME="MyApp"
TEAM_ID="ABCDEFGH"
# Set the Xcode project file path
PROJECT_FILE="$APP_NAME.xcodeproj/project.pbxproj"
# Update the MARKETING_VERSION and CURRENT_PROJECT_VERSION values in the project file
sed -i "" "s/MARKETING_VERSION = .*/MARKETING_VERSION = $VERSION_NUMBER;/g" "$PROJECT_FILE"
sed -i "" "s/CURRENT_PROJECT_VERSION = .*/CURRENT_PROJECT_VERSION = $BUILD_NUMBER;/g" "$PROJECT_FILE"
# Set the archive path
ARCHIVE_DATE=$(date +"%Y-%m-%d")
ARCHIVE_TIME=$(date +"%H.%M")
ARCHIVE_FILENAME="$APP_NAME $ARCHIVE_DATE, $ARCHIVE_TIME.xcarchive"
ARCHIVE_PATH="~/Library/Developer/Xcode/Archives/$ARCHIVE_DATE/$ARCHIVE_FILENAME"
# Archive the Xcode project
xcodebuild \
-scheme "$APP_NAME" \
-project "$APP_NAME.xcodeproj" \
-configuration "Release" \
-destination "generic/platform=iOS" \
-archivePath "$ARCHIVE_PATH" \
archive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment