Skip to content

Commit

Permalink
ios: building for device removes the x86_64 arch
Browse files Browse the repository at this point in the history
Removes the x86_64 strip from NodeMobile.framework when building
for devices automatically. This is a condition necessary for App
Store submission and archiving doesn't do it automatically.
  • Loading branch information
jaimecbernardo committed Jun 20, 2018
1 parent 8b7e854 commit 3d430ec
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
26 changes: 26 additions & 0 deletions install/hooks/ios/after-plugin-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,32 @@ find "$CODESIGNING_FOLDER_PATH/www/nodejs-project/" -name "*.framework" -type d
);
}

//Adds a build phase to remove the x64 strips from the NodeMobile framework. Needed for correct App Store submission.
var removeSimulatorArchsBuildPhaseName = 'Remove NodeJS Mobile Framework Simulator Strips';
var removeSimulatorArchsBuildPhaseScript = `
set -e
FRAMEWORK_BINARY_PATH="$TARGET_BUILD_DIR/$FRAMEWORKS_FOLDER_PATH/NodeMobile.framework/NodeMobile"
FRAMEWORK_STRIPPED_PATH="$FRAMEWORK_BINARY_PATH-strip"
if [ "$PLATFORM_NAME" != "iphonesimulator" ]; then
if $(lipo "$FRAMEWORK_BINARY_PATH" -verify_arch "x86_64") ; then
lipo -output "$FRAMEWORK_STRIPPED_PATH" -remove "x86_64" "$FRAMEWORK_BINARY_PATH"
rm "$FRAMEWORK_BINARY_PATH"
mv "$FRAMEWORK_STRIPPED_PATH" "$FRAMEWORK_BINARY_PATH"
echo "Removed simulator strip from NodeMobile.framework"
fi
fi
`
var removeSimulatorArchsBuildPhase = xcodeProject.buildPhaseObject('PBXShellScriptBuildPhase', removeSimulatorArchsBuildPhaseName, firstTargetUUID);
if (!removeSimulatorArchsBuildPhase) {
xcodeProject.addBuildPhase(
[],
'PBXShellScriptBuildPhase',
removeSimulatorArchsBuildPhaseName,
firstTargetUUID,
{ shellPath: '/bin/sh', shellScript: removeSimulatorArchsBuildPhaseScript }
);
}

// Write the changes into the Xcode project.
fs.writeFileSync(pbxprojPath, xcodeProject.writeSync());

Expand Down
7 changes: 7 additions & 0 deletions install/hooks/ios/before-plugin-uninstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ module.exports = function(context) {
xcodeProject.myRemovePbxScriptBuildPhase(signNativeModulesBuildPhaseName, firstTargetUUID);
}

// Removes the build phase to strip the simulator strips.
var removeSimulatorArchsBuildPhaseName = 'Remove NodeJS Mobile Framework Simulator Strips';
var removeSimulatorArchsBuildPhase = xcodeProject.buildPhaseObject('PBXShellScriptBuildPhase', removeSimulatorArchsBuildPhaseName, firstTargetUUID);
if (removeSimulatorArchsBuildPhase) {
xcodeProject.myRemovePbxScriptBuildPhase(removeSimulatorArchsBuildPhaseName, firstTargetUUID);
}

// Write the changes into the Xcode project.
fs.writeFileSync(pbxprojPath, xcodeProject.writeSync());

Expand Down

0 comments on commit 3d430ec

Please sign in to comment.