forked from schickling/Icomoon.swift
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·89 lines (57 loc) · 2.35 KB
/
run.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
#! /bin/bash
# This script is based on Jacob Van Order's answer on apple dev forums https://devforums.apple.com/message/971277
# See also http://spin.atomicobject.com/2011/12/13/building-a-universal-framework-for-ios/ for the start
# To get this to work with a Xcode 6 Cocoa Touch Framework, create Framework
# Then create a new Aggregate Target. Throw this script into a Build Script Phrase on the Aggregate
set -e
######################
# Options
######################
LIB_DIR="/usr/local/lib/icomoon-swift"
BUILD_DIR="/tmp/icomoon-build"
FRAMEWORK_NAME="Icomoon"
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/iphonesimulator/${FRAMEWORK_NAME}.framework"
DEVICE_LIBRARY_PATH="${BUILD_DIR}/iphoneos/${FRAMEWORK_NAME}.framework"
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/iphoneuniversal"
FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework"
RESULT_FRAMEWORK="$(pwd)/${FRAMEWORK_NAME}.framework"
######################
# Prepare
######################
rm -rf "${RESULT_FRAMEWORK}"
rm -rf "${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"
mkdir "${UNIVERSAL_LIBRARY_DIR}"
mkdir "${FRAMEWORK}"
cp -r "${LIB_DIR}/." "${BUILD_DIR}"
######################
# Unpack font archive
######################
unzip "$1" -d "${BUILD_DIR}"
######################
# Parse svg
######################
cd "${BUILD_DIR}"
SVG_FONT=$(ls ./fonts/*.svg)
TTF_FONT=$(ls ./fonts/*.ttf)
python parse.py "$SVG_FONT" > "${FRAMEWORK_NAME}/Font.swift"
cp "$TTF_FONT" "${FRAMEWORK_NAME}/font.ttf"
######################
# Build Frameworks
######################
xcodebuild -sdk iphonesimulator -configuration "Release" clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/iphonesimulator
xcodebuild -sdk iphoneos -configuration "Release" clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/iphoneos
######################
# Copy files Framework
######################
cp -r "${DEVICE_LIBRARY_PATH}/." "${FRAMEWORK}"
cp -r "${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/." "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule"
######################
# Make fat universal binary
######################
lipo "${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}" "${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}" -create -output "${FRAMEWORK}/${FRAMEWORK_NAME}"
######################
# Copy the result to current dir and open in finder
######################
cp -r "${FRAMEWORK}" "${RESULT_FRAMEWORK}"
open "${RESULT_FRAMEWORK}"