This repository was archived by the owner on Nov 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUniversalBuildScript.sh
More file actions
132 lines (94 loc) · 3.96 KB
/
UniversalBuildScript.sh
File metadata and controls
132 lines (94 loc) · 3.96 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/sh
#
# Copyright (C) 2018 High-Mobility GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http:#www.gnu.org/licenses/.
#
# Please inquire about commercial licensing options at
# licensing@high-mobility.com
#
# UniversalBuildScript.sh
#
# Created by Mikk Rätsep on 16/03/2018.
# Copyright © 2018 High-Mobility. All rights reserved.
######################
# Conf Some Vars
######################
if [ -z "${CONFIGURATION}" ]; then
CONFIGURATION="Release"
fi
if [ -z "${SRCROOT}" ]; then
SRCROOT="$( cd "$(dirname "$0")" ; pwd -P )/.."
fi
if [ -z "${BUILD_DIR}" ]; then
BUILD_DIR="${SRCROOT}/build"
fi
######################
# Options
######################
FRAMEWORK_NAME="$(find ${SRCROOT} -name '*.xcodeproj')"
FRAMEWORK_NAME=${FRAMEWORK_NAME##*/}
FRAMEWORK_NAME=${FRAMEWORK_NAME%.*}
PROJECT_PATH="${SRCROOT}/${FRAMEWORK_NAME}.xcodeproj"
SIMULATOR_PATH="${BUILD_DIR}/${CONFIGURATION}-simulator"
SIMULATOR_LIBRARY_PATH="${SIMULATOR_PATH}/${FRAMEWORK_NAME}.framework"
DEVICE_PATH="${BUILD_DIR}/${CONFIGURATION}-device"
DEVICE_LIBRARY_PATH="${DEVICE_PATH}/${FRAMEWORK_NAME}.framework"
ARCHIVE_PATH="${DEVICE_PATH}/${FRAMEWORK_NAME}.xcarchive"
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iosUniversal"
FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework"
######################
# Build Frameworks
######################
echo "Building for Simulator..."
xcodebuild -quiet -project ${PROJECT_PATH} -target ${FRAMEWORK_NAME} -sdk iphonesimulator -configuration ${CONFIGURATION} CONFIGURATION_BUILD_DIR=${SIMULATOR_PATH} OTHER_CFLAGS="-fembed-bitcode" ONLY_ACTIVE_ARCH=NO clean build
echo "Archiving for Device..."
xcodebuild -quiet -project ${PROJECT_PATH} -scheme ${FRAMEWORK_NAME} -sdk iphoneos -configuration ${CONFIGURATION} OTHER_CFLAGS="-fembed-bitcode" -archivePath ${ARCHIVE_PATH} clean archive
# Updates the device's library path
DEVICE_LIBRARY_PATH="${ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework"
######################
# Create directory for universal
######################
echo "Removing and making directories..."
rm -rf ${UNIVERSAL_LIBRARY_DIR}
mkdir ${UNIVERSAL_LIBRARY_DIR}
mkdir ${FRAMEWORK}
######################
# Copy files Framework
######################
echo "Copying frameworks..."
cp -r "${DEVICE_LIBRARY_PATH}/." "${FRAMEWORK}"
# And the AppStoreCompatible script
echo "Copying AppStoreCompatible script"
cp "${SRCROOT}/Scripts/AppStoreCompatible.sh" "${FRAMEWORK}"
######################
# Make an universal binary
######################
echo "Combining frameworks together..."
lipo "${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}" "${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}" -create -output "${FRAMEWORK}/${FRAMEWORK_NAME}"
# For Swift framework, Swiftmodule needs to be copied in the universal framework
if [ -d "${DEVICE_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" ]; then
cp -f -R "${DEVICE_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule/"
fi
if [ -d "${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" ]; then
cp -f -R "${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule/"
fi
######################
# Cleanup
######################
# Copy the Universal to the root dir
cp -f -R "${FRAMEWORK}" "${SRCROOT}"
# Removes the build/ folder from the source folder
echo "Removing build directory..."
rm -rfd "${SRCROOT}/build"