forked from YAtechnologies/GoogleMaps-SP
-
Notifications
You must be signed in to change notification settings - Fork 6
/
make_xcframework.sh
91 lines (74 loc) · 2.54 KB
/
make_xcframework.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
#!/bin/bash
BUILD_DIRECTORY="Build"
function convert_frameworks_arm64_to_iphonesimulator() {
project_name=$1
framework_name=$2
xcrun vtool -arch arm64 \
-set-build-version 7 11.0 13.7 \
-replace \
-output "../Carthage/Build/iOS/$framework_name.framework/$framework_name" \
"../Carthage/Build/iOS/$framework_name.framework/$framework_name"
}
function archive_project_iphoneos() {
project_name=$1
framework_name=$2
# Archive iOS project.
xcodebuild archive\
-project "../$project_name.xcodeproj"\
-scheme "$framework_name"\
-configuration "Release"\
-destination "generic/platform=iOS"\
-archivePath "$framework_name.framework-iphoneos.xcarchive"\
SKIP_INSTALL=NO\
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
}
function archive_project_iphonesimulator() {
project_name=$1
framework_name=$2
# Archive iOS Simulator project.
xcodebuild archive\
-project "../$project_name.xcodeproj"\
-scheme "$framework_name"\
-configuration "Simulator Release"\
-destination "generic/platform=iOS Simulator"\
-archivePath "$framework_name.framework-iphonesimulator.xcarchive"\
SKIP_INSTALL=NO\
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
}
function create_xcframework() {
project_name=$1
framework_name=$2
# Create XCFramework from the archived project.
xcodebuild -create-xcframework\
-framework "$framework_name.framework-iphoneos.xcarchive/Products/Library/Frameworks/$framework_name.framework"\
-framework "$framework_name.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/$framework_name.framework"\
-output "$framework_name.xcframework"
# Compress the XCFramework.
zip -r -X "$framework_name.xcframework.zip" "$framework_name.xcframework/"
# Save the SHA-256 checksum
shasum -a 256 "$framework_name.xcframework.zip" >> checksum
}
function cleanup() {
# rm -r *.xcframework
rm -r *.xcarchive
}
# Install Google Maps SDK for iOS.
carthage update
rm -rf $BUILD_DIRECTORY
mkdir $BUILD_DIRECTORY
cd $BUILD_DIRECTORY
frameworks=("GoogleMaps" "GoogleMapsBase" "GoogleMapsCore" "GoogleMapsM4B" "GooglePlaces")
for framework in "${frameworks[@]}"; do
archive_project_iphoneos "GoogleMaps" "$framework"
done
for framework in "${frameworks[@]}"; do
convert_frameworks_arm64_to_iphonesimulator "GoogleMaps" "$framework"
done
for framework in "${frameworks[@]}"; do
archive_project_iphonesimulator "GoogleMaps" "$framework"
done
for framework in "${frameworks[@]}"; do
create_xcframework "GoogleMaps" "$framework"
done
cleanup
echo $'\n** XCFRAMEWORK CREATION FINISHED **\n'