forked from becvert/PocketSocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-pocket-socket.sh
executable file
·73 lines (62 loc) · 2.11 KB
/
build-pocket-socket.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
#
# This script was inspired by http://blog.diogot.com/blog/2013/09/18/static-libs-with-support-to-ios-5-and-arm64/
#
# This script uses a temporary folder for intermediate build products.
#
# Minimum deployment target is 5.0 for 32 bit architectures and for 64 bit architectures it is 7.0.
#
if [ -z "$1" ]; then
echo
echo "usage: $0 <project.xcodeproj> [<target>]"
echo
echo "for example: $0 ~/Documents/MyStaticLibProject.xcodeproj"
echo
echo "will generate a fat library (i386, x86_64, armv7, armv7s and arm64) named libMyStaticLibProject.a in the current folder for the target MyStaticLibProject."
echo
exit
fi
if [ ! -d "$1" ]; then
echo
echo "Error: $1 does not exist"
echo
exit
fi
MY_PROJECT="$1"
MY_PROJECT_NAME=$(basename "$1")
if [ -z "$2" ]; then
MY_TARGET=${MY_PROJECT_NAME%.*}
else
MY_TARGET="$2"
fi
MY_BUILD_PATH=`mktemp -d -t "build"`
# iOS Simulator
xcodebuild archive \
-project 'PocketSocket.xcodeproj' \
-scheme "PocketSocket" \
-archivePath "${MY_BUILD_PATH}/iOSSimulator.xcarchive" \
-sdk iphonesimulator \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES OTHER_CFLAGS="-fembed-bitcode"
# iOS
xcodebuild archive \
-project 'PocketSocket.xcodeproj' \
-scheme "PocketSocket" \
-archivePath "${MY_BUILD_PATH}/iOS.xcarchive" \
-sdk iphoneos \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES OTHER_CFLAGS="-fembed-bitcode"
# Mac Catalyst
xcodebuild archive \
-project PocketSocket.xcodeproj \
-scheme PocketSocket \
-configuration 'Release' \
-destination 'generic/platform=macOS,variant=Mac Catalyst,name=Any Mac' \
-sdk iphoneos \
-archivePath "${MY_BUILD_PATH}/macCatalyst.xcarchive" \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES OTHER_CFLAGS="-fembed-bitcode"
# Create the XCFramework file
xcodebuild -create-xcframework \
-archive ${MY_BUILD_PATH}/iOS.xcarchive -library libPocketSocket.a \
-archive ${MY_BUILD_PATH}/iOSSimulator.xcarchive -library libPocketSocket.a \
-archive ${MY_BUILD_PATH}/macCatalyst.xcarchive -library libPocketSocket.a \
-output ~/Desktop/PocketSocket.xcframework
rm -rf "${MY_BUILD_PATH}"