Skip to content

Commit 51fa06a

Browse files
authored
feat: make hermes build for visionOS (#26)
* [WIP] feat: make hermes build for visionOS * feat: point to callstack/hermes-visionos fork, update README * fix: remove USE_HERMES from project.pbxproj
1 parent ca3af60 commit 51fa06a

File tree

7 files changed

+81
-12
lines changed

7 files changed

+81
-12
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ This project is still at an early stage of development and is not ready for prod
1717

1818
1. Download latest Xcode beta [here](https://developer.apple.com/xcode/).
1919
2. Install visionOS Simulator runtime.
20-
3. Follow the same steps as for running iOS defined in [packages/rn-tester/README.md](./packages/rn-tester/README.md)
20+
3. (Optional) Using Hermes - Install latest version of CMake (3.28) from `main` branch:
21+
```sh
22+
brew install cmake --HEAD
23+
```
24+
4. Follow the same steps as for running iOS defined in [packages/rn-tester/README.md](./packages/rn-tester/README.md)

packages/react-native/sdks/hermes-engine/hermes-engine.podspec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ react_native_path = File.join(__dir__, "..", "..")
1212
package = JSON.parse(File.read(File.join(react_native_path, "package.json")))
1313
version = package['version']
1414

15-
source_type = hermes_source_type(version, react_native_path)
15+
# Temporaily build from source until visionOS supports prebuilt binaries
16+
source_type = HermesEngineSourceType::BUILD_FROM_GITHUB_MAIN # hermes_source_type(version, react_native_path)
1617
source = podspec_source(source_type, version, react_native_path)
1718

1819
Pod::Spec.new do |spec|
@@ -35,7 +36,7 @@ Pod::Spec.new do |spec|
3536
}
3637

3738
spec.ios.vendored_frameworks = "destroot/Library/Frameworks/ios/hermes.framework"
38-
spec.visionos.vendored_frameworks = "destroot/Library/Frameworks/visionos/hermes.framework"
39+
spec.visionos.vendored_frameworks = "destroot/Library/Frameworks/xros/hermes.framework"
3940
spec.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework"
4041

4142
if HermesEngineSourceType::isPrebuilt(source_type) then
@@ -133,7 +134,7 @@ Pod::Spec.new do |spec|
133134
:name => '[RN] [2] Build Hermes',
134135
:input_files => ["#{hermesc_path}/ImportHermesc.cmake"],
135136
:output_files => [
136-
"${PODS_ROOT}/hermes-engine/build/iphonesimulator/API/hermes/hermes.framework/hermes"
137+
"${PODS_ROOT}/hermes-engine/build/xrsimulator/API/hermes/hermes.framework/hermes",
137138
],
138139
:script => <<-EOS
139140
. "${REACT_NATIVE_PATH}/scripts/xcode/with-environment.sh"

packages/react-native/sdks/hermes-engine/hermes-utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
require 'net/http'
77
require 'rexml/document'
88

9-
HERMES_GITHUB_URL = "https://github.com/facebook/hermes.git"
9+
HERMES_GITHUB_URL = "https://github.com/callstack/hermes-visionos.git"
1010

1111
module HermesEngineSourceType
1212
LOCAL_PREBUILT_TARBALL = :local_prebuilt_tarball

packages/react-native/sdks/hermes-engine/utils/build-hermes-xcode.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ function get_platform_copy_destination {
1616
if [[ $1 == "macosx" ]]; then
1717
echo "macosx"
1818
return
19+
elif [[ $1 == "xros" ]]; then
20+
echo "xros"
21+
return
22+
elif [[ $1 == "xrsimulator" ]]; then
23+
echo "xros"
24+
return
1925
fi
20-
26+
2127
echo "ios"
2228
}
2329

packages/react-native/sdks/hermes-engine/utils/create-dummy-hermes-xcframework.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pushd destroot/Library/Frameworks > /dev/null || exit 1
1919

2020
echo '' > dummy.c
2121

22-
platforms=( "macosx" "ios" ) # Add other platforms here if needed
22+
platforms=( "macosx" "ios" "xros" ) # Add other platforms here if needed
2323

2424
for platform in "${platforms[@]}"
2525
do

packages/rn-tester/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def pods(target_name, options = {})
4040
# Hermes is now enabled by default.
4141
# The following line will only disable Hermes if the USE_HERMES envvar is SET to a value other than 1 (e.g. USE_HERMES=0).
4242
# TODO: Make hermes work
43-
hermes_enabled = false # !ENV.has_key?('USE_HERMES') || ENV['USE_HERMES'] == '1'
43+
hermes_enabled = !ENV.has_key?('USE_HERMES') || ENV['USE_HERMES'] == '1'
4444
puts "Configuring #{target_name} with Fabric #{fabric_enabled ? "enabled" : "disabled"}.#{hermes_enabled ? " Using Hermes engine." : ""}"
4545

4646
use_react_native!(

packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@
378378
68CD48B71D2BCB2C007E06A9 /* Build JS Bundle */,
379379
79E8BE2B119D4C5CCD2F04B3 /* [RN] Copy Hermes Framework */,
380380
5625E703156DD564DE9175B0 /* [CP] Copy Pods Resources */,
381+
FA9D5B1EDCCF1279A1157A2D /* [CP] Embed Pods Frameworks */,
381382
);
382383
buildRules = (
383384
);
@@ -397,6 +398,7 @@
397398
E7DB209C22B2BA84005AC45F /* Frameworks */,
398399
E7DB209D22B2BA84005AC45F /* Resources */,
399400
01934C30687B8C926E4F59CD /* [CP] Copy Pods Resources */,
401+
B3A406D440F7F60A503B9652 /* [CP] Embed Pods Frameworks */,
400402
);
401403
buildRules = (
402404
);
@@ -417,6 +419,7 @@
417419
E7DB215022B2F332005AC45F /* Frameworks */,
418420
E7DB215122B2F332005AC45F /* Resources */,
419421
E446637427ECD101CAACE52B /* [CP] Copy Pods Resources */,
422+
9263EBF9AC248C00975C6F74 /* [CP] Embed Pods Frameworks */,
420423
);
421424
buildRules = (
422425
);
@@ -588,6 +591,23 @@
588591
shellPath = /bin/sh;
589592
shellScript = ". ../react-native/sdks/hermes-engine/utils/copy-hermes-xcode.sh\n";
590593
};
594+
9263EBF9AC248C00975C6F74 /* [CP] Embed Pods Frameworks */ = {
595+
isa = PBXShellScriptBuildPhase;
596+
buildActionMask = 2147483647;
597+
files = (
598+
);
599+
inputFileListPaths = (
600+
"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks-${CONFIGURATION}-input-files.xcfilelist",
601+
);
602+
name = "[CP] Embed Pods Frameworks";
603+
outputFileListPaths = (
604+
"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks-${CONFIGURATION}-output-files.xcfilelist",
605+
);
606+
runOnlyForDeploymentPostprocessing = 0;
607+
shellPath = /bin/sh;
608+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks.sh\"\n";
609+
showEnvVarsInLog = 0;
610+
};
591611
ABDE2A52ACD1B95E14790B5E /* [CP] Check Pods Manifest.lock */ = {
592612
isa = PBXShellScriptBuildPhase;
593613
buildActionMask = 2147483647;
@@ -610,6 +630,23 @@
610630
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
611631
showEnvVarsInLog = 0;
612632
};
633+
B3A406D440F7F60A503B9652 /* [CP] Embed Pods Frameworks */ = {
634+
isa = PBXShellScriptBuildPhase;
635+
buildActionMask = 2147483647;
636+
files = (
637+
);
638+
inputFileListPaths = (
639+
"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks-${CONFIGURATION}-input-files.xcfilelist",
640+
);
641+
name = "[CP] Embed Pods Frameworks";
642+
outputFileListPaths = (
643+
"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks-${CONFIGURATION}-output-files.xcfilelist",
644+
);
645+
runOnlyForDeploymentPostprocessing = 0;
646+
shellPath = /bin/sh;
647+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks.sh\"\n";
648+
showEnvVarsInLog = 0;
649+
};
613650
B7EB74515CDE78D98087DD53 /* [CP] Check Pods Manifest.lock */ = {
614651
isa = PBXShellScriptBuildPhase;
615652
buildActionMask = 2147483647;
@@ -649,6 +686,23 @@
649686
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-resources.sh\"\n";
650687
showEnvVarsInLog = 0;
651688
};
689+
FA9D5B1EDCCF1279A1157A2D /* [CP] Embed Pods Frameworks */ = {
690+
isa = PBXShellScriptBuildPhase;
691+
buildActionMask = 2147483647;
692+
files = (
693+
);
694+
inputFileListPaths = (
695+
"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks-${CONFIGURATION}-input-files.xcfilelist",
696+
);
697+
name = "[CP] Embed Pods Frameworks";
698+
outputFileListPaths = (
699+
"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks-${CONFIGURATION}-output-files.xcfilelist",
700+
);
701+
runOnlyForDeploymentPostprocessing = 0;
702+
shellPath = /bin/sh;
703+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks.sh\"\n";
704+
showEnvVarsInLog = 0;
705+
};
652706
/* End PBXShellScriptBuildPhase section */
653707

654708
/* Begin PBXSourcesBuildPhase section */
@@ -901,15 +955,17 @@
901955
OTHER_LDFLAGS = (
902956
"-ObjC",
903957
"-lc++",
958+
"-Wl",
959+
"-ld_classic",
904960
);
905961
REACT_NATIVE_PATH = "${PODS_ROOT}/../../react-native";
906-
SDKROOT = iphoneos;
907-
USE_HERMES = false;
962+
SDKROOT = xros;
908963
WARNING_CFLAGS = (
909964
"-Wextra",
910965
"-Wall",
911966
"-Wno-semicolon-before-method-body",
912967
);
968+
XROS_DEPLOYMENT_TARGET = 1.0;
913969
};
914970
name = Debug;
915971
};
@@ -995,16 +1051,18 @@
9951051
OTHER_LDFLAGS = (
9961052
"-ObjC",
9971053
"-lc++",
1054+
"-Wl",
1055+
"-ld_classic",
9981056
);
9991057
REACT_NATIVE_PATH = "${PODS_ROOT}/../../react-native";
1000-
SDKROOT = iphoneos;
1001-
USE_HERMES = false;
1058+
SDKROOT = xros;
10021059
VALIDATE_PRODUCT = YES;
10031060
WARNING_CFLAGS = (
10041061
"-Wextra",
10051062
"-Wall",
10061063
"-Wno-semicolon-before-method-body",
10071064
);
1065+
XROS_DEPLOYMENT_TARGET = 1.0;
10081066
};
10091067
name = Release;
10101068
};

0 commit comments

Comments
 (0)