Skip to content

Commit

Permalink
feat!: Partial support for Catalyst builds
Browse files Browse the repository at this point in the history
`cordova build ios --device --target=mac ...`

Output is to `build/Debug-maccatalyst`

No support for `cordova run`
No support for code signing(?)
  • Loading branch information
dpogue committed Jun 4, 2023
1 parent 58df099 commit 1264e9a
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ module.exports.run = function (buildOpts) {
return Promise.reject(new CordovaError('Cannot specify "device" and "emulator" options together.'));
}

if (buildOpts.target && buildOpts.target.match(/mac/i)) {
buildOpts.catalyst = true;
}

if (buildOpts.buildConfig) {
if (!fs.existsSync(buildOpts.buildConfig)) {
return Promise.reject(new CordovaError(`Build config file does not exist: ${buildOpts.buildConfig}`));
Expand Down Expand Up @@ -223,7 +227,7 @@ module.exports.run = function (buildOpts) {
const xcodebuildArgs = getXcodeBuildArgs(projectName, projectPath, configuration, emulatorTarget, buildOpts);
return execa('xcodebuild', xcodebuildArgs, { cwd: projectPath, stdio: 'inherit' });
}).then(() => {
if (!buildOpts.device || buildOpts.noSign) {
if (!buildOpts.device || buildOpts.catalyst || buildOpts.noSign) {
return;
}

Expand Down Expand Up @@ -334,7 +338,7 @@ function getXcodeBuildArgs (projectName, projectPath, configuration, emulatorTar
}
}

if (buildConfig.device) {
if (buildConfig.device && !buildConfig.catalyst) {
options = [
'-workspace', customArgs.workspace || `${projectName}.xcworkspace`,
'-scheme', customArgs.scheme || projectName,
Expand Down Expand Up @@ -375,10 +379,20 @@ function getXcodeBuildArgs (projectName, projectPath, configuration, emulatorTar
options = [
'-workspace', customArgs.workspace || `${projectName}.xcworkspace`,
'-scheme', customArgs.scheme || projectName,
'-configuration', customArgs.configuration || configuration,
'-sdk', customArgs.sdk || 'iphonesimulator',
'-destination', customArgs.destination || `platform=iOS Simulator,name=${emulatorTarget}`
'-configuration', customArgs.configuration || configuration
];

if (buildConfig.catalyst) {
options = options.concat([
'-destination', customArgs.destination || 'generic/platform=macOS,variant=Mac Catalyst'
]);
} else {
options = options.concat([
'-sdk', customArgs.sdk || 'iphonesimulator',
'-destination', customArgs.destination || `platform=iOS Simulator,name=${emulatorTarget}`
]);
}

buildActions = ['build'];
settings = [`SYMROOT=${path.join(projectPath, 'build')}`];

Expand Down

0 comments on commit 1264e9a

Please sign in to comment.