Skip to content

Commit

Permalink
build,ios: build .xcframework and use it for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimecbernardo committed Aug 5, 2021
1 parent 359665c commit 7f64610
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
6 changes: 6 additions & 0 deletions tools/ios_framework_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ lipo -create "$TARGET_LIBRARY_PATH/arm64/libv8_libsampler.a" "$TARGET_LIBRARY_PA
lipo -create "$TARGET_LIBRARY_PATH/arm64/libv8_snapshot.a" "$TARGET_LIBRARY_PATH/x64/libv8_snapshot.a" -output "$TARGET_LIBRARY_PATH/libv8_snapshot.a"
lipo -create "$TARGET_LIBRARY_PATH/arm64/libzlib.a" "$TARGET_LIBRARY_PATH/x64/libzlib.a" -output "$TARGET_LIBRARY_PATH/libzlib.a"

rm -rf "$TARGET_LIBRARY_PATH/arm64/"
rm -rf "$TARGET_LIBRARY_PATH/x64/"

#Create a path to build the frameworks into
rm -rf out_ios
mkdir -p out_ios
Expand All @@ -110,6 +113,9 @@ xcodebuild build -project $NODELIB_PROJECT_PATH/NodeMobile.xcodeproj -target "No
cp -RL $FRAMEWORK_TARGET_DIR/Release-iphoneos $FRAMEWORK_TARGET_DIR/Release-universal
lipo -create $FRAMEWORK_TARGET_DIR/Release-iphoneos/NodeMobile.framework/NodeMobile $FRAMEWORK_TARGET_DIR/Release-iphonesimulator/NodeMobile.framework/NodeMobile -output $FRAMEWORK_TARGET_DIR/Release-universal/NodeMobile.framework/NodeMobile

#Create a .xcframework
xcodebuild -create-xcframework -framework $FRAMEWORK_TARGET_DIR/Release-iphoneos/NodeMobile.framework -framework $FRAMEWORK_TARGET_DIR/Release-iphonesimulator/NodeMobile.framework -output $FRAMEWORK_TARGET_DIR/NodeMobile.xcframework

echo "Frameworks built to $FRAMEWORK_TARGET_DIR"

cd "$ROOT"
32 changes: 23 additions & 9 deletions tools/mobile-test/ios/testnode/testnode.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 48;
objectVersion = 52;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -15,8 +15,8 @@
3308AA541FB2376800BEB534 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3308AA531FB2376800BEB534 /* main.m */; };
3308AA5B1FB241B900BEB534 /* NodeRunner.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3308AA5A1FB241B900BEB534 /* NodeRunner.mm */; };
331C21271FB9AEA800B04CA8 /* test in Resources */ = {isa = PBXBuildFile; fileRef = 331C21261FB9AEA800B04CA8 /* test */; };
335DC899204DC83200BF9697 /* NodeMobile.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 335DC898204DC83200BF9697 /* NodeMobile.framework */; };
335DC89A204DC83200BF9697 /* NodeMobile.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 335DC898204DC83200BF9697 /* NodeMobile.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
33AC9D9126BC3E21007AAC14 /* NodeMobile.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33AC9D9026BC3E21007AAC14 /* NodeMobile.xcframework */; };
33AC9D9226BC3E21007AAC14 /* NodeMobile.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 33AC9D9026BC3E21007AAC14 /* NodeMobile.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -26,7 +26,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
335DC89A204DC83200BF9697 /* NodeMobile.framework in Embed Frameworks */,
33AC9D9226BC3E21007AAC14 /* NodeMobile.xcframework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -47,15 +47,15 @@
3308AA5A1FB241B900BEB534 /* NodeRunner.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NodeRunner.mm; sourceTree = "<group>"; };
3308AA5C1FB241F200BEB534 /* NodeRunner.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = NodeRunner.hpp; sourceTree = "<group>"; };
331C21261FB9AEA800B04CA8 /* test */ = {isa = PBXFileReference; lastKnownFileType = folder; name = test; path = ../../../../test; sourceTree = "<group>"; };
335DC898204DC83200BF9697 /* NodeMobile.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NodeMobile.framework; path = "../../../../out_ios/Release-iphoneos/NodeMobile.framework"; sourceTree = "<group>"; };
33AC9D9026BC3E21007AAC14 /* NodeMobile.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = NodeMobile.xcframework; path = ../../../../out_ios/NodeMobile.xcframework; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
3308AA3E1FB2376800BEB534 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
335DC899204DC83200BF9697 /* NodeMobile.framework in Frameworks */,
33AC9D9126BC3E21007AAC14 /* NodeMobile.xcframework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -65,10 +65,10 @@
3308AA381FB2376800BEB534 = {
isa = PBXGroup;
children = (
335DC898204DC83200BF9697 /* NodeMobile.framework */,
331C21261FB9AEA800B04CA8 /* test */,
3308AA431FB2376800BEB534 /* testnode */,
3308AA421FB2376800BEB534 /* Products */,
33AC9D8F26BC3E21007AAC14 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -98,6 +98,14 @@
path = testnode;
sourceTree = "<group>";
};
33AC9D8F26BC3E21007AAC14 /* Frameworks */ = {
isa = PBXGroup;
children = (
33AC9D9026BC3E21007AAC14 /* NodeMobile.xcframework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -316,7 +324,10 @@
"$(PROJECT_DIR)/../../../../out_ios/Release-iphoneos/",
);
INFOPLIST_FILE = testnode/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
OTHER_LDFLAGS = "-Wl,-stack_size,0x200000";
PRODUCT_BUNDLE_IDENTIFIER = nodejsmobile.test;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -336,7 +347,10 @@
"$(PROJECT_DIR)/../../../../out_ios/Release-iphoneos/",
);
INFOPLIST_FILE = testnode/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
OTHER_LDFLAGS = "-Wl,-stack_size,0x200000";
PRODUCT_BUNDLE_IDENTIFIER = nodejsmobile.test;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down

0 comments on commit 7f64610

Please sign in to comment.