Skip to content

Commit

Permalink
feat: add visionOS support
Browse files Browse the repository at this point in the history
  • Loading branch information
okwasniewski committed Mar 21, 2024
1 parent 75cdee9 commit 2d92e23
Show file tree
Hide file tree
Showing 9 changed files with 289 additions and 16 deletions.
11 changes: 10 additions & 1 deletion .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.2
resource_class: macos.m1.medium.gen1
working_directory: ~/hermes
environment:
Expand Down Expand Up @@ -192,6 +192,15 @@ jobs:
-destination 'platform=iOS Simulator,name=iPhone 11' \
-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 Down
4 changes: 4 additions & 0 deletions API/hermes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ 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")
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.
# 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7633211E2BA9C44A00196D44"
BuildableName = "ApplePlatformsIntegrationVisionOSTests.xctest"
BlueprintName = "ApplePlatformsIntegrationVisionOSTests"
ReferencedContainer = "container:ApplePlatformsIntegrationTests.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
8 changes: 7 additions & 1 deletion test/ApplePlatformsIntegrationTestApp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ source 'https://cdn.cocoapods.org/'

target 'ApplePlatformsIntegrationMobileTests' do
use_frameworks!
platform :ios, '11'
platform :ios, '12.0'
pod 'hermes-engine', :path => '../../'
end

target 'ApplePlatformsIntegrationVisionOSTests' do
use_frameworks!
platform :visionos, '1.0'
pod 'hermes-engine', :path => '../../'
end

Expand Down
6 changes: 5 additions & 1 deletion utils/build-apple-framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ function get_ios_deployment_target {
ruby -rcocoapods-core -rjson -e "puts Pod::Specification.from_file('hermes-engine.podspec').deployment_target('ios')"
}

function get_visionos_deployment_target {
ruby -rcocoapods-core -rjson -e "puts Pod::Specification.from_file('hermes-engine.podspec').deployment_target('visionos')"
}

function get_mac_deployment_target {
ruby -rcocoapods-core -rjson -e "puts Pod::Specification.from_file('hermes-engine.podspec').deployment_target('osx')"
}
Expand All @@ -47,7 +51,7 @@ function build_host_hermesc {
function configure_apple_framework {
local build_cli_tools enable_bitcode

if [[ $1 == iphoneos || $1 == catalyst ]]; then
if [[ $1 == iphoneos || $1 == catalyst || $1 == visionos ]]; then
enable_bitcode="true"
else
enable_bitcode="false"
Expand Down
5 changes: 4 additions & 1 deletion utils/build-ios-framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@

if [ ! -d destroot/Library/Frameworks/universal/hermes.xcframework ]; then
ios_deployment_target=$(get_ios_deployment_target)
visionos_deployment_target=$(get_visionos_deployment_target)

build_apple_framework "iphoneos" "arm64" "$ios_deployment_target"
build_apple_framework "iphonesimulator" "x86_64;arm64" "$ios_deployment_target"
build_apple_framework "catalyst" "x86_64;arm64" "$ios_deployment_target"
build_apple_framework "xros" "arm64" "$visionos_deployment_target"
build_apple_framework "xrsimulator" "arm64" "$visionos_deployment_target"

create_universal_framework "iphoneos" "iphonesimulator" "catalyst"
create_universal_framework "iphoneos" "iphonesimulator" "catalyst" "xros" "xrsimulator"
else
echo "Skipping; Clean \"destroot\" to rebuild".
fi

0 comments on commit 2d92e23

Please sign in to comment.