Skip to content

Commit

Permalink
chore(build): add maccatalyst as a build target (#1701)
Browse files Browse the repository at this point in the history
* Add `maccatalyst` as a build target.

* Remove debug log.

* Fix step name.

* Fix xcode build command.
  • Loading branch information
sbruens authored Sep 25, 2023
1 parent f8f4da9 commit ac0723a
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 26 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/build_and_test_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,39 @@ jobs:
xcode_archive_path: ./output/coverage/apple/ios/TestResult.xcresult
flags: unittests, apple, ios

maccatalyst_debug_build:
name: Mac Catalyst Debug Build
runs-on: macos-13
timeout-minutes: 20
needs: web_test
steps:
- name: Display XCode
run: xcode-select --print-path

- name: Checkout
uses: actions/[email protected]

- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm

- name: Install NPM Dependencies
run: npm ci

- name: Test OutlineAppleLib
run: npm run action cordova/test maccatalyst

- name: Build Mac Catalyst Client
run: npm run action cordova/build maccatalyst

- uses: codecov/codecov-action@v3
with:
xcode: true
xcode_archive_path: ./output/coverage/apple/maccatalyst/TestResult.xcresult
flags: unittests, apple, maccatalyst

android_debug_build:
name: Android Debug Build
runs-on: ubuntu-20.04
Expand Down
2 changes: 1 addition & 1 deletion src/build/get_build_parameters.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import minimist from 'minimist';

const VALID_PLATFORMS = ['linux', 'windows', 'ios', 'macos', 'android', 'browser'];
const VALID_PLATFORMS = ['linux', 'windows', 'ios', 'macos', 'maccatalyst', 'android', 'browser'];
const VALID_BUILD_MODES = ['debug', 'release'];

const MS_PER_HOUR = 1000 * 60 * 60;
Expand Down
6 changes: 3 additions & 3 deletions src/cordova/apple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You will need:

The XCode project is created by Cordova. To create the project and open it on XCode, use `npm run action cordova/setup $PLATFORM`, then open the XCode workspace file (not the project).

For the **iOS** client:
For the **iOS** client and **Mac Catalyst** client:

```sh
npm run action cordova/build ios && open ./src/cordova/apple/ios.xcworkspace
Expand Down Expand Up @@ -138,7 +138,7 @@ You can kill the app and extension with the [`pkill` command](https://man7.org/l
pkill -9 Outline VpnExtension
```

Sometimes the processes will not die, even with `-9`. For the Outline process, you may need to kill its parent process, usually `debugserver`.
Sometimes the processes will not die, even with `-9`. For the Outline process, you may need to kill its parent process, usually `debugserver`.

You can check running processes with the [`pgrep` command](https://man7.org/linux/man-pages/man1/pgrep.1.html):
```sh
Expand Down Expand Up @@ -185,7 +185,7 @@ You may want to also delete the VPN configurations:
1. Press *Remove Configuration…* and confirm


#### Restart
#### Restart

If all fails, restart your device. That usually takes care of the issue.

Expand Down
52 changes: 32 additions & 20 deletions src/cordova/build.action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {getBuildParameters} from '../build/get_build_parameters.mjs';
import {downloadHttpsFile} from '../build/download_file.mjs';

/**
* @description Builds the parameterized cordova binary (ios, macos, android).
* @description Builds the parameterized cordova binary (ios, macos, maccatalyst, android).
*
* @param {string[]} parameters
*/
Expand Down Expand Up @@ -62,25 +62,49 @@ export async function main(...parameters) {
);
case 'ios' + 'debug':
case 'macos' + 'debug':
case 'maccatalyst' + 'debug':
return appleDebug(platform);
case 'ios' + 'release':
case 'macos' + 'release':
case 'maccatalyst' + 'release':
return appleRelease(platform);
}
}

function getXcodeBuildArgs(platform) {
let destination, workspaceFilename;
switch (platform) {
case 'macos':
destination = 'generic/platform=macOS';
workspaceFilename = 'macos.xcworkspace';
break;
case 'maccatalyst':
destination = 'generic/platform=macOS,variant=Mac Catalyst';
workspaceFilename = 'ios.xcworkspace';
break;
case 'ios':
default:
destination = 'generic/platform=iOS';
workspaceFilename = 'ios.xcworkspace';
break;
}
return [
'-workspace',
path.join(getRootDir(), 'src', 'cordova', 'apple', workspaceFilename),
'-scheme',
'Outline',
'-destination',
destination,
];
}

async function appleDebug(platform) {
console.warn(`WARNING: building "${platform}" in [DEBUG] mode. Do not publish this build!!`);

return spawnStream(
'xcodebuild',
'clean',
'-workspace',
path.join(getRootDir(), 'src', 'cordova', 'apple', `${platform}.xcworkspace`),
'-scheme',
'Outline',
'-destination',
platform === 'ios' ? 'generic/platform=iOS' : 'generic/platform=macOS',
...getXcodeBuildArgs(platform),
'build',
'-configuration',
'Debug',
Expand All @@ -90,19 +114,7 @@ async function appleDebug(platform) {
}

async function appleRelease(platform) {
return spawnStream(
'xcodebuild',
'clean',
'-workspace',
path.join(getRootDir(), 'src', 'cordova', 'apple', `${platform}.xcworkspace`),
'-scheme',
'Outline',
'-destination',
platform === 'ios' ? 'generic/platform=iOS' : 'generic/platform=macOS',
'archive',
'-configuration',
'Release'
);
return spawnStream('xcodebuild', 'clean', ...getXcodeBuildArgs(platform), 'archive', '-configuration', 'Release');
}

async function androidDebug(verbose) {
Expand Down
2 changes: 2 additions & 0 deletions src/cordova/setup.action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ export async function main(...parameters) {
console.warn('NOTE: You must open the Outline.zip file after building to upload to the Play Store.');
return androidRelease(versionName, buildNumber, verbose);
case 'ios' + 'debug':
case 'maccatalyst' + 'debug':
return appleIosDebug(verbose);
case 'macos' + 'debug':
return appleMacOsDebug(verbose);
case 'ios' + 'release':
case 'maccatalyst' + 'release':
return appleIosRelease(versionName, buildNumber, verbose);
case 'macos' + 'release':
return appleMacOsRelease(versionName, buildNumber, verbose);
Expand Down
6 changes: 4 additions & 2 deletions src/cordova/test.action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {spawnStream} from '../build/spawn_stream.mjs';
const APPLE_ROOT = path.join(getRootDir(), 'src', 'cordova', 'apple');
const APPLE_LIBRARY_NAME = 'OutlineAppleLib';

const SUPPORTED_PLATFORMS = new Set(['ios', 'macos', 'maccatalyst']);

/**
* @description Tests the parameterized cordova binary (ios, macos).
*
Expand All @@ -35,8 +37,8 @@ export async function main(...parameters) {
_: [outlinePlatform],
} = minimist(parameters);

if (outlinePlatform !== 'macos' && outlinePlatform !== 'ios') {
throw new Error('Testing is only currently supported for Apple platforms.');
if (!SUPPORTED_PLATFORMS.has(outlinePlatform)) {
throw new Error('Testing is only currently supported for platforms: ' + Array.from(SUPPORTED_PLATFORMS));
}

if (os.platform() !== 'darwin') {
Expand Down

0 comments on commit ac0723a

Please sign in to comment.