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"
|
|
|
|
|
2024-07-31 16:37:34 +08:00
|
|
|
if [ -f ./local_env.sh ]; then
|
|
|
|
source ./local_env.sh
|
|
|
|
echo "found the local_env file"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 获取项目相关参数
|
|
|
|
if [ -f ./project_env.sh ]; then
|
|
|
|
source ./project_env.sh
|
|
|
|
echo "found the project_env file"
|
|
|
|
fi
|
|
|
|
|
2024-06-12 15:01:54 +08:00
|
|
|
PROJECT_NAME="$1"
|
|
|
|
SCHEME_NAME="$2"
|
|
|
|
PLATFORM="$3"
|
|
|
|
VERSION="$4"
|
|
|
|
|
|
|
|
PROJECT_PATH="../../Builds/$PLATFORM/$VERSION/$BUILD_NAME/"
|
2024-07-31 16:37:34 +08:00
|
|
|
|
2024-06-12 15:01:54 +08:00
|
|
|
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"
|
|
|
|
|
2024-07-31 16:37:34 +08:00
|
|
|
#来自打包机 pod路径
|
|
|
|
#POD_PATH="/Users/mayuanzheng/.gem/ruby/3.0.0/bin/pod"
|
2024-06-12 15:01:54 +08:00
|
|
|
|
|
|
|
# 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.
|
2024-07-31 16:37:34 +08:00
|
|
|
echo "Build process completed. IPA file is available at: $OUTPUT_DIRECTORY/$BUILD_NAME.ipa"
|