@@ -73,40 +73,57 @@ main() {
7373 RELEASE_DIR_BASE=${RELEASE_DIR_BASE:- " $SDK_DIR /Release" }
7474 LEANPLUM_PACKAGE_IDENTIFIER=${LEANPLUM_PACKAGE_IDENTIFIER:- " s" }
7575 CONFIGURATION=${CONFIGURATION:- " Release" }
76+
7677 BUILD_DIR=${BUILD_DIR:- " /tmp/AppleSDK-build" }
7778 BUILD_ROOT=${BUILD_ROOT:- " /tmp/AppleSDK-build" }
79+
7880 ARM64_DIR=${ARM64_DIR:- " /build-arm64" }
79- ARMV7S_DIR=${ARMV7S_DIR:- " /build-armv7s" }
8081 X8664_DIR=${X8664_DIR:- " /build-x86_64" }
81- ARMV7_DIR=${ARMV7_DIR:- " /build-armv7" }
82- X86_DIR=${X86_DIR:- " /build-x86" }
83- default=" ${BUILD_DIR}${ARMV7_DIR} /${CONFIGURATION} -iphoneos"
84- CURRENTCONFIG_ARMV7_DEVICE_DIR=${CURRENTCONFIG_ARMV7_DEVICE_DIR:- $default }
82+
8583 default=" ${BUILD_DIR}${ARM64_DIR} /${CONFIGURATION} -iphoneos"
8684 CURRENTCONFIG_ARM64_DEVICE_DIR=${CURRENTCONFIG_ARM64_DEVICE_DIR:- $default }
87- default=" ${BUILD_DIR}${ARMV7S_DIR} /${CONFIGURATION} -iphoneos"
88- CURRENTCONFIG_ARMV7S_DEVICE_DIR=${CURRENTCONFIG_ARMV7S_DEVICE_DIR:- $default }
89- default=" ${BUILD_DIR}${X86_DIR} /${CONFIGURATION} -iphonesimulator"
90- CURRENTCONFIG_X86_DEVICE_DIR=${CURRENTCONFIG_X86_DEVICE_DIR:- $default }
9185 default=" ${BUILD_DIR}${X8664_DIR} /${CONFIGURATION} -iphonesimulator"
9286 CURRENTCONFIG_X8664_SIMULATOR_DIR=${CURRENTCONFIG_X8664_SIMULATOR_DIR:- $default }
87+
88+ # Clean and build
9389 ACTION=" clean build"
9490
9591 DEVICE_SDK=" iphoneos"
9692 SIM_SDK=" iphonesimulator"
9793
94+ # Clear leftovers
9895 rm -rf " $RELEASE_DIR_BASE "
9996 mkdir -p " $RELEASE_DIR_BASE "
100- RELEASE_DIR=" $RELEASE_DIR_BASE "
101- mkdir -p " $RELEASE_DIR "
102-
97+
10398 # Build Dynamic Framework
99+ RELEASE_DIR=" $RELEASE_DIR_BASE /dynamic"
100+ mkdir -p " $RELEASE_DIR "
101+
104102 cd " $SDK_DIR /Example/"
105103 pod install
106104 cd " $SDK_DIR /Example/Pods"
107105 build_ios_dylib
108106
109- zip_ios_dylib
107+ # Build Static Framework
108+ RELEASE_DIR=" $RELEASE_DIR_BASE /static"
109+ mkdir -p " $RELEASE_DIR "
110+
111+ export LP_STATIC=1
112+ cd " $SDK_DIR /Example/"
113+ pod install
114+ cd " $SDK_DIR /Example/Pods"
115+ build_ios_static
116+
117+ # remove duplicate assets if any
118+ find " ${RELEASE_DIR_BASE} /" -name ' *.car' -not -path ' */Leanplum-iOS-SDK.bundle/*' -exec rm -rf {} +
119+ find " ${RELEASE_DIR_BASE} /" -name ' *.storyboardc' -not -path ' */Leanplum-iOS-SDK.bundle/*' -exec rm -rf {} +
120+ find " ${RELEASE_DIR_BASE} /" -name ' _CodeSignature' -exec rm -rf {} +
121+
122+ # zip all iOS frameworks
123+ zip_ios
124+
125+ # zip static iOS framework for Unreal Engine
126+ zip_unreal_engine
110127
111128 echo " ${GREEN} Done.${NORMAL} "
112129}
@@ -122,28 +139,14 @@ main() {
122139# None
123140# ######################################
124141build_ios_dylib () {
125- echo " Starting build for Leanplum-SDK (iOS)"
142+ echo " Starting build for Leanplum-SDK (iOS) dynamic framework "
126143
127- run " Building Leanplum-SDK-iOS dynamic (device/armv7) target ..." \
128- xcodebuild -configuration " ${CONFIGURATION} " -target " Leanplum-iOS-SDK" -sdk " ${DEVICE_SDK} " \
129- " $ACTION " ARCHS=' armv7' RUN_CLANG_STATIC_ANALYZER=NO BUILD_DIR=" ${BUILD_DIR}${ARMV7_DIR} " \
130- BUILD_ROOT=" ${BUILD_ROOT} " OTHER_CFLAGS=" -fembed-bitcode" \
131- GCC_PREPROCESSOR_DEFINITIONS=" PACKAGE_IDENTIFIER=${LEANPLUM_PACKAGE_IDENTIFIER} "
132- run " Building Leanplum-SDK-iOS dynamic (device/armv7s) target ..." \
133- xcodebuild -configuration " ${CONFIGURATION} " -target " Leanplum-iOS-SDK" -sdk " ${DEVICE_SDK} " \
134- " $ACTION " ARCHS=' armv7s' RUN_CLANG_STATIC_ANALYZER=NO BUILD_DIR=" ${BUILD_DIR}${ARMV7S_DIR} " \
135- BUILD_ROOT=" ${BUILD_ROOT} " OTHER_CFLAGS=" -fembed-bitcode" \
136- GCC_PREPROCESSOR_DEFINITIONS=" PACKAGE_IDENTIFIER=${LEANPLUM_PACKAGE_IDENTIFIER} "
137144 run " Building Leanplum-SDK-iOS dynamic (device/arm64) target ..." \
138145 xcodebuild -configuration " ${CONFIGURATION} " -target " Leanplum-iOS-SDK" -sdk " ${DEVICE_SDK} " \
139146 " $ACTION " ARCHS=' arm64' RUN_CLANG_STATIC_ANALYZER=NO BUILD_DIR=" ${BUILD_DIR}${ARM64_DIR} " \
140147 BUILD_ROOT=" ${BUILD_ROOT} " OTHER_CFLAGS=" -fembed-bitcode" \
141148 GCC_PREPROCESSOR_DEFINITIONS=" PACKAGE_IDENTIFIER=${LEANPLUM_PACKAGE_IDENTIFIER} "
142- run " Building Leanplum-SDK-iOS dynamic (simulator/i386) target ..." \
143- xcodebuild -configuration " ${CONFIGURATION} " -target " Leanplum-iOS-SDK" -sdk " ${SIM_SDK} " \
144- " $ACTION " ARCHS=' i386' VALID_ARCHS=' i386' RUN_CLANG_STATIC_ANALYZER=NO \
145- BUILD_DIR=" ${BUILD_DIR}${X86_DIR} " BUILD_ROOT=" ${BUILD_ROOT} " OTHER_CFLAGS=" -fembed-bitcode" \
146- GCC_PREPROCESSOR_DEFINITIONS=" PACKAGE_IDENTIFIER=${LEANPLUM_PACKAGE_IDENTIFIER} "
149+
147150 run " Building Leanplum-SDK-iOS dynamic (simulator/x86_64) target ..." \
148151 xcodebuild -configuration " ${CONFIGURATION} " -target " Leanplum-iOS-SDK" -sdk " ${SIM_SDK} " \
149152 " $ACTION " ARCHS=' x86_64' VALID_ARCHS=' x86_64' RUN_CLANG_STATIC_ANALYZER=NO \
@@ -152,21 +155,87 @@ build_ios_dylib() {
152155
153156 run " Combining builds to universal fat library ..." \
154157 lipo -create -output " ${RELEASE_DIR} /Leanplum" \
155- " ${CURRENTCONFIG_ARMV7_DEVICE_DIR} /Leanplum-iOS-SDK/Leanplum.framework/Leanplum" \
156- " ${CURRENTCONFIG_ARMV7S_DEVICE_DIR} /Leanplum-iOS-SDK/Leanplum.framework/Leanplum" \
157158 " ${CURRENTCONFIG_ARM64_DEVICE_DIR} /Leanplum-iOS-SDK/Leanplum.framework/Leanplum" \
158- " ${CURRENTCONFIG_X86_DEVICE_DIR} /Leanplum-iOS-SDK/Leanplum.framework/Leanplum" \
159159 " ${CURRENTCONFIG_X8664_SIMULATOR_DIR} /Leanplum-iOS-SDK/Leanplum.framework/Leanplum"
160160
161161 # Copy generated framework
162- cp -r " ${BUILD_DIR} $ARMV7_DIR /$CONFIGURATION -iphoneos/Leanplum-iOS-SDK/Leanplum.framework/" \
162+ cp -r " ${BUILD_DIR} $ARM64_DIR /$CONFIGURATION -iphoneos/Leanplum-iOS-SDK/Leanplum.framework/" \
163163 " ${RELEASE_DIR} /Leanplum.framework"
164164 rm -f " ${RELEASE_DIR} /Leanplum.framework/Leanplum"
165165 mv " ${RELEASE_DIR} /Leanplum" " ${RELEASE_DIR} /Leanplum.framework/"
166166
167- rm -rf " ${RELEASE_DIR} /Leanplum.framework/_CodeSignature"
167+ # create xcframework
168+ run " Combining builds into xcframework" \
169+ xcodebuild -create-xcframework \
170+ -framework " ${CURRENTCONFIG_ARM64_DEVICE_DIR} /Leanplum-iOS-SDK/Leanplum.framework" \
171+ -framework " ${CURRENTCONFIG_X8664_SIMULATOR_DIR} /Leanplum-iOS-SDK/Leanplum.framework" \
172+ -output " ${RELEASE_DIR} /Leanplum.xcframework"
173+
174+ printf " %s\n" " Successfully built Leanplum-SDK (iOS) Framework."
175+ }
176+
177+ # ######################################
178+ # Builds the iOS Target.
179+ # Globals:
180+ # None
181+ # Arguments:
182+ # None
183+ # Returns:
184+ # None
185+ # ######################################
186+ build_ios_static () {
187+ echo " Starting build for Leanplum-SDK (iOS) static framework"
188+
189+ run " Building Leanplum-SDK-iOS static (device/arm64) target ..." \
190+ xcodebuild -configuration " ${CONFIGURATION} " -target " Leanplum-iOS-SDK" -sdk " ${DEVICE_SDK} " \
191+ " $ACTION " ARCHS=' arm64' RUN_CLANG_STATIC_ANALYZER=NO BUILD_DIR=" ${BUILD_DIR}${ARM64_DIR} " \
192+ BUILD_ROOT=" ${BUILD_ROOT} " OTHER_CFLAGS=" -fembed-bitcode" \
193+ GCC_PREPROCESSOR_DEFINITIONS=" PACKAGE_IDENTIFIER=${LEANPLUM_PACKAGE_IDENTIFIER} "
194+
195+ run " Building Leanplum-SDK-iOS static (simulator/x86_64) target ..." \
196+ xcodebuild -configuration " ${CONFIGURATION} " -target " Leanplum-iOS-SDK" -sdk " ${SIM_SDK} " \
197+ " $ACTION " ARCHS=' x86_64' VALID_ARCHS=' x86_64' RUN_CLANG_STATIC_ANALYZER=NO \
198+ BUILD_DIR=" ${BUILD_DIR}${X8664_DIR} " BUILD_ROOT=" ${BUILD_ROOT} " OTHER_CFLAGS=" -fembed-bitcode" \
199+ GCC_PREPROCESSOR_DEFINITIONS=" PACKAGE_IDENTIFIER=${LEANPLUM_PACKAGE_IDENTIFIER} "
168200
169- printf " %s\n" " Successfully built Leanplum-SDK (iOS) Framework.\n"
201+ # create framework for each slice first
202+ mkdir -p " ${RELEASE_DIR} /arm64/Leanplum.framework"
203+ mkdir -p " ${RELEASE_DIR} /x86_64/Leanplum.framework"
204+
205+ cp -r " ${BUILD_DIR} $ARM64_DIR /$CONFIGURATION -iphoneos/Leanplum-iOS-SDK/Leanplum.framework/" \
206+ " ${RELEASE_DIR} /Leanplum.framework"
207+ cp -r " ${BUILD_DIR} $ARM64_DIR /$CONFIGURATION -iphoneos/Leanplum-iOS-SDK/Leanplum.framework/" \
208+ " ${RELEASE_DIR} /arm64/Leanplum.framework"
209+ cp -r " ${BUILD_DIR} $X8664_DIR /$CONFIGURATION -iphonesimulator/Leanplum-iOS-SDK/Leanplum.framework/" \
210+ " ${RELEASE_DIR} /x86_64/Leanplum.framework"
211+
212+ rm -f " ${RELEASE_DIR} /Leanplum.framework/Leanplum"
213+
214+ # combine and copy arm64 & x86_64 slice to universal framework
215+ run " Combining builds to universal fat library ..." \
216+ lipo -create -output " ${RELEASE_DIR} /Leanplum.framework/Leanplum" \
217+ " ${CURRENTCONFIG_ARM64_DEVICE_DIR} /Leanplum-iOS-SDK/libLeanplum-iOS-SDK.a" \
218+ " ${CURRENTCONFIG_X8664_SIMULATOR_DIR} /Leanplum-iOS-SDK/libLeanplum-iOS-SDK.a"
219+
220+ # copy the arm64 slice to framework
221+ lipo -create -output " ${RELEASE_DIR} /arm64/Leanplum.framework/Leanplum" \
222+ " ${CURRENTCONFIG_ARM64_DEVICE_DIR} /Leanplum-iOS-SDK/libLeanplum-iOS-SDK.a" \
223+
224+ # copy the x86_64 slice to framework
225+ lipo -create -output " ${RELEASE_DIR} /x86_64/Leanplum.framework/Leanplum" \
226+ " ${CURRENTCONFIG_X8664_SIMULATOR_DIR} /Leanplum-iOS-SDK/libLeanplum-iOS-SDK.a" \
227+
228+ # create xcframework from each framework slice
229+ run " Combining builds into xcframework" \
230+ xcodebuild -create-xcframework \
231+ -framework " ${RELEASE_DIR} /arm64/Leanplum.framework" \
232+ -framework " ${RELEASE_DIR} /x86_64/Leanplum.framework" \
233+ -output " ${RELEASE_DIR} /Leanplum.xcframework"
234+
235+ rm -rf " ${RELEASE_DIR} /arm64"
236+ rm -rf " ${RELEASE_DIR} /x86_64"
237+
238+ printf " %s\n" " Successfully built Leanplum-SDK (iOS) static Framework."
170239}
171240
172241# ######################################
@@ -178,10 +247,31 @@ build_ios_dylib() {
178247# Returns:
179248# None
180249# ######################################
181- zip_ios_dylib () {
182- cd " ${RELEASE_DIR} "
183- zip -r Leanplum.framework.zip Leanplum.framework
250+ zip_ios () {
251+ echo " zipping for iOS release"
252+ cd " ${RELEASE_DIR_BASE} "
253+ zip -r Leanplum.framework.zip *
184254 mv Leanplum.framework.zip " $SDK_DIR "
255+ cd -
256+ }
257+
258+ zip_unreal_engine () {
259+ echo " zipping for Unreal Engine release"
260+ pwd
261+ cd " ${RELEASE_DIR_BASE} /static"
262+
263+ mkdir -p Leanplum.embeddedframework
264+ cp -R Leanplum.framework Leanplum.embeddedframework
265+ zip -r Leanplum.embeddedframework.zip Leanplum.embeddedframework
266+ mv Leanplum.embeddedframework.zip " $SDK_DIR "
267+ rm -rf Leanplum.embeddedframework
268+
269+ mkdir -p Leanplum.embeddedxcframework
270+ cp -R Leanplum.xcframework Leanplum.embeddedxcframework
271+ zip -r Leanplum.embeddedxcframework.zip Leanplum.embeddedxcframework
272+ mv Leanplum.embeddedxcframework.zip " $SDK_DIR "
273+ rm -rf Leanplum.embeddedxcframework
274+ cd -
185275}
186276
187277main " $@ "
0 commit comments