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: visionOS support #5783

Merged
merged 45 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
747866f
chore: wip platform for visionos
rigor789 Sep 28, 2023
96830fc
feat: initial visionOS platform handling
rigor789 Sep 29, 2023
b5a3da5
chore: bump ios-sim-portable
rigor789 Sep 29, 2023
f4b7a69
fix(visionos): fallback to App_Resources/ios
rigor789 Sep 29, 2023
3e50cb3
fix: rename TNSNativeSource > NSNativeSources
NathanWalker Sep 29, 2023
eb2de47
fix(vision): write runtime package.json
rigor789 Sep 29, 2023
9acc5f9
fix: path platform detect handling for visionOS
NathanWalker Sep 29, 2023
df85555
chore(release): nativescript 8.6.0-vision.0
rigor789 Sep 29, 2023
c672cca
fix(vision): platform paths
rigor789 Sep 29, 2023
f445267
chore(release): nativescript 8.6.0-vision.1
rigor789 Sep 29, 2023
6392c75
fix(visionos): use App_Resources/visionOS to merge Info.plist
NathanWalker Oct 4, 2023
bc72497
release: 8.6.0-vision.2
NathanWalker Oct 4, 2023
8fbc23f
feat(create): vision flags
NathanWalker Oct 5, 2023
e666686
release: 8.6.0-vision.3
NathanWalker Oct 6, 2023
0a5cf4d
chore: cleanup
NathanWalker Oct 9, 2023
724f9bc
release: 8.6.0-vision.4
NathanWalker Oct 9, 2023
3da7962
release: 8.6.0-vision.6
NathanWalker Oct 10, 2023
74f2f31
fix: vision support
NathanWalker Oct 10, 2023
e36d0ab
release: 8.6.0-vision.7
NathanWalker Oct 10, 2023
8f10833
feat(visionos): allow platform specific SPM Packages
NathanWalker Oct 30, 2023
165e459
release: 8.6.2-vision.8
NathanWalker Oct 30, 2023
30acce0
fix(ios): skip package validation on xcodebuild
NathanWalker Jan 27, 2024
7c8a46a
chore: cleanup
NathanWalker Feb 3, 2024
d7ec912
fix: visionOS simulator logs
rigor789 Feb 7, 2024
0c87c46
chore: ensure arm64 if vision productType
NathanWalker Feb 7, 2024
af292bb
release: 8.6.6-vision.9
NathanWalker Feb 7, 2024
2cb22c8
feat(visionos): add device run support
NathanWalker Feb 13, 2024
064078f
feat(start): visionOS for ns start commands
NathanWalker Feb 13, 2024
d3ab25d
release: 8.6.6-vision.10
NathanWalker Feb 13, 2024
2d8faf6
feat: add visionOS to start menu
NathanWalker Feb 18, 2024
f6f23e3
fix: vision device info
NathanWalker Feb 18, 2024
d4d3531
fix(visionos): entitlement handling
NathanWalker Feb 18, 2024
b5084c3
release: 8.6.6-vision.11
NathanWalker Feb 18, 2024
fcaa07a
feat: allow macros to be defined in users build.xcconfig
NathanWalker Apr 1, 2024
3aed320
Merge branch 'main' into feat/visions-platform
rigor789 Apr 2, 2024
29d5c18
chore: fix deps
rigor789 Apr 2, 2024
b70477e
feat: allow NS_SWIFTUI_BOOT user defined value
NathanWalker Apr 2, 2024
7605441
release: 8.7.0-rc.0
NathanWalker Apr 2, 2024
afab03b
fix: ensure ts vision template is handled via flag
NathanWalker Apr 3, 2024
f8505ba
release: 8.7.0-rc.1
NathanWalker Apr 3, 2024
c34b49d
feat: build|visionos placeholder
rigor789 Apr 3, 2024
55f4d98
fix: vision template selection
rigor789 Apr 3, 2024
9550fbd
chore: cleanup
rigor789 Apr 3, 2024
b6f281d
chore: fix tests
rigor789 Apr 3, 2024
fdf76e0
release: 8.7.0-rc.2
rigor789 Apr 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,24 +180,32 @@ injector.requireCommand("platform|update", "./commands/update-platform");
injector.requireCommand("run|*all", "./commands/run");
injector.requireCommand("run|ios", "./commands/run");
injector.requireCommand("run|android", "./commands/run");
injector.requireCommand("run|vision", "./commands/run");
injector.requireCommand("run|visionos", "./commands/run");
injector.requireCommand("typings", "./commands/typings");

injector.requireCommand("preview", "./commands/preview");

injector.requireCommand("debug|ios", "./commands/debug");
injector.requireCommand("debug|android", "./commands/debug");
injector.requireCommand("debug|vision", "./commands/debug");
injector.requireCommand("debug|visionos", "./commands/debug");
injector.requireCommand("fonts", "./commands/fonts");

injector.requireCommand("prepare", "./commands/prepare");
injector.requireCommand("build|ios", "./commands/build");
injector.requireCommand("build|android", "./commands/build");
// injector.requireCommand("build|vision", "./commands/build");
// injector.requireCommand("build|visionos", "./commands/build");
injector.requireCommand("deploy", "./commands/deploy");

injector.require("testExecutionService", "./services/test-execution-service");
injector.requireCommand("dev-test|android", "./commands/test");
injector.requireCommand("dev-test|ios", "./commands/test");
injector.requireCommand("test|android", "./commands/test");
injector.requireCommand("test|ios", "./commands/test");
// injector.requireCommand("test|vision", "./commands/test");
// injector.requireCommand("test|visionos", "./commands/test");
injector.requireCommand("test|init", "./commands/test-init");
injector.requireCommand("dev-generate-help", "./commands/generate-help");

Expand Down
6 changes: 5 additions & 1 deletion lib/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
$platformValidationService: IPlatformValidationService,
$logger: ILogger,
$buildDataService: IBuildDataService,
private $migrateController: IMigrateController
protected $migrateController: IMigrateController
) {
super(
$options,
Expand Down Expand Up @@ -221,3 +221,7 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
}

injector.registerCommand("build|android", BuildAndroidCommand);

// export class BuildVisionOsCommand extends BuildIosCommand implements ICommand {}
// injector.registerCommand("build|vision", BuildVisionOsCommand);
// injector.registerCommand("build|visionos", BuildVisionOsCommand);
74 changes: 65 additions & 9 deletions lib/commands/create-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export class CreateProjectCommand implements ICommand {
private static BlankTemplateDescription = "A blank app";
private static BlankTsTemplateKey = "Blank Typescript";
private static BlankTsTemplateDescription = "A blank typescript app";
private static BlankVisionTemplateKey = "visionOS";
private static BlankVisionTemplateDescription = "A visionOS app";
private static HelloWorldTemplateKey = "Hello World";
private static HelloWorldTemplateDescription = "A Hello World app";
private static DrawerTemplateKey = "SideDrawer";
Expand Down Expand Up @@ -72,6 +74,16 @@ export class CreateProjectCommand implements ICommand {
selectedTemplate = constants.REACT_NAME;
} else if (this.$options.svelte) {
selectedTemplate = constants.SVELTE_NAME;
} else if (this.$options["vision-ng"]) {
selectedTemplate = constants.RESERVED_TEMPLATE_NAMES["vision-ng"];
} else if (this.$options["vision-react"]) {
selectedTemplate = constants.RESERVED_TEMPLATE_NAMES["vision-react"];
} else if (this.$options["vision-solid"]) {
selectedTemplate = constants.RESERVED_TEMPLATE_NAMES["vision-solid"];
} else if (this.$options["vision-svelte"]) {
selectedTemplate = constants.RESERVED_TEMPLATE_NAMES["vision-svelte"];
} else if (this.$options["vision-vue"]) {
selectedTemplate = constants.RESERVED_TEMPLATE_NAMES["vision-vue"];
} else {
selectedTemplate = this.$options.template;
}
Expand Down Expand Up @@ -262,6 +274,11 @@ can skip this prompt next time using the --template option, or the --ng, --react
value: "@nativescript/template-tab-navigation-ts",
description: CreateProjectCommand.TabsTemplateDescription,
},
{
key: CreateProjectCommand.BlankVisionTemplateKey,
value: "@nativescript/template-hello-world-ts-vision",
description: CreateProjectCommand.BlankVisionTemplateDescription,
},
];

return templates;
Expand All @@ -284,6 +301,11 @@ can skip this prompt next time using the --template option, or the --ng, --react
value: "@nativescript/template-tab-navigation-ng",
description: CreateProjectCommand.TabsTemplateDescription,
},
{
key: CreateProjectCommand.BlankVisionTemplateKey,
value: "@nativescript/template-hello-world-ng-vision",
description: CreateProjectCommand.BlankVisionTemplateDescription,
},
];

return templates;
Expand All @@ -296,6 +318,11 @@ can skip this prompt next time using the --template option, or the --ng, --react
value: constants.RESERVED_TEMPLATE_NAMES.react,
description: CreateProjectCommand.HelloWorldTemplateDescription,
},
{
key: CreateProjectCommand.BlankVisionTemplateKey,
value: "@nativescript/template-blank-react-vision",
description: CreateProjectCommand.BlankVisionTemplateDescription,
},
];

return templates;
Expand All @@ -308,6 +335,11 @@ can skip this prompt next time using the --template option, or the --ng, --react
value: constants.RESERVED_TEMPLATE_NAMES.svelte,
description: CreateProjectCommand.HelloWorldTemplateDescription,
},
{
key: CreateProjectCommand.BlankVisionTemplateKey,
value: "@nativescript/template-blank-svelte-vision",
description: CreateProjectCommand.BlankVisionTemplateDescription,
},
];

return templates;
Expand Down Expand Up @@ -335,6 +367,11 @@ can skip this prompt next time using the --template option, or the --ng, --react
value: "@nativescript/template-tab-navigation-vue",
description: CreateProjectCommand.TabsTemplateDescription,
},
{
key: CreateProjectCommand.BlankVisionTemplateKey,
value: "@nativescript/template-blank-vue-vision",
description: CreateProjectCommand.BlankVisionTemplateDescription,
},
];

return templates;
Expand All @@ -346,6 +383,33 @@ can skip this prompt next time using the --template option, or the --ng, --react

const greyDollarSign = color.grey("$");
this.$logger.clearScreen();
let runDebugNotes: Array<string> = [];
if (
this.$options.vision ||
this.$options["vision-ng"] ||
this.$options["vision-react"] ||
this.$options["vision-solid"] ||
this.$options["vision-svelte"] ||
this.$options["vision-vue"]
) {
runDebugNotes = [
`Run the project on Vision Pro with:`,
"",
` ${greyDollarSign} ${color.green("ns run visionos --no-hmr")}`,
];
} else {
runDebugNotes = [
`Run the project on multiple devices:`,
"",
` ${greyDollarSign} ${color.green("ns run ios")}`,
` ${greyDollarSign} ${color.green("ns run android")}`,
"",
"Debug the project with Chrome DevTools:",
"",
` ${greyDollarSign} ${color.green("ns debug ios")}`,
` ${greyDollarSign} ${color.green("ns debug android")}`,
];
}
this.$logger.info(
[
[
Expand All @@ -358,15 +422,7 @@ can skip this prompt next time using the --template option, or the --ng, --react
`cd ${relativePath}`
)} and then:`,
"",
`Run the project on multiple devices:`,
"",
` ${greyDollarSign} ${color.green("ns run ios")}`,
` ${greyDollarSign} ${color.green("ns run android")}`,
"",
"Debug the project with Chrome DevTools:",
"",
` ${greyDollarSign} ${color.green("ns debug ios")}`,
` ${greyDollarSign} ${color.green("ns debug android")}`,
...runDebugNotes,
``,
`For more options consult the docs or run ${color.green("ns --help")}`,
"",
Expand Down
47 changes: 37 additions & 10 deletions lib/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ injector.registerCommand("run|*all", RunCommandBase);

export class RunIosCommand implements ICommand {
@cache()
private get runCommand(): RunCommandBase {
protected get runCommand(): RunCommandBase {
const runCommand = this.$injector.resolve<RunCommandBase>(RunCommandBase);
runCommand.platform = this.platform;
return runCommand;
Expand All @@ -95,12 +95,12 @@ export class RunIosCommand implements ICommand {
}

constructor(
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $errors: IErrors,
private $injector: IInjector,
private $options: IOptions,
private $platformValidationService: IPlatformValidationService,
private $projectDataService: IProjectDataService
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
protected $errors: IErrors,
protected $injector: IInjector,
protected $options: IOptions,
protected $platformValidationService: IPlatformValidationService,
protected $projectDataService: IProjectDataService
) {}

public async execute(args: string[]): Promise<void> {
Expand All @@ -112,12 +112,12 @@ export class RunIosCommand implements ICommand {

if (
!this.$platformValidationService.isPlatformSupportedForOS(
this.$devicePlatformsConstants.iOS,
this.platform,
projectData
)
) {
this.$errors.fail(
`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`
`Applications for platform ${this.platform} can not be built on this OS`
);
}

Expand All @@ -127,7 +127,7 @@ export class RunIosCommand implements ICommand {
this.$options.provision,
this.$options.teamId,
projectData,
this.$devicePlatformsConstants.iOS.toLowerCase()
this.platform.toLowerCase()
));
return result;
}
Expand Down Expand Up @@ -196,3 +196,30 @@ export class RunAndroidCommand implements ICommand {
}

injector.registerCommand("run|android", RunAndroidCommand);

export class RunVisionOSCommand extends RunIosCommand {
public get platform(): string {
return this.$devicePlatformsConstants.visionOS;
}

constructor(
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
protected $errors: IErrors,
protected $injector: IInjector,
protected $options: IOptions,
protected $platformValidationService: IPlatformValidationService,
protected $projectDataService: IProjectDataService
) {
super(
$devicePlatformsConstants,
$errors,
$injector,
$options,
$platformValidationService,
$projectDataService
);
}
}

injector.registerCommand("run|vision", RunVisionOSCommand);
injector.registerCommand("run|visionos", RunVisionOSCommand);
11 changes: 11 additions & 0 deletions lib/common/definitions/mobile.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,10 @@ declare global {
* The state of the simulator. Can be 'Shutdown' or 'Booted'
*/
state?: string;
/**
* The platform of the device (iOS, visionOS)
*/
platform?: string;
}

interface IiOSSimResolver {
Expand Down Expand Up @@ -1192,6 +1196,8 @@ declare global {
platformNames: string[];
isAndroidPlatform(platform: string): boolean;
isiOSPlatform(platform: string): boolean;
isvisionOSPlatform(platform: string): boolean;
isApplePlatfrom(platform: string): boolean;
normalizePlatformName(platform: string): string;
validatePlatformName(platform: string): string;
buildDevicePath(...args: string[]): string;
Expand Down Expand Up @@ -1234,6 +1240,11 @@ declare global {
interface IDevicePlatformsConstants {
iOS: string;
Android: string;
visionOS: string;

isiOS(value: string): boolean;
isAndroid(value: string): boolean;
isvisionOS(value: string): boolean;
}

interface IDeviceApplication {
Expand Down
16 changes: 15 additions & 1 deletion lib/common/mobile/device-platforms-constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import { injector } from "../yok";

export class DevicePlatformsConstants
implements Mobile.IDevicePlatformsConstants {
implements Mobile.IDevicePlatformsConstants
{
public iOS = "iOS";
public Android = "Android";
public visionOS = "visionOS";

public isiOS(value: string) {
return value.toLowerCase() === this.iOS.toLowerCase();
}

public isAndroid(value: string) {
return value.toLowerCase() === this.Android.toLowerCase();
}

public isvisionOS(value: string) {
return value.toLowerCase() === this.visionOS.toLowerCase();
}
}
injector.register("devicePlatformsConstants", DevicePlatformsConstants);
14 changes: 13 additions & 1 deletion lib/common/mobile/ios/simulator/ios-emulator-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ class IosEmulatorServices implements Mobile.IiOSSimulatorService {
let error = null;

try {
if (
options.platform === this.$devicePlatformsConstants.visionOS &&
!options.emulatorIdOrName
) {
// find first available visionOS simulator (for now).
const { devices } = await this.tryGetiOSSimDevices();
options.emulatorIdOrName = devices.find(
(device) =>
device.platform === this.$devicePlatformsConstants.visionOS
)?.id;
}

await this.$iOSSimResolver.iOSSim.startSimulator({
device: options.imageIdentifier || options.emulatorIdOrName,
state: "None",
Expand Down Expand Up @@ -132,7 +144,7 @@ class IosEmulatorServices implements Mobile.IiOSSimulatorService {
isTablet: this.$mobileHelper.isiOSTablet(simDevice.name),
type: DeviceTypes.Emulator,
connectionTypes: [DeviceConnectionType.Local],
platform: this.$devicePlatformsConstants.iOS,
platform: simDevice.platform ?? this.$devicePlatformsConstants.iOS,
};
}
}
Expand Down
4 changes: 3 additions & 1 deletion lib/common/mobile/log-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export class LogFilter implements Mobile.ILogFilter {
if (platform) {
if (
platform.toLowerCase() ===
this.$devicePlatformsConstants.iOS.toLowerCase()
this.$devicePlatformsConstants.iOS.toLowerCase() ||
platform.toLowerCase() ===
this.$devicePlatformsConstants.visionOS.toLowerCase()
) {
return this.$injector.resolve("iOSLogFilter");
} else if (
Expand Down
Loading