Skip to content

Commit f441f6f

Browse files
committed
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 26b8a9b commit f441f6f

File tree

7 files changed

+77
-12
lines changed

7 files changed

+77
-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
@@ -132,7 +133,7 @@ Pod::Spec.new do |spec|
132133
:name => '[RN] [2] Build Hermes',
133134
:input_files => ["#{hermesc_path}/ImportHermesc.cmake"],
134135
:output_files => [
135-
"${PODS_ROOT}/hermes-engine/build/iphonesimulator/API/hermes/hermes.framework/hermes"
136+
"${PODS_ROOT}/hermes-engine/build/xrsimulator/API/hermes/hermes.framework/hermes",
136137
],
137138
:script => <<-EOS
138139
. "${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: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@
376376
68CD48B71D2BCB2C007E06A9 /* Build JS Bundle */,
377377
79E8BE2B119D4C5CCD2F04B3 /* [RN] Copy Hermes Framework */,
378378
5625E703156DD564DE9175B0 /* [CP] Copy Pods Resources */,
379+
FA9D5B1EDCCF1279A1157A2D /* [CP] Embed Pods Frameworks */,
379380
);
380381
buildRules = (
381382
);
@@ -395,6 +396,7 @@
395396
E7DB209C22B2BA84005AC45F /* Frameworks */,
396397
E7DB209D22B2BA84005AC45F /* Resources */,
397398
01934C30687B8C926E4F59CD /* [CP] Copy Pods Resources */,
399+
B3A406D440F7F60A503B9652 /* [CP] Embed Pods Frameworks */,
398400
);
399401
buildRules = (
400402
);
@@ -415,6 +417,7 @@
415417
E7DB215022B2F332005AC45F /* Frameworks */,
416418
E7DB215122B2F332005AC45F /* Resources */,
417419
E446637427ECD101CAACE52B /* [CP] Copy Pods Resources */,
420+
9263EBF9AC248C00975C6F74 /* [CP] Embed Pods Frameworks */,
418421
);
419422
buildRules = (
420423
);
@@ -586,6 +589,23 @@
586589
shellPath = /bin/sh;
587590
shellScript = ". ../react-native/sdks/hermes-engine/utils/copy-hermes-xcode.sh\n";
588591
};
592+
9263EBF9AC248C00975C6F74 /* [CP] Embed Pods Frameworks */ = {
593+
isa = PBXShellScriptBuildPhase;
594+
buildActionMask = 2147483647;
595+
files = (
596+
);
597+
inputFileListPaths = (
598+
"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks-${CONFIGURATION}-input-files.xcfilelist",
599+
);
600+
name = "[CP] Embed Pods Frameworks";
601+
outputFileListPaths = (
602+
"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks-${CONFIGURATION}-output-files.xcfilelist",
603+
);
604+
runOnlyForDeploymentPostprocessing = 0;
605+
shellPath = /bin/sh;
606+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks.sh\"\n";
607+
showEnvVarsInLog = 0;
608+
};
589609
ABDE2A52ACD1B95E14790B5E /* [CP] Check Pods Manifest.lock */ = {
590610
isa = PBXShellScriptBuildPhase;
591611
buildActionMask = 2147483647;
@@ -608,6 +628,23 @@
608628
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";
609629
showEnvVarsInLog = 0;
610630
};
631+
B3A406D440F7F60A503B9652 /* [CP] Embed Pods Frameworks */ = {
632+
isa = PBXShellScriptBuildPhase;
633+
buildActionMask = 2147483647;
634+
files = (
635+
);
636+
inputFileListPaths = (
637+
"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks-${CONFIGURATION}-input-files.xcfilelist",
638+
);
639+
name = "[CP] Embed Pods Frameworks";
640+
outputFileListPaths = (
641+
"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks-${CONFIGURATION}-output-files.xcfilelist",
642+
);
643+
runOnlyForDeploymentPostprocessing = 0;
644+
shellPath = /bin/sh;
645+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks.sh\"\n";
646+
showEnvVarsInLog = 0;
647+
};
611648
B7EB74515CDE78D98087DD53 /* [CP] Check Pods Manifest.lock */ = {
612649
isa = PBXShellScriptBuildPhase;
613650
buildActionMask = 2147483647;
@@ -647,6 +684,23 @@
647684
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-resources.sh\"\n";
648685
showEnvVarsInLog = 0;
649686
};
687+
FA9D5B1EDCCF1279A1157A2D /* [CP] Embed Pods Frameworks */ = {
688+
isa = PBXShellScriptBuildPhase;
689+
buildActionMask = 2147483647;
690+
files = (
691+
);
692+
inputFileListPaths = (
693+
"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks-${CONFIGURATION}-input-files.xcfilelist",
694+
);
695+
name = "[CP] Embed Pods Frameworks";
696+
outputFileListPaths = (
697+
"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks-${CONFIGURATION}-output-files.xcfilelist",
698+
);
699+
runOnlyForDeploymentPostprocessing = 0;
700+
shellPath = /bin/sh;
701+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks.sh\"\n";
702+
showEnvVarsInLog = 0;
703+
};
650704
/* End PBXShellScriptBuildPhase section */
651705

652706
/* Begin PBXSourcesBuildPhase section */
@@ -897,13 +951,13 @@
897951
"-ld_classic",
898952
);
899953
REACT_NATIVE_PATH = "${PODS_ROOT}/../../react-native";
900-
SDKROOT = iphoneos;
901-
USE_HERMES = false;
954+
SDKROOT = xros;
902955
WARNING_CFLAGS = (
903956
"-Wextra",
904957
"-Wall",
905958
"-Wno-semicolon-before-method-body",
906959
);
960+
XROS_DEPLOYMENT_TARGET = 1.0;
907961
};
908962
name = Debug;
909963
};
@@ -989,14 +1043,14 @@
9891043
"-ld_classic",
9901044
);
9911045
REACT_NATIVE_PATH = "${PODS_ROOT}/../../react-native";
992-
SDKROOT = iphoneos;
993-
USE_HERMES = false;
1046+
SDKROOT = xros;
9941047
VALIDATE_PRODUCT = YES;
9951048
WARNING_CFLAGS = (
9961049
"-Wextra",
9971050
"-Wall",
9981051
"-Wno-semicolon-before-method-body",
9991052
);
1053+
XROS_DEPLOYMENT_TARGET = 1.0;
10001054
};
10011055
name = Release;
10021056
};

0 commit comments

Comments
 (0)