Skip to content

Commit 7f64610

Browse files
build,ios: build .xcframework and use it for tests
1 parent 359665c commit 7f64610

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

tools/ios_framework_prepare.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ lipo -create "$TARGET_LIBRARY_PATH/arm64/libv8_libsampler.a" "$TARGET_LIBRARY_PA
9696
lipo -create "$TARGET_LIBRARY_PATH/arm64/libv8_snapshot.a" "$TARGET_LIBRARY_PATH/x64/libv8_snapshot.a" -output "$TARGET_LIBRARY_PATH/libv8_snapshot.a"
9797
lipo -create "$TARGET_LIBRARY_PATH/arm64/libzlib.a" "$TARGET_LIBRARY_PATH/x64/libzlib.a" -output "$TARGET_LIBRARY_PATH/libzlib.a"
9898

99+
rm -rf "$TARGET_LIBRARY_PATH/arm64/"
100+
rm -rf "$TARGET_LIBRARY_PATH/x64/"
101+
99102
#Create a path to build the frameworks into
100103
rm -rf out_ios
101104
mkdir -p out_ios
@@ -110,6 +113,9 @@ xcodebuild build -project $NODELIB_PROJECT_PATH/NodeMobile.xcodeproj -target "No
110113
cp -RL $FRAMEWORK_TARGET_DIR/Release-iphoneos $FRAMEWORK_TARGET_DIR/Release-universal
111114
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
112115

116+
#Create a .xcframework
117+
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
118+
113119
echo "Frameworks built to $FRAMEWORK_TARGET_DIR"
114120

115121
cd "$ROOT"

tools/mobile-test/ios/testnode/testnode.xcodeproj/project.pbxproj

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 48;
6+
objectVersion = 52;
77
objects = {
88

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

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

5353
/* Begin PBXFrameworksBuildPhase section */
5454
3308AA3E1FB2376800BEB534 /* Frameworks */ = {
5555
isa = PBXFrameworksBuildPhase;
5656
buildActionMask = 2147483647;
5757
files = (
58-
335DC899204DC83200BF9697 /* NodeMobile.framework in Frameworks */,
58+
33AC9D9126BC3E21007AAC14 /* NodeMobile.xcframework in Frameworks */,
5959
);
6060
runOnlyForDeploymentPostprocessing = 0;
6161
};
@@ -65,10 +65,10 @@
6565
3308AA381FB2376800BEB534 = {
6666
isa = PBXGroup;
6767
children = (
68-
335DC898204DC83200BF9697 /* NodeMobile.framework */,
6968
331C21261FB9AEA800B04CA8 /* test */,
7069
3308AA431FB2376800BEB534 /* testnode */,
7170
3308AA421FB2376800BEB534 /* Products */,
71+
33AC9D8F26BC3E21007AAC14 /* Frameworks */,
7272
);
7373
sourceTree = "<group>";
7474
};
@@ -98,6 +98,14 @@
9898
path = testnode;
9999
sourceTree = "<group>";
100100
};
101+
33AC9D8F26BC3E21007AAC14 /* Frameworks */ = {
102+
isa = PBXGroup;
103+
children = (
104+
33AC9D9026BC3E21007AAC14 /* NodeMobile.xcframework */,
105+
);
106+
name = Frameworks;
107+
sourceTree = "<group>";
108+
};
101109
/* End PBXGroup section */
102110

103111
/* Begin PBXNativeTarget section */
@@ -316,7 +324,10 @@
316324
"$(PROJECT_DIR)/../../../../out_ios/Release-iphoneos/",
317325
);
318326
INFOPLIST_FILE = testnode/Info.plist;
319-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
327+
LD_RUNPATH_SEARCH_PATHS = (
328+
"$(inherited)",
329+
"@executable_path/Frameworks",
330+
);
320331
OTHER_LDFLAGS = "-Wl,-stack_size,0x200000";
321332
PRODUCT_BUNDLE_IDENTIFIER = nodejsmobile.test;
322333
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -336,7 +347,10 @@
336347
"$(PROJECT_DIR)/../../../../out_ios/Release-iphoneos/",
337348
);
338349
INFOPLIST_FILE = testnode/Info.plist;
339-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
350+
LD_RUNPATH_SEARCH_PATHS = (
351+
"$(inherited)",
352+
"@executable_path/Frameworks",
353+
);
340354
OTHER_LDFLAGS = "-Wl,-stack_size,0x200000";
341355
PRODUCT_BUNDLE_IDENTIFIER = nodejsmobile.test;
342356
PRODUCT_NAME = "$(TARGET_NAME)";

0 commit comments

Comments
 (0)