Skip to content

Commit cc2ad04

Browse files
Saadnajmitido64
andauthored
feat: add visionOS support (#1803)
Co-authored-by: Tommy Nguyen <[email protected]>
1 parent e69194f commit cc2ad04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2929
-267
lines changed

.github/CODEOWNERS

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ ios/ @Saadnajmi @kelset @tido64
1212
# macOS
1313
macos/ @Saadnajmi @kelset @tido64
1414

15+
# visionOS
16+
visionOS/ @Saadnajmi @kelset @tido64
17+
1518
# Windows
1619
windows/ @acoates-ms @kelset @tido64
1720

.github/actions/affected/action.yml

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ outputs:
1414
value: ${{ steps.affected.outputs.ios }}
1515
macos:
1616
value: ${{ steps.affected.outputs.macos }}
17+
visionos:
18+
value: ${{ steps.affected.outputs.visionos }}
1719
windows:
1820
value: ${{ steps.affected.outputs.windows }}
1921
runs:
@@ -31,7 +33,11 @@ runs:
3133
if [[ "$affected" = *"macos"* ]]; then
3234
echo 'macos=true' >> $GITHUB_OUTPUT
3335
fi
36+
if [[ "$affected" = *"visionos"* ]]; then
37+
echo 'visionos=true' >> $GITHUB_OUTPUT
38+
fi
3439
if [[ "$affected" = *"windows"* ]]; then
3540
echo 'windows=true' >> $GITHUB_OUTPUT
3641
fi
42+
echo $affected
3743
shell: bash

.github/actions/init-test-app/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ runs:
1414
- name: Initialize a new app
1515
run: |
1616
if [[ ${{ inputs.platform }} == "all" ]]; then
17-
yarn init-test-app --destination test-app --name TestApp -p android -p ios -p macos -p windows
17+
yarn init-test-app --destination test-app --name TestApp -p android -p ios -p macos -p visionos -p windows
1818
else
1919
yarn init-test-app --destination test-app --name TestApp --platform ${{ inputs.platform }}
2020
fi

.github/actions/setup-react-native/action.yml

+1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ runs:
1111
run: |
1212
rm example/ios/Podfile.lock
1313
rm example/macos/Podfile.lock
14+
rm example/visionos/Podfile.lock
1415
npm run set-react-version -- ${{ inputs.version }}
1516
shell: bash

.github/labeler.yml

+17
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@
4949
- scripts/*.js
5050
- scripts/xcodebuild.sh
5151
- test/*.rb
52+
"platform: visionOS":
53+
- changed-files:
54+
- any-glob-to-any-file:
55+
- .github/actions/cocoapods/*
56+
- .github/actions/init-test-app/*
57+
- .github/actions/setup-toolchain/*
58+
- .github/workflows/build.yml
59+
- Gemfile*
60+
- ReactTestApp-DevSupport.podspec
61+
- common/**/*
62+
- example/visionos/**/*
63+
- ios/*.rb
64+
- ios/ReactTestApp/*.{h,m,mm,swift}
65+
- visionos/**/*
66+
- scripts/*.js
67+
- scripts/xcodebuild.sh
68+
- test/*.rb
5269
"platform: Windows":
5370
- changed-files:
5471
- any-glob-to-any-file:

.github/pull_request_template.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Resolves #244.
2222
- [ ] Android
2323
- [ ] iOS
2424
- [ ] macOS
25+
- [ ] visionOS
2526
- [ ] Windows
2627

2728
### Test plan

.github/renovate.json

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
{
6161
"groupName": "react-native",
6262
"matchPackageNames": [
63+
"@callstack/react-native-visionos",
6364
"@react-native/assets-registry",
6465
"@react-native/babel-plugin-codegen",
6566
"@react-native/babel-preset",

.github/workflows/build.yml

+101
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,107 @@ jobs:
456456
../scripts/xcodebuild.sh ${{ steps.configure.outputs.project-directory }}/TemplateExample.xcworkspace build
457457
working-directory: template-example
458458
timeout-minutes: 60
459+
visionos:
460+
name: "visionOS"
461+
runs-on: macos-14
462+
if: ${{ github.event_name != 'schedule' }}
463+
steps:
464+
- name: Checkout
465+
uses: actions/checkout@v4
466+
with:
467+
filter: blob:none
468+
fetch-depth: 0
469+
- name: Set up toolchain
470+
uses: ./.github/actions/setup-toolchain
471+
with:
472+
platform: visionos
473+
project-root: example
474+
cache-key-prefix: example
475+
xcode-developer-dir: /Applications/Xcode_15.2.app
476+
- name: Set up react-native@nightly
477+
if: ${{ github.event_name == 'schedule' }}
478+
uses: ./.github/actions/setup-react-native
479+
with:
480+
version: nightly
481+
- name: Install npm dependencies
482+
uses: ./.github/actions/yarn
483+
with:
484+
immutable: ${{ github.event_name != 'schedule' }}
485+
- name: Bundle JavaScript
486+
run: |
487+
yarn build:visionos || yarn build:visionos
488+
working-directory: example
489+
- name: Determine whether the visionOS app needs to be built
490+
id: affected
491+
uses: ./.github/actions/affected
492+
- name: Install Pods
493+
if: ${{ steps.affected.outputs.visionos != '' }}
494+
uses: ./.github/actions/cocoapods
495+
with:
496+
project-directory: visionos
497+
working-directory: example
498+
- name: Build
499+
if: ${{ steps.affected.outputs.visionos != '' }}
500+
run: |
501+
../scripts/xcodebuild.sh visionos/Example.xcworkspace build-for-testing
502+
working-directory: example
503+
- name: Test `react-native config`
504+
if: ${{ steps.affected.outputs.visionos != '' }}
505+
run: |
506+
node --test test/config.test.mjs
507+
working-directory: example
508+
timeout-minutes: 60
509+
visionos-template:
510+
name: "visionOS [template]"
511+
strategy:
512+
matrix:
513+
template: [all, visionos]
514+
runs-on: macos-14
515+
if: ${{ github.event_name != 'schedule' }}
516+
steps:
517+
- name: Checkout
518+
uses: actions/checkout@v4
519+
with:
520+
filter: blob:none
521+
fetch-depth: 0
522+
- name: Set up toolchain
523+
uses: ./.github/actions/setup-toolchain
524+
with:
525+
platform: visionos
526+
project-root: example
527+
cache-key-prefix: template-${{ matrix.template }}
528+
xcode-developer-dir: /Applications/Xcode_15.2.app
529+
- name: Initialize test app
530+
uses: ./.github/actions/init-test-app
531+
with:
532+
platform: ${{ matrix.template }}
533+
- name: Bundle JavaScript
534+
run: |
535+
yarn build:visionos || yarn build:visionos
536+
working-directory: template-example
537+
- name: Determine whether the visionOS app needs to be built
538+
id: affected
539+
uses: ./.github/actions/affected
540+
- name: Determine project directory
541+
id: configure
542+
if: ${{ steps.affected.outputs.visionos != '' }}
543+
run: |
544+
if [[ ${{ matrix.template }} == visionos ]]; then
545+
echo 'project-directory=.' >> $GITHUB_OUTPUT
546+
else
547+
echo 'project-directory=visionos' >> $GITHUB_OUTPUT
548+
fi
549+
- name: Install Pods
550+
if: ${{ steps.affected.outputs.visionos != '' }}
551+
run: |
552+
pod install --project-directory=${{ steps.configure.outputs.project-directory }}
553+
working-directory: template-example
554+
- name: Build
555+
if: ${{ steps.affected.outputs.visionos != '' }}
556+
run: |
557+
../scripts/xcodebuild.sh ${{ steps.configure.outputs.project-directory }}/TemplateExample.xcworkspace build
558+
working-directory: template-example
559+
timeout-minutes: 60
459560
windows:
460561
name: "Windows"
461562
runs-on: windows-latest

ReactTestApp-DevSupport.podspec

+10-9
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ require 'json'
44
# undefined method `deployment_target' for Pod:Module.
55
# But procedures and lambdas work fine.
66
deployment_target = lambda do |target_platform|
7-
xcodeproj = File.join(__dir__, target_platform, 'ReactTestApp.xcodeproj')
7+
xcodeproj = File.join(__dir__, target_platform.to_s, 'ReactTestApp.xcodeproj')
88
project = Xcodeproj::Project.open(xcodeproj)
9-
setting = case target_platform
10-
when 'ios'
11-
'IPHONEOS_DEPLOYMENT_TARGET'
12-
when 'macos'
13-
'MACOSX_DEPLOYMENT_TARGET'
14-
end
9+
settings = {
10+
ios: 'IPHONEOS_DEPLOYMENT_TARGET',
11+
macos: 'MACOSX_DEPLOYMENT_TARGET',
12+
visionos: 'XROS_DEPLOYMENT_TARGET',
13+
}
14+
setting = settings[target_platform]
1515
project.build_configurations[0].resolve_build_setting(setting)
1616
end
1717

@@ -27,8 +27,9 @@ Pod::Spec.new do |s|
2727
s.source = { :git => package['repository']['url'], :tag => version }
2828
s.summary = package['description']
2929

30-
s.ios.deployment_target = deployment_target.call('ios')
31-
s.osx.deployment_target = deployment_target.call('macos')
30+
s.ios.deployment_target = deployment_target.call(:ios)
31+
s.osx.deployment_target = deployment_target.call(:macos)
32+
s.visionos.deployment_target = deployment_target.call(:visionos)
3233

3334
s.dependency 'React-Core'
3435
s.dependency 'React-jsi'

example/Example-Tests.podspec

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Pod::Spec.new do |s|
1313

1414
s.ios.deployment_target = '13.0'
1515
s.osx.deployment_target = '10.15'
16+
s.visionos.deployment_target = '1.0'
1617

1718
s.dependency 'React'
1819
s.dependency 'ReactTestApp-DevSupport'

example/app.json

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
"dist/assets",
2727
"dist/main.macos.jsbundle"
2828
],
29+
"visionos": [
30+
"dist/assets",
31+
"dist/main.visionos.jsbundle"
32+
],
2933
"windows": [
3034
"dist/assets",
3135
"dist/main.windows.bundle"

0 commit comments

Comments
 (0)