Skip to content

Commit 76b585d

Browse files
committed
Add framework thinner for iOS Apple store validation
1 parent df7e12d commit 76b585d

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# (An edited version of http://ikennd.ac/blog/2015/02/stripping-unwanted-architectures-from-dynamic-libraries-in-xcode/)
2+
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
3+
4+
# This script loops through the frameworks embedded in the application and
5+
# removes unused architectures.
6+
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
7+
do
8+
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
9+
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
10+
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
11+
12+
EXTRACTED_ARCHS=()
13+
# We check the output of "lipo -info" cause not all the frameworks are Universal (Ex: some frameworks installed via Pods)
14+
if [[ $(lipo -info "$FRAMEWORK_EXECUTABLE_PATH") != Non-fat* ]] ;
15+
then
16+
for ARCH in $ARCHS
17+
do
18+
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
19+
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
20+
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
21+
done
22+
23+
echo "Merging extracted architectures: ${ARCHS}"
24+
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
25+
rm "${EXTRACTED_ARCHS[@]}"
26+
27+
echo "Replacing original executable with thinned version"
28+
rm "$FRAMEWORK_EXECUTABLE_PATH"
29+
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
30+
fi
31+
done

kivy_ios/tools/templates/{{ cookiecutter.project_name }}-ios/{{ cookiecutter.project_name }}.xcodeproj/project.pbxproj

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@
2727
59994E3B148E85C800863906 /* YourApp in Resources */ = {isa = PBXBuildFile; fileRef = 59994E3A148E85C800863906 /* YourApp */; };
2828
/* End PBXBuildFile section */
2929

30+
31+
/* Begin PBXCopyFilesBuildPhase section */
32+
EF5745029C423687AC1203A1 /* Embed Frameworks */ = {
33+
isa = PBXCopyFilesBuildPhase;
34+
buildActionMask = 2147483647;
35+
dstPath = "";
36+
dstSubfolderSpec = 10;
37+
files = (
38+
);
39+
name = "Embed Frameworks";
40+
runOnlyForDeploymentPostprocessing = 0;
41+
};
42+
/* End PBXCopyFilesBuildPhase section */
43+
3044
/* Begin PBXFileReference section */
3145
01532DA9137C099F0076F6BF /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon.png; sourceTree = "<group>"; };
3246
1D6058910D05DD3D006BFB54 /* {{ cookiecutter.project_name }}.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = {{ cookiecutter.project_name }}.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -48,6 +62,7 @@
4862
59738AD91A8E62D6001B2C0C /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "[email protected]"; path = "LaunchImages/[email protected]"; sourceTree = "<group>"; };
4963
59738ADA1A8E62D6001B2C0C /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "[email protected]"; path = "LaunchImages/[email protected]"; sourceTree = "<group>"; };
5064
59994E3A148E85C800863906 /* YourApp */ = {isa = PBXFileReference; lastKnownFileType = folder; path = YourApp; sourceTree = "<group>"; };
65+
ACAA5ADB24791C6100C86143 /* frameworks_thinner.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = frameworks_thinner.sh; sourceTree = SOURCE_ROOT; };
5166
8D1107310486CEB800E47090 /* {{ cookiecutter.project_name }}-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "{{ cookiecutter.project_name }}-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
5267
/* End PBXFileReference section */
5368

@@ -82,6 +97,7 @@
8297
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
8398
isa = PBXGroup;
8499
children = (
100+
ACAA5ADA24791C3C00C86143 /* Scripts */,
85101
080E96DDFE201D6D7F000001 /* Classes */,
86102
29B97315FDCFA39411CA2CEA /* Sources */,
87103
29B97317FDCFA39411CA2CEA /* Resources */,
@@ -130,6 +146,14 @@
130146
name = Frameworks;
131147
sourceTree = "<group>";
132148
};
149+
ACAA5ADA24791C3C00C86143 /* Scripts */ = {
150+
isa = PBXGroup;
151+
children = (
152+
ACAA5ADB24791C6100C86143 /* frameworks_thinner.sh */,
153+
);
154+
path = Scripts;
155+
sourceTree = "<group>";
156+
};
133157
/* End PBXGroup section */
134158

135159
/* Begin PBXNativeTarget section */
@@ -143,6 +167,8 @@
143167
1D60588D0D05DD3D006BFB54 /* Resources */,
144168
1D60588E0D05DD3D006BFB54 /* Sources */,
145169
1D60588F0D05DD3D006BFB54 /* Frameworks */,
170+
EF5745029C423687AC1203A1 /* Embed Frameworks */,
171+
ACAA5AD924791BF300C86143 /* ShellScript */,
146172
);
147173
buildRules = (
148174
);
@@ -254,6 +280,26 @@
254280
};
255281
/* End PBXShellScriptBuildPhase section */
256282

283+
/* Begin PBXShellScriptBuildPhase section */
284+
ACAA5AD924791BF300C86143 /* ShellScript */ = {
285+
isa = PBXShellScriptBuildPhase;
286+
buildActionMask = 2147483647;
287+
files = (
288+
);
289+
inputFileListPaths = (
290+
);
291+
inputPaths = (
292+
);
293+
outputFileListPaths = (
294+
);
295+
outputPaths = (
296+
);
297+
runOnlyForDeploymentPostprocessing = 0;
298+
shellPath = /bin/sh;
299+
shellScript = "\"$PROJECT_DIR\"/frameworks_thinner.sh\n";
300+
};
301+
/* End PBXShellScriptBuildPhase section */
302+
257303
/* Begin PBXSourcesBuildPhase section */
258304
1D60588E0D05DD3D006BFB54 /* Sources */ = {
259305
isa = PBXSourcesBuildPhase;

0 commit comments

Comments
 (0)