Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ 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("run|catalyst", "./commands/run");
injector.requireCommand("typings", "./commands/typings");

injector.requireCommand("preview", "./commands/preview");
Expand All @@ -198,6 +199,7 @@ 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("build|catalyst", "./commands/build");
injector.requireCommand("deploy", "./commands/deploy");

injector.requireCommand("embed", "./commands/embedding/embed");
Expand Down
58 changes: 58 additions & 0 deletions lib/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,61 @@ export class BuildVisionOsCommand extends BuildIosCommand implements ICommand {

injector.registerCommand("build|vision", BuildVisionOsCommand);
injector.registerCommand("build|visionos", BuildVisionOsCommand);

/**
* Builds the iOS target against the macOS SDK as a Mac Catalyst app.
*/
export class BuildCatalystCommand extends BuildIosCommand implements ICommand {
constructor(
protected $options: IOptions,
$errors: IErrors,
$projectData: IProjectData,
$platformsDataService: IPlatformsDataService,
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
$buildController: IBuildController,
$platformValidationService: IPlatformValidationService,
$logger: ILogger,
$buildDataService: IBuildDataService,
protected $migrateController: IMigrateController,
) {
super(
$options,
$errors,
$projectData,
$platformsDataService,
$devicePlatformsConstants,
$buildController,
$platformValidationService,
$logger,
$buildDataService,
$migrateController,
);
}

public async execute(args: string[]): Promise<void> {
await this.executeCore([
this.$devicePlatformsConstants.Catalyst.toLowerCase(),
]);
}

public async canExecute(args: string[]): Promise<boolean> {
const platform = this.$devicePlatformsConstants.Catalyst;
if (!this.$options.force) {
await this.$migrateController.validate({
projectDir: this.$projectData.projectDir,
platforms: [platform],
});
}

super.validatePlatform(platform);

let canExecute = await super.canExecuteCommandBase(platform);
if (canExecute) {
canExecute = await super.validateArgs(args, platform);
}

return canExecute;
}
}

injector.registerCommand("build|catalyst", BuildCatalystCommand);
57 changes: 43 additions & 14 deletions lib/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ export class RunCommandBase implements ICommand {
private $migrateController: IMigrateController,
private $options: IOptions,
private $projectData: IProjectData,
private $keyCommandHelper: IKeyCommandHelper
private $keyCommandHelper: IKeyCommandHelper,
) {}

public allowedParameters: ICommandParameter[] = [];
public async execute(args: string[]): Promise<void> {
await this.$liveSyncCommandHelper.executeCommandLiveSync(
this.platform,
this.liveSyncCommandHelperAdditionalOptions
this.liveSyncCommandHelperAdditionalOptions,
);

if (process.env.NS_IS_INTERACTIVE) {
this.$keyCommandHelper.attachKeyCommands(
this.platform as IKeyCommandPlatform,
"run"
"run",
);
}
}
Expand All @@ -64,7 +64,7 @@ export class RunCommandBase implements ICommand {
: [
this.$devicePlatformsConstants.Android,
this.$devicePlatformsConstants.iOS,
];
];

if (!this.$options.force) {
await this.$migrateController.validate({
Expand Down Expand Up @@ -100,7 +100,7 @@ export class RunIosCommand implements ICommand {
protected $injector: IInjector,
protected $options: IOptions,
protected $platformValidationService: IPlatformValidationService,
protected $projectDataService: IProjectDataService
protected $projectDataService: IProjectDataService,
) {}

public async execute(args: string[]): Promise<void> {
Expand All @@ -113,11 +113,11 @@ export class RunIosCommand implements ICommand {
if (
!this.$platformValidationService.isPlatformSupportedForOS(
this.platform,
projectData
projectData,
)
) {
this.$errors.fail(
`Applications for platform ${this.platform} 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.platform.toLowerCase()
this.platform.toLowerCase(),
));
return result;
}
Expand All @@ -154,7 +154,7 @@ export class RunAndroidCommand implements ICommand {
private $injector: IInjector,
private $options: IOptions,
private $platformValidationService: IPlatformValidationService,
private $projectData: IProjectData
private $projectData: IProjectData,
) {}

public async execute(args: string[]): Promise<void> {
Expand All @@ -167,11 +167,11 @@ export class RunAndroidCommand implements ICommand {
if (
!this.$platformValidationService.isPlatformSupportedForOS(
this.$devicePlatformsConstants.Android,
this.$projectData
this.$projectData,
)
) {
this.$errors.fail(
`Applications for platform ${this.$devicePlatformsConstants.Android} can not be built on this OS`
`Applications for platform ${this.$devicePlatformsConstants.Android} can not be built on this OS`,
);
}

Expand All @@ -190,7 +190,7 @@ export class RunAndroidCommand implements ICommand {
this.$options.provision,
this.$options.teamId,
this.$projectData,
this.$devicePlatformsConstants.Android.toLowerCase()
this.$devicePlatformsConstants.Android.toLowerCase(),
);
}
}
Expand All @@ -208,18 +208,47 @@ export class RunVisionOSCommand extends RunIosCommand {
protected $injector: IInjector,
protected $options: IOptions,
protected $platformValidationService: IPlatformValidationService,
protected $projectDataService: IProjectDataService
protected $projectDataService: IProjectDataService,
) {
super(
$devicePlatformsConstants,
$errors,
$injector,
$options,
$platformValidationService,
$projectDataService
$projectDataService,
);
}
}

injector.registerCommand("run|vision", RunVisionOSCommand);
injector.registerCommand("run|visionos", RunVisionOSCommand);

/**
* Runs the Mac Catalyst build of the app on this machine.
*/
export class RunCatalystCommand extends RunIosCommand {
public get platform(): string {
return this.$devicePlatformsConstants.Catalyst;
}

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|catalyst", RunCatalystCommand);
4 changes: 4 additions & 0 deletions lib/common/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ injector.require(
"iOSSimulatorDiscovery",
"./mobile/mobile-core/ios-simulator-discovery"
);
injector.require(
"macCatalystDeviceDiscovery",
"./mobile/mobile-core/mac-catalyst-discovery"
);
injector.require(
"androidDeviceDiscovery",
"./mobile/mobile-core/android-device-discovery"
Expand Down
10 changes: 10 additions & 0 deletions lib/common/definitions/mobile.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ declare global {
destroyAllSockets(): Promise<void>;
}

interface IMacCatalystDevice extends IDevice {
/**
* Absolute path of the built .app bundle this device runs and syncs into.
*/
applicationBundlePath: string;
}

interface IAndroidDevice extends IDevice {
adb: Mobile.IDeviceAndroidDebugBridge;
init(): Promise<void>;
Expand Down Expand Up @@ -1204,6 +1211,7 @@ declare global {
isAndroidPlatform(platform: string): boolean;
isiOSPlatform(platform: string): boolean;
isvisionOSPlatform(platform: string): boolean;
isCatalystPlatform(platform: string): boolean;
isApplePlatform(platform: string): boolean;
normalizePlatformName(platform: string): string;
validatePlatformName(platform: string): string;
Expand Down Expand Up @@ -1248,10 +1256,12 @@ declare global {
iOS: string;
Android: string;
visionOS: string;
Catalyst: string;

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

interface IDeviceApplication {
Expand Down
6 changes: 6 additions & 0 deletions lib/common/mobile/device-platforms-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export class DevicePlatformsConstants
public iOS = "iOS";
public Android = "Android";
public visionOS = "visionOS";
// Not a runtime of its own: iOS rebuilt against the macOS SDK.
public Catalyst = "Catalyst";

public isiOS(value: string) {
return value.toLowerCase() === this.iOS.toLowerCase();
Expand All @@ -18,5 +20,9 @@ export class DevicePlatformsConstants
public isvisionOS(value: string) {
return value.toLowerCase() === this.visionOS.toLowerCase();
}

public isCatalyst(value: string) {
return value.toLowerCase() === this.Catalyst.toLowerCase();
}
}
injector.register("devicePlatformsConstants", DevicePlatformsConstants);
Loading
Loading