Skip to content

Commit

Permalink
Switch to using XCFramework as required by Xcode 12/Swift 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrag committed Sep 18, 2020
1 parent 383445a commit d396372
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Icomoon.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@
8FFB56341C2D7BFB00D2BE62 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
Expand All @@ -295,6 +296,7 @@
8FFB56351C2D7BFB00D2BE62 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
Expand Down
7 changes: 7 additions & 0 deletions Icomoon.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Icomoon.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
8 changes: 8 additions & 0 deletions Icomoon.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
37 changes: 16 additions & 21 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ set -e
LIB_DIR="/usr/local/lib/icomoon-swift"
BUILD_DIR="/tmp/icomoon-build"
FRAMEWORK_NAME="Icomoon"
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/iphonesimulator/${FRAMEWORK_NAME}.framework"
DEVICE_LIBRARY_PATH="${BUILD_DIR}/iphoneos/${FRAMEWORK_NAME}.framework"
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/iphoneuniversal"
FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework"
RESULT_FRAMEWORK="$(pwd)/${FRAMEWORK_NAME}.framework"
SIMULATOR_ARCHIVE="$BUILD_DIR/$FRAMEWORK_NAME.framework-iphoneos.xcarchive"
DEVICE_ARCHIVE="$BUILD_DIR/$FRAMEWORK_NAME.framework-iphonesimulator.xcarchive"
CATALYST_ARCHIVE="$BUILD_DIR/$FRAMEWORK_NAME.framework-catalyst.xcarchive"
RESULT_FRAMEWORK="$(pwd)/${FRAMEWORK_NAME}.xcframework"


######################
Expand All @@ -30,8 +29,6 @@ rm -rf "${RESULT_FRAMEWORK}"
rm -rf "${BUILD_DIR}"

mkdir -p "${BUILD_DIR}"
mkdir "${UNIVERSAL_LIBRARY_DIR}"
mkdir "${FRAMEWORK}"

cp -r "${LIB_DIR}/." "${BUILD_DIR}"

Expand Down Expand Up @@ -60,30 +57,28 @@ cp "$TTF_FONT" "${FRAMEWORK_NAME}/font.ttf"
# Build Frameworks
######################

xcodebuild -sdk iphonesimulator -configuration "Release" clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/iphonesimulator ENABLE_BITCODE=YES
# Device slice.
xcodebuild archive -workspace "$FRAMEWORK_NAME.xcworkspace" -scheme "$FRAMEWORK_NAME" -configuration Release -destination 'generic/platform=iOS' -archivePath "$SIMULATOR_ARCHIVE" SKIP_INSTALL=NO

xcodebuild -sdk iphoneos -configuration "Release" clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/iphoneos ENABLE_BITCODE=YES
# Simulator slice.
xcodebuild archive -workspace "$FRAMEWORK_NAME.xcworkspace" -scheme "$FRAMEWORK_NAME" -configuration Release -destination 'generic/platform=iOS Simulator' -archivePath "$DEVICE_ARCHIVE" SKIP_INSTALL=NO

# Mac Catalyst slice.
xcodebuild archive -workspace "$FRAMEWORK_NAME.xcworkspace" -scheme "$FRAMEWORK_NAME" -configuration Release -destination 'platform=macOS,arch=x86_64,variant=Mac Catalyst' -archivePath "$CATALYST_ARCHIVE" SKIP_INSTALL=NO


######################
# Copy files Framework
#####################

cp -r "${DEVICE_LIBRARY_PATH}/." "${FRAMEWORK}"
cp -r "${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/." "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule"


######################
# Make fat universal binary
######################

lipo "${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}" "${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}" -create -output "${FRAMEWORK}/${FRAMEWORK_NAME}"
#cp -r "${DEVICE_LIBRARY_PATH}/." "${FRAMEWORK}"
#cp -r "${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/." "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule"


######################
# Copy the result to current dir and open in finder
# Make XCFramework
######################

cp -r "${FRAMEWORK}" "${RESULT_FRAMEWORK}"
xcodebuild -create-xcframework -framework "$SIMULATOR_ARCHIVE/Products/Library/Frameworks/$FRAMEWORK_NAME.framework" -framework "$DEVICE_ARCHIVE/Products/Library/Frameworks/$FRAMEWORK_NAME.framework" -framework "$CATALYST_ARCHIVE/Products/Library/Frameworks/$FRAMEWORK_NAME.framework" -output "$RESULT_FRAMEWORK"

open "${RESULT_FRAMEWORK}"
open .

0 comments on commit d396372

Please sign in to comment.