Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add visionOS support #1358

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 29 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ workflows:
# Default settings for Apple jobs (apple-runtime, test-apple-runtime)
apple_defaults: &apple_defaults
macos:
xcode: 13.4.1
xcode: 15.3
resource_class: macos.m1.medium.gen1
working_directory: ~/hermes
environment:
Expand Down Expand Up @@ -168,7 +168,10 @@ jobs:
- run:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologise, I thought testing didn't require CMake, but it looks like pod install is looking for it. We should add the same thing here with a comment.

name: Install dependencies
command: |
brew install cmake ninja
brew install ninja
# TODO: See comment in build-apple-runtime.
brew update
brew install cmake
- run:
name: Build the test application
command: |
Expand All @@ -189,9 +192,18 @@ jobs:
xcodebuild test \
-workspace ApplePlatformsIntegrationTests.xcworkspace \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 11' \
-destination 'platform=iOS Simulator,name=iPhone 15' \
-scheme ApplePlatformsIntegrationMobileTests
working_directory: test/ApplePlatformsIntegrationTestApp
- run:
name: Test Apple Vision application
command: |
xcodebuild test \
-workspace ApplePlatformsIntegrationTests.xcworkspace \
-configuration Debug \
-destination 'platform=visionOS Simulator,name=Apple Vision Pro' \
-scheme ApplePlatformsIntegrationVisionOSTests
working_directory: test/ApplePlatformsIntegrationTestApp

build-apple-runtime:
<<: *apple_defaults
Expand All @@ -207,8 +219,13 @@ jobs:
- run:
name: Install dependencies
command: |
brew install cmake ninja
brew install ninja
sudo gem install cocoapods
# TODO: Building for Apple Vision Pro requires a newer version of
# CMake than is available by default. Remove "brew update" once the
# CircleCI image contains CMake > 3.29.2.
brew update
brew install cmake
- run:
name: Build the iOS frameworks
command: ./utils/build-ios-framework.sh
Expand All @@ -222,6 +239,8 @@ jobs:
- ~/hermes/build_catalyst
- ~/hermes/build_iphonesimulator
- ~/hermes/build_macosx
- ~/hermes/build_xros
- ~/hermes/build_xrsimulator
- ~/hermes/destroot

package-apple-runtime:
Expand All @@ -236,8 +255,10 @@ jobs:
- run:
name: Install dependencies
command: |
brew install cmake ninja
sudo gem install cocoapods
# TODO: See comment in build-apple-runtime.
brew update
brew install cmake
- run:
name: Package the framework
command: |
Expand Down Expand Up @@ -265,7 +286,7 @@ jobs:

macos:
macos:
xcode: 13.4.1
xcode: 13.4.1
steps:
- checkout:
path: hermes
Expand Down Expand Up @@ -303,7 +324,7 @@ jobs:

test-macos:
macos:
xcode: 13.4.1
xcode: 13.4.1
steps:
- checkout:
path: hermes
Expand Down Expand Up @@ -680,7 +701,7 @@ jobs:

test-macos-test262:
macos:
xcode: 13.4.1
xcode: 13.4.1
steps:
- checkout:
path: hermes
Expand Down
8 changes: 8 additions & 0 deletions API/hermes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ if(APPLE AND HERMES_BUILD_APPLE_FRAMEWORK)
add_custom_command(TARGET libhermes POST_BUILD
COMMAND /usr/libexec/PlistBuddy -c "Add :LSMinimumSystemVersion string ${CMAKE_OSX_DEPLOYMENT_TARGET}" $<TARGET_FILE_DIR:libhermes>/Resources/Info.plist
)
elseif(HERMES_APPLE_TARGET_PLATFORM MATCHES "xr")
if(CMAKE_VERSION VERSION_LESS 3.28.4)
message("VisionOS Simulator requires CMake version >= 3.28.4")
endif()

add_custom_command(TARGET libhermes POST_BUILD
COMMAND /usr/libexec/PlistBuddy -c "Add :MinimumOSVersion string ${CMAKE_OSX_DEPLOYMENT_TARGET}" $<TARGET_FILE_DIR:libhermes>/Info.plist
)
endif()
endif()

Expand Down
3 changes: 2 additions & 1 deletion hermes-engine.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ Pod::Spec.new do |spec|
# The podspec would be serialized to JSON and people will download prebuilt binaries instead of the source.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think React Native uses this file. It is pretty outdated, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was needed to make the internal hermes tests work and properly build in Xcode

# TODO(use the hash field as a validation mechanism when the process is stable)
spec.source = ENV['hermes-artifact-url'] ? { http: ENV['hermes-artifact-url'] } : { git: "https://github.com/facebook/hermes.git", tag: "v#{spec.version}" }
spec.platforms = { :osx => "10.13", :ios => "11.0" }
spec.platforms = { :osx => "10.13", :ios => "12.0", :visionos => "1.0" }

spec.preserve_paths = ["destroot/bin/*"].concat(HermesHelper::BUILD_TYPE == :debug ? ["**/*.{h,c,cpp}"] : [])
spec.source_files = "destroot/include/**/*.h"
spec.header_mappings_dir = "destroot/include"

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

spec.xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", "CLANG_CXX_LIBRARY" => "compiler-default", "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" }
Expand Down
1 change: 1 addition & 0 deletions lib/Platform/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <android/log.h>
#elif defined(__APPLE__)
#include <os/log.h>
#include <stdio.h>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the source of issues 😄 vsnprintf function wasn't automatically imported for visionOS

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from what I read in the docs, it's probably also a problem on macOS 11.3+ toolchains. weird they'd make such a fundamental change to their core libc headers after so many years 🤷

#else
#include <cstdio>
#endif
Expand Down