Skip to content

Commit

Permalink
feat: make hermes build for visionOS (#26)
Browse files Browse the repository at this point in the history
* [WIP] feat: make hermes build for visionOS

* feat: point to callstack/hermes-visionos fork, update README

* fix: remove USE_HERMES from project.pbxproj
  • Loading branch information
okwasniewski authored Nov 13, 2023
1 parent ca3af60 commit 51fa06a
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 12 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ This project is still at an early stage of development and is not ready for prod

1. Download latest Xcode beta [here](https://developer.apple.com/xcode/).
2. Install visionOS Simulator runtime.
3. Follow the same steps as for running iOS defined in [packages/rn-tester/README.md](./packages/rn-tester/README.md)
3. (Optional) Using Hermes - Install latest version of CMake (3.28) from `main` branch:
```sh
brew install cmake --HEAD
```
4. Follow the same steps as for running iOS defined in [packages/rn-tester/README.md](./packages/rn-tester/README.md)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ react_native_path = File.join(__dir__, "..", "..")
package = JSON.parse(File.read(File.join(react_native_path, "package.json")))
version = package['version']

source_type = hermes_source_type(version, react_native_path)
# Temporaily build from source until visionOS supports prebuilt binaries
source_type = HermesEngineSourceType::BUILD_FROM_GITHUB_MAIN # hermes_source_type(version, react_native_path)
source = podspec_source(source_type, version, react_native_path)

Pod::Spec.new do |spec|
Expand All @@ -35,7 +36,7 @@ Pod::Spec.new do |spec|
}

spec.ios.vendored_frameworks = "destroot/Library/Frameworks/ios/hermes.framework"
spec.visionos.vendored_frameworks = "destroot/Library/Frameworks/visionos/hermes.framework"
spec.visionos.vendored_frameworks = "destroot/Library/Frameworks/xros/hermes.framework"
spec.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework"

if HermesEngineSourceType::isPrebuilt(source_type) then
Expand Down Expand Up @@ -133,7 +134,7 @@ Pod::Spec.new do |spec|
:name => '[RN] [2] Build Hermes',
:input_files => ["#{hermesc_path}/ImportHermesc.cmake"],
:output_files => [
"${PODS_ROOT}/hermes-engine/build/iphonesimulator/API/hermes/hermes.framework/hermes"
"${PODS_ROOT}/hermes-engine/build/xrsimulator/API/hermes/hermes.framework/hermes",
],
:script => <<-EOS
. "${REACT_NATIVE_PATH}/scripts/xcode/with-environment.sh"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/sdks/hermes-engine/hermes-utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require 'net/http'
require 'rexml/document'

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

module HermesEngineSourceType
LOCAL_PREBUILT_TARBALL = :local_prebuilt_tarball
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ function get_platform_copy_destination {
if [[ $1 == "macosx" ]]; then
echo "macosx"
return
elif [[ $1 == "xros" ]]; then
echo "xros"
return
elif [[ $1 == "xrsimulator" ]]; then
echo "xros"
return
fi

echo "ios"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pushd destroot/Library/Frameworks > /dev/null || exit 1

echo '' > dummy.c

platforms=( "macosx" "ios" ) # Add other platforms here if needed
platforms=( "macosx" "ios" "xros" ) # Add other platforms here if needed

for platform in "${platforms[@]}"
do
Expand Down
2 changes: 1 addition & 1 deletion packages/rn-tester/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def pods(target_name, options = {})
# Hermes is now enabled by default.
# 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).
# TODO: Make hermes work
hermes_enabled = false # !ENV.has_key?('USE_HERMES') || ENV['USE_HERMES'] == '1'
hermes_enabled = !ENV.has_key?('USE_HERMES') || ENV['USE_HERMES'] == '1'
puts "Configuring #{target_name} with Fabric #{fabric_enabled ? "enabled" : "disabled"}.#{hermes_enabled ? " Using Hermes engine." : ""}"

use_react_native!(
Expand Down
66 changes: 62 additions & 4 deletions packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@
68CD48B71D2BCB2C007E06A9 /* Build JS Bundle */,
79E8BE2B119D4C5CCD2F04B3 /* [RN] Copy Hermes Framework */,
5625E703156DD564DE9175B0 /* [CP] Copy Pods Resources */,
FA9D5B1EDCCF1279A1157A2D /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand All @@ -397,6 +398,7 @@
E7DB209C22B2BA84005AC45F /* Frameworks */,
E7DB209D22B2BA84005AC45F /* Resources */,
01934C30687B8C926E4F59CD /* [CP] Copy Pods Resources */,
B3A406D440F7F60A503B9652 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand All @@ -417,6 +419,7 @@
E7DB215022B2F332005AC45F /* Frameworks */,
E7DB215122B2F332005AC45F /* Resources */,
E446637427ECD101CAACE52B /* [CP] Copy Pods Resources */,
9263EBF9AC248C00975C6F74 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -588,6 +591,23 @@
shellPath = /bin/sh;
shellScript = ". ../react-native/sdks/hermes-engine/utils/copy-hermes-xcode.sh\n";
};
9263EBF9AC248C00975C6F74 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
ABDE2A52ACD1B95E14790B5E /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -610,6 +630,23 @@
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";
showEnvVarsInLog = 0;
};
B3A406D440F7F60A503B9652 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
B7EB74515CDE78D98087DD53 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -649,6 +686,23 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
FA9D5B1EDCCF1279A1157A2D /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -901,15 +955,17 @@
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
"-Wl",
"-ld_classic",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../react-native";
SDKROOT = iphoneos;
USE_HERMES = false;
SDKROOT = xros;
WARNING_CFLAGS = (
"-Wextra",
"-Wall",
"-Wno-semicolon-before-method-body",
);
XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Debug;
};
Expand Down Expand Up @@ -995,16 +1051,18 @@
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
"-Wl",
"-ld_classic",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../react-native";
SDKROOT = iphoneos;
USE_HERMES = false;
SDKROOT = xros;
VALIDATE_PRODUCT = YES;
WARNING_CFLAGS = (
"-Wextra",
"-Wall",
"-Wno-semicolon-before-method-body",
);
XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Release;
};
Expand Down

0 comments on commit 51fa06a

Please sign in to comment.