Skip to content

Instantly share code, notes, and snippets.

@illescasDaniel
Created January 31, 2023 15:38
Show Gist options
  • Save illescasDaniel/27eb1e886062805d5d1a2cf1de50e4ce to your computer and use it in GitHub Desktop.
Save illescasDaniel/27eb1e886062805d5d1a2cf1de50e4ce to your computer and use it in GitHub Desktop.
Build XCFramework
#!/bin/sh
PROJECT_NAME=DemoFramework
# DO NOT MODIFY the code below
PROJECT_SCHEME_NAME="${PROJECT_NAME}"
FRAMEWORK_FILE_NAME="${PROJECT_NAME}.framework"
XCFRAMEWORK_OUTPUT_NAME="${PROJECT_NAME}.xcframework"
SIMULATOR_FRAMEWORK_ARCHIVE_OUTPUT_NAME="${PROJECT_NAME}-iphonesimulator.xcarchive"
DEVICE_FRAMEWORK_ARCHIVE_OUTPUT_NAME="${PROJECT_NAME}-iphoneos.xcarchive"
MAC_FRAMEWORK_ARCHIVE_OUTPUT_NAME="${PROJECT_NAME}-macosx.xcarchive"
# Folder structure
# - this script
# - bin folder
# - your project folder
# - your project xcodeproj folder
rm -rf ./bin/$XCFRAMEWORK_OUTPUT_NAME
rm -rf ./bin/$SIMULATOR_FRAMEWORK_ARCHIVE_OUTPUT_NAME
rm -rf ./bin/$DEVICE_FRAMEWORK_ARCHIVE_OUTPUT_NAME
rm -rf ./bin/$MAC_FRAMEWORK_ARCHIVE_OUTPUT_NAME
xcodebuild archive \
-scheme $PROJECT_SCHEME_NAME \
-archivePath ./bin/$SIMULATOR_FRAMEWORK_ARCHIVE_OUTPUT_NAME \
-sdk iphonesimulator \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
xcodebuild archive \
-scheme $PROJECT_SCHEME_NAME \
-archivePath ./bin/$DEVICE_FRAMEWORK_ARCHIVE_OUTPUT_NAME \
-sdk iphoneos \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
xcodebuild archive \
-scheme $PROJECT_SCHEME_NAME \
-archivePath ./bin/$MAC_FRAMEWORK_ARCHIVE_OUTPUT_NAME \
-sdk macosx \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
xcodebuild -create-xcframework \
-archive ./bin/$SIMULATOR_FRAMEWORK_ARCHIVE_OUTPUT_NAME -framework $FRAMEWORK_FILE_NAME \
-archive ./bin/$DEVICE_FRAMEWORK_ARCHIVE_OUTPUT_NAME -framework $FRAMEWORK_FILE_NAME \
-archive ./bin/$MAC_FRAMEWORK_ARCHIVE_OUTPUT_NAME -framework $FRAMEWORK_FILE_NAME \
-output ./bin/$XCFRAMEWORK_OUTPUT_NAME
rm -rf ./bin/$SIMULATOR_FRAMEWORK_ARCHIVE_OUTPUT_NAME
rm -rf ./bin/$DEVICE_FRAMEWORK_ARCHIVE_OUTPUT_NAME
rm -rf ./bin/$MAC_FRAMEWORK_ARCHIVE_OUTPUT_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment