Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding xcbuild script to produce XCFramework from commandline #304

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions xcbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/sh
set -e
set -o xtrace

# WORKSPACE=""
PROJECT="TrustKit.xcodeproj"
SCHEME="TrustKit"
FRAMEWORK_NAME="TrustKit"

BUILD_DIR=${PWD}/"_build"
IOS_ARCHIVE_PATH="${BUILD_DIR}/iOSDevice.xcarchive"
IOS_SIM_ARCHIVE_PATH="${BUILD_DIR}/iOSSimulator.xcarchive"
LIB=${PWD}/"lib"
PROJECT_DIR=${PWD}

rm -rf ${BUILD_DIR}
rm -rf "${LIB}/${FRAMEWORK_NAME}.xcframework"

build_sim() {
cd $PROJECT_DIR

xcodebuild archive \
-scheme ${SCHEME} \
-project ${PROJECT} \
-destination="iOS Simulator" \
-archivePath "${IOS_SIM_ARCHIVE_PATH}" \
-sdk iphonesimulator \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES \
SWIFT_SERIALIZE_DEBUGGING_OPTIONS=NO

cd ${PWD}
}

build_device() {
cd $PROJECT_DIR

xcodebuild archive \
-scheme ${SCHEME} \
-project ${PROJECT} \
-destination="iOS" \
-archivePath "${IOS_ARCHIVE_PATH}" \
-sdk iphoneos \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES \
SWIFT_SERIALIZE_DEBUGGING_OPTIONS=NO

cd ${PWD}
}

prep() {
cd ${PROJECT_DIR}
# rm -rf Pods
# pod install
cd ..
}

make_xcframework() {
xcodebuild -create-xcframework \
-framework ${IOS_SIM_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
-debug-symbols ${IOS_SIM_ARCHIVE_PATH}/dSYMs/${FRAMEWORK_NAME}.framework.dSYM \
-framework ${IOS_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
-debug-symbols ${IOS_ARCHIVE_PATH}/dSYMs/${FRAMEWORK_NAME}.framework.dSYM \
-output ${LIB}/${FRAMEWORK_NAME}.xcframework
}

# prep
build_sim
build_device
make_xcframework

# zip -r ${FRAMEWORK_NAME}.xcframework.zip ${FRAMEWORK_NAME}.xcframework

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run

rm -rf ${BUILD_DIR}
# rm -rf ${FRAMEWORK_NAME}.xcframework