ios_builds.sh (1642B)
1 #!/bin/bash 2 3 set -e 4 TEAM_ID=$(more ~/Developer/mac_id) 5 6 if [ "$1" == "help" ]; then 7 echo "Run bash ios_build.sh build clean" 8 echo "Run bash ios_build.sh version" 9 echo "Go to Xcode Archive Organizer and upload!" 10 exit 11 fi 12 13 cd Plugin 14 15 if [ "$1" == "build" ] || [ "$1" == "configure" ]; then 16 echo "Running CMake configuration..." 17 18 # clean up old builds 19 if [ "$2" == "clean" ]; then rm -Rf build-ios; fi 20 21 # generate new builds 22 cmake -Bbuild-ios -GXcode -DCMAKE_SYSTEM_NAME=iOS \ 23 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.4 \ 24 -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM="$TEAM_ID" \ 25 -DCMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY="1,2" \ 26 -DCMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE="NO" 27 28 if [ "$1" == "build" ]; then 29 xcodebuild -project build-ios/CHOWTapeModel.xcodeproj \ 30 -scheme CHOWTapeModel_Standalone archive -configuration Release \ 31 -sdk iphoneos -jobs 12 -archivePath CHOWTapeModel.xcarchive | xcpretty 32 fi 33 fi 34 35 if [ "$1" == "version" ]; then 36 # set version number to include commit hash 37 COMMIT=$(git log --pretty=format:'%h' -n 1) 38 VERSION=$(cut -f 2 -d '=' <<< "$(grep 'CMAKE_PROJECT_VERSION:STATIC' build-ios/CMakeCache.txt)") 39 BUILD_NUMBER="$VERSION-$COMMIT" 40 echo "Setting version for archive: $BUILD_NUMBER" 41 42 PLIST=CHOWTapeModel.xcarchive/Info.plist 43 /usr/libexec/Plistbuddy -c "Set ApplicationProperties:CFBundleVersion $BUILD_NUMBER" "$PLIST" 44 45 # move to archives folder so Xcode can find it 46 archive_dir="$HOME/Library/Developer/Xcode/Archives/$(date '+%Y-%m-%d')" 47 echo "Moving to directory: $archive_dir" 48 mkdir -p "$archive_dir" 49 mv CHOWTapeModel.xcarchive "$archive_dir/CHOWTapeModel-$COMMIT.xcarchive" 50 fi