Skip to content

Commit 7d1e3ad

Browse files
refactor build settings gathering
1 parent aec29ac commit 7d1e3ad

5 files changed

Lines changed: 24 additions & 54 deletions

File tree

action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ inputs:
88
description: The version of Xcode to use for building the Xcode project. Defaults to the active version of Xcode on the runner.
99
required: false
1010
default: latest
11-
platform-sdk-version:
12-
description: The version of the platform SDK to use for building the Xcode project. Defaults to the latest version of the platform SDK defined in the `.xcodeproj`.
13-
required: false
1411
project-path:
1512
description: The directory that contains the exported xcode project from Unity.
1613
required: true
@@ -57,6 +54,9 @@ inputs:
5754
platform:
5855
description: The platform to build for. Can be one of `iOS`, `macOS`, `visionOS`, `tvOS`. Defaults to parsing platform from `.xcodeproj`.
5956
required: false
57+
platform-sdk-version:
58+
description: The version of the platform SDK to use for building the Xcode project. Defaults to the latest version of the platform SDK defined in the `.xcodeproj`.
59+
required: false
6060
export-option:
6161
description: The export option to use for exporting the Xcode project. Can be one of `app-store-connect`, `steam`, `release-testing`, `package`, `enterprise`, `debugging`, `developer-id`, `mac-application`.
6262
required: false

dist/index.js

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -58024,7 +58024,7 @@ async function GetProjectDetails(credential, xcodeVersion) {
5802458024
core.info(`Project directory: ${projectDirectory}`);
5802558025
const projectName = path.basename(projectPath, '.xcodeproj');
5802658026
const scheme = await getProjectScheme(projectPath);
58027-
const [platform, bundleId] = await parseBuildSettings(projectPath, scheme);
58027+
const [platform, bundleId] = await parseBuildSettings(projectPath);
5802858028
core.info(`Platform: ${platform}`);
5802958029
if (!platform) {
5803058030
throw new Error('Unable to determine the platform to build for.');
@@ -58087,36 +58087,20 @@ async function GetProjectDetails(credential, xcodeVersion) {
5808758087
core.info(`----- Info.plist content: -----\n${infoPlistContent}\n-----------------------------------`);
5808858088
return projectRef;
5808958089
}
58090-
async function parseBuildSettings(projectPath, scheme) {
58091-
let buildSettingsOutput = '';
58092-
let platformSdkVersion = core.getInput('platform-sdk-version') || null;
58093-
const projectSettingsArgs = [
58094-
'build',
58095-
'-project', projectPath,
58096-
'-scheme', scheme,
58097-
'-showBuildSettings'
58098-
];
58099-
if (!core.isDebug()) {
58100-
core.info(`[command]${xcodebuild} ${projectSettingsArgs.join(' ')}`);
58101-
}
58102-
await (0, exec_1.exec)(xcodebuild, projectSettingsArgs, {
58103-
listeners: {
58104-
stdout: (data) => {
58105-
buildSettingsOutput += data.toString();
58106-
}
58107-
},
58108-
silent: !core.isDebug()
58109-
});
58110-
const platformName = core.getInput('platform') || matchRegexPattern(buildSettingsOutput, /\s+PLATFORM_NAME = (?<platformName>\w+)/, 'platformName');
58090+
async function parseBuildSettings(projectPath) {
58091+
await fs.promises.access(projectPath, fs.constants.R_OK);
58092+
const xCodeProjContent = await fs.promises.readFile(projectPath, 'utf8');
58093+
const platformName = core.getInput('platform') || matchRegexPattern(xCodeProjContent, /\s+PLATFORM_NAME = (?<platformName>\w+)/, 'platformName');
5811158094
if (!platformName) {
5811258095
throw new Error('Unable to determine the platform name from the build settings');
5811358096
}
58114-
const bundleId = core.getInput('bundle-id') || matchRegexPattern(buildSettingsOutput, /\s+PRODUCT_BUNDLE_IDENTIFIER = (?<bundleId>[\w.-]+)/, 'bundleId');
58097+
const bundleId = core.getInput('bundle-id') || matchRegexPattern(xCodeProjContent, /\s+PRODUCT_BUNDLE_IDENTIFIER = (?<bundleId>[\w.-]+)/, 'bundleId');
5811558098
if (!bundleId || bundleId === 'NO') {
5811658099
throw new Error('Unable to determine the bundle ID from the build settings');
5811758100
}
58101+
let platformSdkVersion = core.getInput('platform-sdk-version') || null;
5811858102
if (!platformSdkVersion) {
58119-
platformSdkVersion = matchRegexPattern(buildSettingsOutput, /\s+SDK_VERSION = (?<sdkVersion>[\d.]+)/, 'sdkVersion') || null;
58103+
platformSdkVersion = matchRegexPattern(xCodeProjContent, /\s+SDK_VERSION = (?<sdkVersion>[\d.]+)/, 'sdkVersion') || null;
5812058104
}
5812158105
const platforms = {
5812258106
'iphoneos': 'iOS',
@@ -60674,11 +60658,12 @@ const main = async () => {
6067460658
let xcodeVersionString = core.getInput('xcode-version');
6067560659
if (xcodeVersionString) {
6067660660
core.info(`Setting xcode version to ${xcodeVersionString}`);
60661+
await exec.exec('xcodes', ['list']);
6067760662
if (xcodeVersionString.includes('latest')) {
6067860663
await exec.exec('xcodes', ['install', '--latest', '--select']);
6067960664
}
6068060665
else {
60681-
await exec.exec('xcodes', ['select', xcodeVersionString]);
60666+
await exec.exec('xcodes', ['install', xcodeVersionString, '--select']);
6068260667
}
6068360668
}
6068460669
let xcodeVersionOutput = '';

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ const main = async () => {
2323
let xcodeVersionString = core.getInput('xcode-version');
2424
if (xcodeVersionString) {
2525
core.info(`Setting xcode version to ${xcodeVersionString}`);
26+
await exec.exec('xcodes', ['list']);
2627
if (xcodeVersionString.includes('latest')) {
2728
await exec.exec('xcodes', ['install', '--latest', '--select']);
2829
} else {
29-
await exec.exec('xcodes', ['select', xcodeVersionString]);
30+
await exec.exec('xcodes', ['install', xcodeVersionString, '--select']);
3031
}
3132
}
3233
let xcodeVersionOutput = '';

src/xcode.ts

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
4848
core.info(`Project directory: ${projectDirectory}`);
4949
const projectName = path.basename(projectPath, '.xcodeproj');
5050
const scheme = await getProjectScheme(projectPath);
51-
const [platform, bundleId] = await parseBuildSettings(projectPath, scheme);
51+
const [platform, bundleId] = await parseBuildSettings(projectPath);
5252
core.info(`Platform: ${platform}`);
5353
if (!platform) {
5454
throw new Error('Unable to determine the platform to build for.');
@@ -119,36 +119,20 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
119119
return projectRef;
120120
}
121121

122-
async function parseBuildSettings(projectPath: string, scheme: string): Promise<[string, string]> {
123-
let buildSettingsOutput = '';
124-
let platformSdkVersion = core.getInput('platform-sdk-version') || null;
125-
const projectSettingsArgs = [
126-
'build',
127-
'-project', projectPath,
128-
'-scheme', scheme,
129-
'-showBuildSettings'
130-
];
131-
if (!core.isDebug()) {
132-
core.info(`[command]${xcodebuild} ${projectSettingsArgs.join(' ')}`);
133-
}
134-
await exec(xcodebuild, projectSettingsArgs, {
135-
listeners: {
136-
stdout: (data: Buffer) => {
137-
buildSettingsOutput += data.toString();
138-
}
139-
},
140-
silent: !core.isDebug()
141-
});
142-
const platformName = core.getInput('platform') || matchRegexPattern(buildSettingsOutput, /\s+PLATFORM_NAME = (?<platformName>\w+)/, 'platformName');
122+
async function parseBuildSettings(projectPath: string): Promise<[string, string]> {
123+
await fs.promises.access(projectPath, fs.constants.R_OK);
124+
const xCodeProjContent = await fs.promises.readFile(projectPath, 'utf8');
125+
const platformName = core.getInput('platform') || matchRegexPattern(xCodeProjContent, /\s+PLATFORM_NAME = (?<platformName>\w+)/, 'platformName');
143126
if (!platformName) {
144127
throw new Error('Unable to determine the platform name from the build settings');
145128
}
146-
const bundleId = core.getInput('bundle-id') || matchRegexPattern(buildSettingsOutput, /\s+PRODUCT_BUNDLE_IDENTIFIER = (?<bundleId>[\w.-]+)/, 'bundleId');
129+
const bundleId = core.getInput('bundle-id') || matchRegexPattern(xCodeProjContent, /\s+PRODUCT_BUNDLE_IDENTIFIER = (?<bundleId>[\w.-]+)/, 'bundleId');
147130
if (!bundleId || bundleId === 'NO') {
148131
throw new Error('Unable to determine the bundle ID from the build settings');
149132
}
133+
let platformSdkVersion = core.getInput('platform-sdk-version') || null;
150134
if (!platformSdkVersion) {
151-
platformSdkVersion = matchRegexPattern(buildSettingsOutput, /\s+SDK_VERSION = (?<sdkVersion>[\d.]+)/, 'sdkVersion') || null;
135+
platformSdkVersion = matchRegexPattern(xCodeProjContent, /\s+SDK_VERSION = (?<sdkVersion>[\d.]+)/, 'sdkVersion') || null;
152136
}
153137
const platforms = {
154138
'iphoneos': 'iOS',

0 commit comments

Comments
 (0)