Created
April 20, 2022 16:15
-
-
Save u5-03/d5c534490853f3d30441b66538b10301 to your computer and use it in GitHub Desktop.
xcframework build script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FRAMEWORK_NAME="SCHEME_NAME" | |
FILE_PATH=$(cd $(dirname $0) && pwd) | |
# Ref: https://qiita.com/tfactory/items/34f9d88f014c47221617 | |
# Output directory (project root directly) | |
OUTPUT_DIR=$FILE_PATH/path/to/project_root | |
# Output destination directory for intermediate files | |
DERIVED_DIR=${OUTPUT_DIR}/$FRAMEWORK_NAME-derived | |
# archive output directory | |
ARCHIVE_DIR=${OUTPUT_DIR}/$FRAMEWORK_NAME-archive | |
# xcframework output directory | |
XCFRAMEWORK_DIR=${OUTPUT_DIR}/$FRAMEWORK_NAME-xcframework | |
# Create output destination directory for intermediate files | |
mkdir -p ${DERIVED_DIR} | |
# Create output destination directory for archive files | |
mkdir -p ${ARCHIVE_DIR} | |
# Create output destination directory for xcframework | |
mkdir -p ${XCFRAMEWORK_DIR} | |
# Archive file for iOS real machine | |
ARCHIVE_FILE_IOS=${ARCHIVE_DIR}/ios.xcarchive | |
echo "ARCHIVE_FILE_IOS:${ARCHIVE_FILE_IOS}" | |
# Archive file for iOS simulator | |
ARCHIVE_FILE_IOS_SIMULATOR=${ARCHIVE_DIR}/iossimulator.xcarchive | |
echo "ARCHIVE_FILE_IOS_SIMULATOR:${ARCHIVE_FILE_IOS_SIMULATOR}" | |
# Creating an archive file for the actual iOS device | |
xcodebuild archive -workspace Frameworks.xcworkspace -scheme $FRAMEWORK_NAME -destination="iOS" -archivePath $ARCHIVE_FILE_IOS -derivedDataPath $DERIVED_DIR -sdk iphoneos SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES | |
# Creating an archive file for iOS simulator | |
xcodebuild archive -workspace Frameworks.xcworkspace -scheme $FRAMEWORK_NAME -destination="iOS Simulator" -archivePath $ARCHIVE_FILE_IOS_SIMULATOR -derivedDataPath $DERIVED_DIR -sdk iphonesimulator SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES | |
# Create xcframework | |
xcodebuild -create-xcframework -framework $ARCHIVE_FILE_IOS/Products/Library/Frameworks/$FRAMEWORK_NAME.framework -framework $ARCHIVE_FILE_IOS_SIMULATOR/Products/Library/Frameworks/$FRAMEWORK_NAME.framework -output $XCFRAMEWORK_DIR/$FRAMEWORK_NAME.xcframework |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment