Forest_Client/Tool/BuildTool/build_xcode_xworkspace.sh

78 lines
2.3 KiB
Bash
Raw Normal View History

2024-06-12 15:01:54 +08:00
#!/bin/bash
# This script automates the process of building an Xcode project and creating an IPA file.
SHELL_DIR=$(dirname $0)
echo "change dir to $SHELL_DIR"
cd "$SHELL_DIR"
PROJECT_NAME="$1"
SCHEME_NAME="$2"
PLATFORM="$3"
VERSION="$4"
# Define variables
BUILD_NAME="AveryBuild"
PROJECT_PATH="../../Builds/$PLATFORM/$VERSION/$BUILD_NAME/"
#PROJECT_NAME="Unity-iPhone" # Replace with your Xcode project name (without the .xcodeproj extension)
#SCHEME_NAME="Unity-iPhone" # Replace with your Xcode scheme
OUTPUT_DIRECTORY="../" # Replace with the desired output directory for the IPA file
# create export Options plist
#echo "Generating a new exportOptions.plist file"
#sh generate_exportOptions.sh $PACKAGE_NAME $PACKAGE_ID
# Define source and destination paths
EXPORT_OPTIONS_FILE="./exportOptions.plist"
# Xcode Dependencies
PODFILE="./Podfile"
PODFILE_LOCK="./Podfile.lock"
#Specify the full path to the pod command (modify as needed)
POD_PATH="/Users/mayuanzheng/.gem/ruby/3.0.0/bin/pod"
# Copy the file
echo "copy export options to $PROJECT_PATH"
cp "$EXPORT_OPTIONS_FILE" "$PROJECT_PATH"
# Copy the podfile
echo "Copy podfile && podfile.lock to $PROJECT_PATH"
cp "$PODFILE" "$PROJECT_PATH"
cp "$PODFILE_LOCK" "$PROJECT_PATH"
echo "change direction to $PROJECT_PATH"
cd $PROJECT_PATH
#Set the environment character encoding to UTF-8
export LANG=en_US.UTF-8
# Run pod install to install dependencies
echo "Running pod install..."
$POD_PATH install
#Restore original language settings
export LANG=$ORIGINAL_LANG
xcodebuild -list -workspace $PROJECT_NAME.xcworkspace
echo "clean..."
xcodebuild clean
# Build the Xcode workspace and create an archive
echo "Building Xcode workspace..."
xcodebuild archive -workspace $PROJECT_NAME.xcworkspace -scheme $SCHEME_NAME -archivePath $OUTPUT_DIRECTORY/$PROJECT_NAME.xcarchive
# Export the archive to create an IPA file
echo "Exporting archive to IPA..."
xcodebuild -exportArchive -archivePath $OUTPUT_DIRECTORY/$PROJECT_NAME.xcarchive -exportPath $OUTPUT_DIRECTORY -exportOptionsPlist exportOptions.plist
# Clean up the temporary archive
echo "Cleaning up temporary archive..."
rm -rf $OUTPUT_DIRECTORY/$PROJECT_NAME.xcarchive
# The script is now complete.
echo "Build process completed. IPA file is available at: $OUTPUT_DIRECTORY/YourProject.ipa"