-
Notifications
You must be signed in to change notification settings - Fork 16
/
buildXCFrameworks.sh
executable file
·94 lines (71 loc) · 4.49 KB
/
buildXCFrameworks.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
assert_success() {
local status=$?
local process_name="$1"
if [ "$status" -ne 0 ]; then
echo "$process_name failed. Check ./build/build.log for more info."
exit status
fi
}
archive() {
local project="$1"
local scheme="$2"
local destination="$3"
local archivePath="$4"
printf "Archiving $project / $destination..."
xcodebuild archive \
-quiet \
-project "$project" \
-scheme "$scheme" \
-destination "$destination" \
-archivePath "$archivePath" \
-parallelizeTargets \
-jobs 8 \
OTHER_SWIFT_FLAGS="-no-verify-emitted-module-interface" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES > ./build/build.log 2>&1
assert_success "Archiving $destination"
echo "✅"
}
########### Creates the binaries which are distributed standalone
echo "Generating Standalone XCFrameworks"
archive "_Pods.xcodeproj" "ConsentViewController-iOS" "generic/platform=iOS" "./build/ConsentViewController-iOS.framework-iOS.xcarchive"
archive "_Pods.xcodeproj" "ConsentViewController-iOS" "generic/platform=iOS Simulator" "./build/ConsentViewController-iOS.framework-iphonesimulator.xcarchive"
archive "_Pods.xcodeproj" "ConsentViewController-tvOS" "generic/platform=tvOS Simulator" "./build/ConsentViewController-tvOS.framework-tvossimulator.xcarchive"
archive "_Pods.xcodeproj" "ConsentViewController-tvOS" "generic/platform=tvOS" "./build/ConsentViewController-tvOS.framework.xcarchive"
rm -r ./XCFramework/ConsentViewController.xcframework &> ./build/build.log 2>&1
rm -r ./XCFramework/ConsentViewController.xcframework.zip &> ./build/build.log 2>&1
echo "Archiving succeeded."
printf "Creating XCFrameworks"
xcodebuild -create-xcframework \
-framework './build/ConsentViewController-iOS.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/ConsentViewController.framework' \
-framework './build/ConsentViewController-iOS.framework-iOS.xcarchive/Products/Library/Frameworks/ConsentViewController.framework' \
-framework './build/ConsentViewController-tvOS.framework-tvossimulator.xcarchive/Products/Library/Frameworks/ConsentViewController.framework' \
-framework './build/ConsentViewController-tvOS.framework-tvOS.xcarchive/Products/Library/Frameworks/ConsentViewController.framework' \
-output './XCFramework/ConsentViewController.xcframework' &> ./build/build.log 2>&1
echo "✅"
printf "Zipping XCFramework"
zip -r ./XCFramework/ConsentViewController.xcframework.zip ./XCFramework/ConsentViewController.xcframework &> ./build/build.log 2>&1
echo "✅"
echo "XCFrameworks created on: ./XCFramework/ConsentViewController.xcframework.zip"
# ########### Creates the binaries which are distributed via SPM.
echo "Generating XCFrameworks for SPM"
archive "ConsentViewController.xcodeproj" "SPMConsentViewController-iOS" "generic/platform=iOS" "./build/SPM/ConsentViewController-iOS"
archive "ConsentViewController.xcodeproj" "SPMConsentViewController-iOS" "generic/platform=iOS Simulator" "./build/SPM/ConsentViewController-iOS-simulator"
archive "ConsentViewController.xcodeproj" "SPMConsentViewController-tvOS" "generic/platform=tvOS" "./build/SPM/ConsentViewController-tvOS"
archive "ConsentViewController.xcodeproj" "SPMConsentViewController-tvOS" "generic/platform=tvOS Simulator" "./build/SPM/ConsentViewController-tvOS-simulator"
echo "Archiving succeeded."
printf "Creating XCFrameworks"
rm -r ./XCFramework/SPM/ConsentViewController.xcframework &> ./build/build.log 2>&1
rm -r ./XCFramework/SPM/ConsentViewController.xcframework.zip &> ./build/build.log 2>&1
xcodebuild -create-xcframework \
-framework './build/SPM/ConsentViewController-iOS.xcarchive/Products/Library/Frameworks/ConsentViewController.framework' \
-framework './build/SPM/ConsentViewController-iOS-simulator.xcarchive/Products/Library/Frameworks/ConsentViewController.framework' \
-framework './build/SPM/ConsentViewController-tvOS.xcarchive/Products/Library/Frameworks/ConsentViewController.framework' \
-framework './build/SPM/ConsentViewController-tvOS-simulator.xcarchive/Products/Library/Frameworks/ConsentViewController.framework' \
-output './XCFramework/SPM/ConsentViewController.xcframework' &> ./build/build.log 2>&1
echo "✅"
printf "Zipping XCFramework"
zip -r ./XCFramework/SPM/ConsentViewController.xcframework.zip ./XCFramework/SPM/ConsentViewController.xcframework &> ./build/build.log 2>&1
echo "✅"
echo "SPM XCFrameworks created on: ./XCFramework/SPM/ConsentViewController.xcframework.zip"