-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd7c67a
commit 7cd4a01
Showing
9 changed files
with
191 additions
and
385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'json' | ||
|
||
package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) | ||
|
||
Pod::Spec.new do |s| | ||
s.name = package['name'] | ||
s.version = package['version'] | ||
s.summary = package['description'] | ||
s.license = package['license'] | ||
s.source = { :git => 'https://github.com/JaneaSystems/nodejs-mobile-react-native.git', :tag => 'v#{s.version}' } | ||
s.authors = package['author'] | ||
s.homepage = package['homepage'] | ||
s.platform = :ios, '9.0' | ||
s.source_files = 'ios/*.{h,m,mm,hpp,cpp}' | ||
s.compiler_flags = '-I$(PODS_TARGET_SRCROOT)/ios/libnode/include/node/' | ||
s.pod_target_xcconfig = { | ||
'CLANG_CXX_LANGUAGE_STANDARD' => 'gnu++0x', | ||
'ENABLE_BITCODE' => 'NO' | ||
} | ||
s.user_target_xcconfig = { 'ENABLE_BITCODE' => 'NO' } | ||
s.ios.vendored_frameworks = 'ios/NodeMobile.framework' | ||
s.static_framework = true | ||
s.dependency 'React' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module.exports = { | ||
dependency: { | ||
platforms: { | ||
android: { | ||
sourceDir: './android' | ||
}, | ||
ios: { | ||
project: './ios/RNNodeJsMobile.xcodeproj', | ||
scriptPhases: [ | ||
{ | ||
name: '[NODEJS MOBILE] Copy Node.js Project files', | ||
path: './scripts/ios-copy-nodejs-project.sh', | ||
execution_position: 'after_compile' | ||
}, { | ||
name: '[NODEJS MOBILE] Build Native Modules', | ||
path: './scripts/ios-build-native-modules.sh', | ||
execution_position: 'after_compile' | ||
}, { | ||
name: '[NODEJS MOBILE] Sign Native Modules', | ||
path: './scripts/ios-sign-native-modules.sh', | ||
execution_position: 'after_compile' | ||
}, { | ||
name: '[NODEJS MOBILE] Remove Simulator Strip', | ||
path: './scripts/ios-remove-framework-simulator-strips.sh', | ||
execution_position: 'after_compile' | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/sh | ||
set -e | ||
if [ -z "$NODEJS_MOBILE_BUILD_NATIVE_MODULES" ]; then | ||
# If build native modules preference is not set, look for it in the project's | ||
#nodejs-assets/BUILD_NATIVE_MODULES.txt file. | ||
NODEJS_ASSETS_DIR="$( cd "$PROJECT_DIR" && cd ../nodejs-assets/ && pwd )" | ||
PREFERENCE_FILE_PATH="$NODEJS_ASSETS_DIR/BUILD_NATIVE_MODULES.txt" | ||
if [ -f "$PREFERENCE_FILE_PATH" ]; then | ||
NODEJS_MOBILE_BUILD_NATIVE_MODULES="$(cat $PREFERENCE_FILE_PATH | xargs)" | ||
fi | ||
fi | ||
if [ -z "$NODEJS_MOBILE_BUILD_NATIVE_MODULES" ]; then | ||
# If build native modules preference is not set, try to find .gyp files | ||
#to turn it on. | ||
gypfiles=($(find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -type f -name "*.gyp")) | ||
if [ ${#gypfiles[@]} -gt 0 ]; then | ||
NODEJS_MOBILE_BUILD_NATIVE_MODULES=1 | ||
else | ||
NODEJS_MOBILE_BUILD_NATIVE_MODULES=0 | ||
fi | ||
fi | ||
if [ "1" != "$NODEJS_MOBILE_BUILD_NATIVE_MODULES" ]; then exit 0; fi | ||
# Delete object files that may already come from within the npm package. | ||
find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -name "*.o" -type f -delete | ||
find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -name "*.a" -type f -delete | ||
find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -name "*.node" -type f -delete | ||
# Delete bundle contents that may be there from previous builds. | ||
find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -path "*/*.node/*" -delete | ||
find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -name "*.node" -type d -delete | ||
find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -path "*/*.framework/*" -delete | ||
find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -name "*.framework" -type d -delete | ||
# Apply patches to the modules package.json | ||
if [ -d "$CODESIGNING_FOLDER_PATH"/nodejs-project/node_modules/ ]; then | ||
PATCH_SCRIPT_DIR="$( cd "$PROJECT_DIR" && cd ../node_modules/nodejs-mobile-react-native/scripts/ && pwd )" | ||
NODEJS_PROJECT_MODULES_DIR="$( cd "$CODESIGNING_FOLDER_PATH" && cd nodejs-project/node_modules/ && pwd )" | ||
node "$PATCH_SCRIPT_DIR"/patch-package.js $NODEJS_PROJECT_MODULES_DIR | ||
fi | ||
# Get the nodejs-mobile-gyp location | ||
if [ -d "$PROJECT_DIR/../node_modules/nodejs-mobile-gyp/" ]; then | ||
NODEJS_MOBILE_GYP_DIR="$( cd "$PROJECT_DIR" && cd ../node_modules/nodejs-mobile-gyp/ && pwd )" | ||
else | ||
NODEJS_MOBILE_GYP_DIR="$( cd "$PROJECT_DIR" && cd ../node_modules/nodejs-mobile-react-native/node_modules/nodejs-mobile-gyp/ && pwd )" | ||
fi | ||
NODEJS_MOBILE_GYP_BIN_FILE="$NODEJS_MOBILE_GYP_DIR"/bin/node-gyp.js | ||
# Rebuild modules with right environment | ||
NODEJS_HEADERS_DIR="$( cd "$PROJECT_DIR" && cd ../node_modules/nodejs-mobile-react-native/ios/libnode/ && pwd )" | ||
pushd $CODESIGNING_FOLDER_PATH/nodejs-project/ | ||
if [ "$PLATFORM_NAME" == "iphoneos" ] | ||
then | ||
GYP_DEFINES="OS=ios" npm_config_nodedir="$NODEJS_HEADERS_DIR" npm_config_node_gyp="$NODEJS_MOBILE_GYP_BIN_FILE" npm_config_platform="ios" npm_config_format="make-ios" npm_config_node_engine="chakracore" npm_config_arch="arm64" npm --verbose rebuild --build-from-source | ||
else | ||
GYP_DEFINES="OS=ios" npm_config_nodedir="$NODEJS_HEADERS_DIR" npm_config_node_gyp="$NODEJS_MOBILE_GYP_BIN_FILE" npm_config_platform="ios" npm_config_format="make-ios" npm_config_node_engine="chakracore" npm_config_arch="x64" npm --verbose rebuild --build-from-source | ||
fi | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
set -e | ||
NODEJS_ASSETS_DIR="$( cd "$PROJECT_DIR" && cd ../nodejs-assets/ && pwd )" | ||
NODEJS_BUILT_IN_MODULES_DIR="$( cd "$PROJECT_DIR" && cd ../node_modules/nodejs-mobile-react-native/install/resources/nodejs-modules/ && pwd )" | ||
if [ -d "$CODESIGNING_FOLDER_PATH/nodejs-project/" ] | ||
then | ||
rm -rf "$CODESIGNING_FOLDER_PATH/nodejs-project/" | ||
fi | ||
if [ -d "$CODESIGNING_FOLDER_PATH/builtin_modules/" ] | ||
then | ||
rm -rf "$CODESIGNING_FOLDER_PATH/builtin_modules/" | ||
fi | ||
rsync -av --delete "$NODEJS_ASSETS_DIR/nodejs-project" "$CODESIGNING_FOLDER_PATH" | ||
rsync -av --delete "$NODEJS_BUILT_IN_MODULES_DIR/builtin_modules" "$CODESIGNING_FOLDER_PATH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
set -e | ||
if [ -z "$NODEJS_MOBILE_BUILD_NATIVE_MODULES" ]; then | ||
# If build native modules preference is not set, look for it in the project's | ||
#nodejs-assets/BUILD_NATIVE_MODULES.txt file. | ||
NODEJS_ASSETS_DIR="$( cd "$PROJECT_DIR" && cd ../nodejs-assets/ && pwd )" | ||
PREFERENCE_FILE_PATH="$NODEJS_ASSETS_DIR/BUILD_NATIVE_MODULES.txt" | ||
if [ -f "$PREFERENCE_FILE_PATH" ]; then | ||
NODEJS_MOBILE_BUILD_NATIVE_MODULES="$(cat $PREFERENCE_FILE_PATH | xargs)" | ||
fi | ||
fi | ||
if [ -z "$NODEJS_MOBILE_BUILD_NATIVE_MODULES" ]; then | ||
# If build native modules preference is not set, try to find .gyp files | ||
#to turn it on. | ||
gypfiles=($(find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -type f -name "*.gyp")) | ||
if [ ${#gypfiles[@]} -gt 0 ]; then | ||
NODEJS_MOBILE_BUILD_NATIVE_MODULES=1 | ||
else | ||
NODEJS_MOBILE_BUILD_NATIVE_MODULES=0 | ||
fi | ||
fi | ||
if [ "1" != "$NODEJS_MOBILE_BUILD_NATIVE_MODULES" ]; then exit 0; fi | ||
# Delete object files | ||
find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -name "*.o" -type f -delete | ||
find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -name "*.a" -type f -delete | ||
# Create Info.plist for each framework built and loader override. | ||
PATCH_SCRIPT_DIR="$( cd "$PROJECT_DIR" && cd ../node_modules/nodejs-mobile-react-native/scripts/ && pwd )" | ||
NODEJS_PROJECT_DIR="$( cd "$CODESIGNING_FOLDER_PATH" && cd nodejs-project/ && pwd )" | ||
node "$PATCH_SCRIPT_DIR"/ios-create-plists-and-dlopen-override.js $NODEJS_PROJECT_DIR | ||
# Embed every resulting .framework in the application and delete them afterwards. | ||
embed_framework() | ||
{ | ||
FRAMEWORK_NAME="$(basename "$1")" | ||
cp -r "$1" "$TARGET_BUILD_DIR/$FRAMEWORKS_FOLDER_PATH/" | ||
/usr/bin/codesign --force --sign $EXPANDED_CODE_SIGN_IDENTITY --preserve-metadata=identifier,entitlements,flags --timestamp=none "$TARGET_BUILD_DIR/$FRAMEWORKS_FOLDER_PATH/$FRAMEWORK_NAME" | ||
} | ||
find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -name "*.framework" -type d | while read frmwrk_path; do embed_framework "$frmwrk_path"; done | ||
|
||
#Delete gyp temporary .deps dependency folders from the project structure. | ||
find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -path "*/.deps/*" -delete | ||
find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -name ".deps" -type d -delete | ||
|
||
#Delete frameworks from their build paths | ||
find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -path "*/*.framework/*" -delete | ||
find "$CODESIGNING_FOLDER_PATH/nodejs-project/" -name "*.framework" -type d -delete |
Oops, something went wrong.