forked from DeloitteAU/ddmock-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frameworkMerge.sh
50 lines (40 loc) · 1.85 KB
/
frameworkMerge.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
# Merge Script
echo "Step 1"
# Set bash script to exit immediately if any commands fail.
set -e
echo "Step 2"
# Setup some constants for use later on.
FRAMEWORK_NAME="$1"
echo "Step 3"
# If remnants from a previous build exist, delete them.
if [ -d "build" ]; then
rm -rf "build"
fi
echo "Step 4"
# Build the framework for device and for simulator (using
# all needed architectures).
xcodebuild -target "${FRAMEWORK_NAME}" -configuration Release -arch arm64 -arch armv7 -arch armv7s only_active_arch=no defines_module=yes -sdk "iphoneos"
xcodebuild -target "${FRAMEWORK_NAME}" -configuration Release -arch x86_64 -arch i386 only_active_arch=no defines_module=yes -sdk "iphonesimulator"
echo "Step 5"
# Remove .framework file if exists in output from previous run.
if [ -d "output/DDMockiOS/${FRAMEWORK_NAME}.framework" ]; then
rm -rf "output/DDMockiOS/${FRAMEWORK_NAME}.framework"
fi
echo "Step 6"
# Copy the device version of framework to output.
cp -r "build/Release-iphoneos/${FRAMEWORK_NAME}.framework" "output/DDMockiOS/${FRAMEWORK_NAME}.framework"
echo "Step 7"
# Replace the framework executable within the framework with
# a new version created by merging the device and simulator
# frameworks' executables with lipo.
lipo -create -output "output/DDMockiOS/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "build/Release-iphoneos/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "build/Release-iphonesimulator/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}"
echo "Step 8"
# Copy the Swift module mappings for the simulator into the
# framework. The device mappings already exist from step 6.
cp -r "build/Release-iphonesimulator/${FRAMEWORK_NAME}.framework/Modules/${FRAMEWORK_NAME}.swiftmodule/" "output/DDMockiOS/${FRAMEWORK_NAME}.framework/Modules/${FRAMEWORK_NAME}.swiftmodule"
echo "Step 9"
# Delete the most recent build.
if [ -d "build" ]; then
rm -rf "build"
fi
echo "Done"