From 7f64610f0d774ff4225595c3d76aa0132b79753e Mon Sep 17 00:00:00 2001 From: Jaime Bernardo Date: Thu, 5 Aug 2021 17:54:30 +0200 Subject: [PATCH] build,ios: build .xcframework and use it for tests --- tools/ios_framework_prepare.sh | 6 ++++ .../testnode.xcodeproj/project.pbxproj | 32 +++++++++++++------ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/tools/ios_framework_prepare.sh b/tools/ios_framework_prepare.sh index a4076ec3427..bc84b58e407 100755 --- a/tools/ios_framework_prepare.sh +++ b/tools/ios_framework_prepare.sh @@ -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 @@ -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" diff --git a/tools/mobile-test/ios/testnode/testnode.xcodeproj/project.pbxproj b/tools/mobile-test/ios/testnode/testnode.xcodeproj/project.pbxproj index 7cbb01cb025..83b5e477661 100644 --- a/tools/mobile-test/ios/testnode/testnode.xcodeproj/project.pbxproj +++ b/tools/mobile-test/ios/testnode/testnode.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 48; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ @@ -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 */ @@ -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; @@ -47,7 +47,7 @@ 3308AA5A1FB241B900BEB534 /* NodeRunner.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NodeRunner.mm; sourceTree = ""; }; 3308AA5C1FB241F200BEB534 /* NodeRunner.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = NodeRunner.hpp; sourceTree = ""; }; 331C21261FB9AEA800B04CA8 /* test */ = {isa = PBXFileReference; lastKnownFileType = folder; name = test; path = ../../../../test; sourceTree = ""; }; - 335DC898204DC83200BF9697 /* NodeMobile.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NodeMobile.framework; path = "../../../../out_ios/Release-iphoneos/NodeMobile.framework"; sourceTree = ""; }; + 33AC9D9026BC3E21007AAC14 /* NodeMobile.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = NodeMobile.xcframework; path = ../../../../out_ios/NodeMobile.xcframework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -55,7 +55,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 335DC899204DC83200BF9697 /* NodeMobile.framework in Frameworks */, + 33AC9D9126BC3E21007AAC14 /* NodeMobile.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -65,10 +65,10 @@ 3308AA381FB2376800BEB534 = { isa = PBXGroup; children = ( - 335DC898204DC83200BF9697 /* NodeMobile.framework */, 331C21261FB9AEA800B04CA8 /* test */, 3308AA431FB2376800BEB534 /* testnode */, 3308AA421FB2376800BEB534 /* Products */, + 33AC9D8F26BC3E21007AAC14 /* Frameworks */, ); sourceTree = ""; }; @@ -98,6 +98,14 @@ path = testnode; sourceTree = ""; }; + 33AC9D8F26BC3E21007AAC14 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 33AC9D9026BC3E21007AAC14 /* NodeMobile.xcframework */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -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)"; @@ -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)";