Skip to content

Commit 306ff49

Browse files
committed
feat: platform visionOS
1 parent a8a1277 commit 306ff49

29 files changed

Lines changed: 1480 additions & 0 deletions

File tree

packages/create-app/src/lib/templates.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ export const PLATFORMS: TemplateInfo[] = [
6969
directory: 'src/template',
7070
importName: 'pluginPlatformIOS',
7171
},
72+
{
73+
type: 'local',
74+
name: 'visionos',
75+
packageName: '@callstack/rnef-plugin-platform-visionos',
76+
localPath: path.join(TEMP_PACKAGES_PATH, 'plugin-platform-visionos'),
77+
directory: 'src/template',
78+
importName: 'pluginPlatformVisionOS',
79+
},
7280
{
7381
type: 'local',
7482
name: 'android',
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# plugin-platform-visionos
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Building
6+
7+
Run `nx build plugin-platform-visionos` to build the library.
8+
9+
## Running unit tests
10+
11+
Run `nx test plugin-platform-visionos` to execute the unit tests via [Vitest](https://vitest.dev/).
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import baseConfig from '../../eslint.config.js';
2+
3+
export default baseConfig;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "@callstack/rnef-plugin-platform-visionos",
3+
"version": "0.0.1",
4+
"type": "module",
5+
"exports": {
6+
"types": "./dist/src/index.d.ts",
7+
"import": "./dist/src/index.js"
8+
},
9+
"dependencies": {
10+
"@react-native-community/cli-config-apple": "^15.1.2",
11+
"tslib": "^2.3.0",
12+
"@callstack/rnef-plugin-platform-apple": "workspace:*"
13+
},
14+
"devDependencies": {
15+
"@callstack/rnef-config": "workspace:*"
16+
}
17+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "plugin-platform-visionos",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "packages/plugin-platform-visionos/src",
5+
"projectType": "library",
6+
"tags": [],
7+
"targets": {
8+
"build": {
9+
"executor": "@nx/js:tsc",
10+
"outputs": ["{options.outputPath}"],
11+
"options": {
12+
"outputPath": "packages/plugin-platform-visionos/dist",
13+
"main": "packages/plugin-platform-visionos/src/index.ts",
14+
"tsConfig": "packages/plugin-platform-visionos/tsconfig.lib.json",
15+
"assets": [
16+
"packages/plugin-platform-visionos/*.md",
17+
"packages/plugin-platform-visionos/src/template/**/*",
18+
"packages/plugin-platform-visionos/react-native.config.*"
19+
]
20+
}
21+
}
22+
}
23+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {
2+
getProjectConfig,
3+
getDependencyConfig,
4+
} from '@react-native-community/cli-config-apple';
5+
6+
export default {
7+
platforms: {
8+
visionos: {
9+
projectConfig: getProjectConfig({ platformName: 'visionos' }),
10+
dependencyConfig: getDependencyConfig({ platformName: 'visionos' }),
11+
},
12+
},
13+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './lib/pluginPlatformVisionOS.js';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { test, expect } from 'vitest';
2+
3+
test('dummy test', () => {
4+
expect(true).toBe(true);
5+
});
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import type { PluginOutput, PluginApi } from '@callstack/rnef-config';
2+
import {
3+
createBuild,
4+
createRun,
5+
getRunOptions,
6+
getBuildOptions,
7+
RunFlags,
8+
BuildFlags,
9+
} from '@callstack/rnef-plugin-platform-apple';
10+
import { getProjectConfig } from '@react-native-community/cli-config-apple';
11+
12+
const projectConfig = getProjectConfig({ platformName: 'visionos' });
13+
const buildOptions = getBuildOptions({ platformName: 'visionos' });
14+
const runOptions = getRunOptions({ platformName: 'visionos' });
15+
16+
export const pluginPlatformVisionOS =
17+
() =>
18+
(api: PluginApi): PluginOutput => {
19+
api.registerCommand({
20+
name: 'build:visionos',
21+
description: 'Build visionOS app.',
22+
action: async (args) => {
23+
const projectRoot = api.getProjectRoot();
24+
const config = projectConfig(projectRoot, {});
25+
26+
if (config) {
27+
await createBuild('visionos', config, args as BuildFlags);
28+
} else {
29+
throw new Error('visionOS project not found.');
30+
}
31+
},
32+
options: buildOptions,
33+
});
34+
35+
api.registerCommand({
36+
name: 'run:visionos',
37+
description: 'Run visionOS app.',
38+
action: async (args) => {
39+
const projectRoot = api.getProjectRoot();
40+
const config = projectConfig(projectRoot, {});
41+
42+
if (config) {
43+
await createRun('visionos', config, args as RunFlags, projectRoot);
44+
} else {
45+
throw new Error('visionOS project not found.');
46+
}
47+
},
48+
// @ts-expect-error: fix `simulator` is not defined in `RunFlags`
49+
options: runOptions,
50+
});
51+
52+
return {
53+
name: 'plugin-platform-visionos',
54+
description: 'RNEF plugin for everything visionOS.',
55+
};
56+
};
57+
58+
export default pluginPlatformVisionOS;
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: 'RNEF Remote Build - visionOS Simulator'
2+
description: 'Github implementation of the RNEF Remote Build for visionOS Simulator'
3+
4+
inputs:
5+
github-token:
6+
description: "GitHub Token"
7+
required: false
8+
default: ${{ github.token }}
9+
scheme:
10+
description: The workspace scheme to build
11+
required: false
12+
default: "HelloWorld"
13+
architectures:
14+
description: The architectures to build for
15+
required: false
16+
default: "arm64 x86_64"
17+
18+
outputs:
19+
artifact-url:
20+
description: 'URL of the relevant visionOS Simulator build artifact (could be cached)'
21+
value: ${{ steps.cached-url.outcome == 'success' && steps.cached-url.outputs.artifact-url || steps.upload-artifact.outputs.artifact-url }}
22+
23+
runs:
24+
using: "composite"
25+
steps:
26+
- name: Native Fingerprint
27+
id: fingerprint
28+
uses: ./.github/actions/rnef-native-fingerprint
29+
with:
30+
platforms: visionos
31+
32+
- name: Set variables
33+
run: |
34+
echo "ARTIFACT_NAME=${{inputs.scheme}}-${{inputs.architectures}}-${{ steps.fingerprint.outputs.hash}}.tar.gz" >> $GITHUB_ENV
35+
shell: bash
36+
37+
- name: Find artifact URL
38+
id: cached-url
39+
uses: ./.github/actions/find-artifact
40+
with:
41+
name: ${{ env.ARTIFACT_NAME }}
42+
43+
- name: Post Cached Build (if found)
44+
if: steps.cached-url.outputs.artifact-url
45+
uses: ./.github/actions/rnef-post-build
46+
with:
47+
platform: visionOS Simulator
48+
artifact-url: ${{ steps.cached-url.outputs.artifact-url }}
49+
50+
- name: Install Pods
51+
if: ${{ !steps.cached-url.outputs.artifact-url }}
52+
run: |
53+
cd visionos
54+
pod install --verbose
55+
shell: bash
56+
57+
- name: Build visionOS
58+
if: ${{ !steps.cached-url.outputs.artifact-url }}
59+
# Taken from: https://github.com/microsoft/rnx-kit/blob/ac1cfa362ace6172a020d2b4bcdd63c398527c17/incubator/build/scripts/build-apple.sh#L49
60+
# @TODO replace with RNEF CLI call.
61+
run: |
62+
cd visionos
63+
xcworkspace=$(find . -maxdepth 1 -name '*.xcworkspace' -type d | head -1)
64+
xcodebuild \
65+
-workspace "${xcworkspace}" \
66+
-scheme "${{inputs.scheme}}" \
67+
-destination "generic/platform=visionOS Simulator" \
68+
-configuration Debug \
69+
-derivedDataPath DerivedData \
70+
ARCHS="${{inputs.architectures}}" \
71+
CODE_SIGNING_ALLOWED=NO \
72+
CLANG_ADDRESS_SANITIZER=NO \
73+
CLANG_UNDEFINED_BEHAVIOR_SANITIZER=NO \
74+
OTHER_CFLAGS='$(inherited) -fno-sanitize=undefined -fno-sanitize=bounds -fstack-protector-strong' \
75+
OTHER_LDFLAGS='$(inherited) -fno-sanitize=undefined -fno-sanitize=bounds -fstack-protector-strong' \
76+
COMPILER_INDEX_STORE_ENABLE=NO \
77+
build
78+
shell: bash
79+
80+
- name: Prepare Artifact
81+
if: ${{ !steps.cached-url.outputs.artifact-url }}
82+
run: |
83+
app=$(find visionos/DerivedData/Build/Products/Debug-iphonesimulator -maxdepth 1 -name '*.app' -type d | head -1)
84+
app_dir=$(dirname "${app}")
85+
app_name=$(basename "${app}")
86+
tar -C "${app_dir}" -czvf "${{ env.ARTIFACT_NAME }}" "${app_name}"
87+
shell: bash
88+
89+
- name: Upload IPA
90+
id: upload-artifact
91+
if: ${{ !steps.cached-url.outputs.artifact-url }}
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: ${{ env.ARTIFACT_NAME }}
95+
path: ${{ env.ARTIFACT_NAME }}
96+
if-no-files-found: error
97+
98+
- name: Post Build
99+
if: ${{ !steps.cached-url.outputs.artifact-url }}
100+
uses: ./.github/actions/rnef-post-build
101+
with:
102+
platform: visionOS Simulator
103+
artifact-url: ${{ steps.upload-artifact.outputs.artifact-url }}

0 commit comments

Comments
 (0)