Skip to content

Commit 2caefb4

Browse files
more refactoring
1 parent dfc0758 commit 2caefb4

4 files changed

Lines changed: 22 additions & 21 deletions

File tree

dist/index.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57910,10 +57910,11 @@ async function RemoveCredentials() {
5791057910
Object.defineProperty(exports, "__esModule", ({ value: true }));
5791157911
exports.XcodeProject = void 0;
5791257912
class XcodeProject {
57913-
constructor(projectPath, projectName, platform, bundleId, projectDirectory, versionString, bundleVersion, scheme, credential, xcodeVersion) {
57913+
constructor(projectPath, projectName, platform, destination, bundleId, projectDirectory, versionString, bundleVersion, scheme, credential, xcodeVersion) {
5791457914
this.projectPath = projectPath;
5791557915
this.projectName = projectName;
5791657916
this.platform = platform;
57917+
this.destination = destination;
5791757918
this.bundleId = bundleId;
5791857919
this.projectDirectory = projectDirectory;
5791957920
this.versionString = versionString;
@@ -58040,7 +58041,9 @@ async function GetProjectDetails(credential, xcodeVersion) {
5804058041
if (!bundleId) {
5804158042
throw new Error('Unable to determine the bundle ID');
5804258043
}
58043-
await getPlatformSdkVersion(projectPath, scheme, platform);
58044+
const destination = core.getInput('destination') || `generic/platform=${platform}`;
58045+
core.debug(`Using destination: ${destination}`);
58046+
await getPlatformSdkVersion(projectPath, scheme, platform, destination);
5804458047
let infoPlistPath = `${projectDirectory}/${projectName}/Info.plist`;
5804558048
if (!fs.existsSync(infoPlistPath)) {
5804658049
infoPlistPath = `${projectDirectory}/Info.plist`;
@@ -58059,7 +58062,7 @@ async function GetProjectDetails(credential, xcodeVersion) {
5805958062
core.info(`CFBundleShortVersionString: ${cFBundleShortVersionString}`);
5806058063
const cFBundleVersion = infoPlist['CFBundleVersion'];
5806158064
core.info(`CFBundleVersion: ${cFBundleVersion}`);
58062-
const projectRef = new XcodeProject_1.XcodeProject(projectPath, projectName, platform, bundleId, projectDirectory, cFBundleShortVersionString, cFBundleVersion, scheme, credential, xcodeVersion);
58065+
const projectRef = new XcodeProject_1.XcodeProject(projectPath, projectName, platform, destination, bundleId, projectDirectory, cFBundleShortVersionString, cFBundleVersion, scheme, credential, xcodeVersion);
5806358066
await getExportOptions(projectRef);
5806458067
if (projectRef.isAppStoreUpload() && core.getInput('auto-increment-build-number') === 'true') {
5806558068
projectRef.credential.appleId = await getAppId(projectRef);
@@ -58110,13 +58113,14 @@ async function parseBuildSettings(projectPath) {
5811058113
}
5811158114
return [platformMap[platform], bundleId];
5811258115
}
58113-
async function getPlatformSdkVersion(projectPath, scheme, platform) {
58116+
async function getPlatformSdkVersion(projectPath, scheme, platform, destination) {
58117+
await (0, exec_1.exec)(xcodebuild, ['-downloadPlatform', platform]);
5811458118
let buildSettingsOutput = '';
5811558119
const projectSettingsArgs = [
5811658120
'build',
5811758121
'-project', projectPath,
5811858122
'-scheme', scheme,
58119-
'-destination', `generic/platform=${platform}`,
58123+
'-destination', destination,
5812058124
'-showBuildSettings'
5812158125
];
5812258126
if (!core.isDebug()) {
@@ -58190,16 +58194,11 @@ async function downloadPlatformSdkIfMissing(platform, version) {
5819058194
if (version) {
5819158195
await (0, exec_1.exec)('xcodes', ['runtimes', 'install', `${platform} ${version}`]);
5819258196
}
58193-
else {
58194-
await (0, exec_1.exec)(xcodebuild, ['-downloadPlatform', platform]);
58195-
}
5819658197
}
5819758198
async function ArchiveXcodeProject(projectRef) {
5819858199
const { projectPath, projectName, projectDirectory } = projectRef;
5819958200
const archivePath = `${projectDirectory}/${projectName}.xcarchive`;
5820058201
core.debug(`Archive path: ${archivePath}`);
58201-
let destination = core.getInput('destination') || `generic/platform=${projectRef.platform}`;
58202-
core.debug(`Using destination: ${destination}`);
5820358202
const configuration = core.getInput('configuration') || 'Release';
5820458203
core.debug(`Configuration: ${configuration}`);
5820558204
let entitlementsPath = core.getInput('entitlements-plist');
@@ -58213,7 +58212,7 @@ async function ArchiveXcodeProject(projectRef) {
5821358212
'archive',
5821458213
'-project', projectPath,
5821558214
'-scheme', projectRef.scheme,
58216-
'-destination', destination,
58215+
'-destination', projectRef.destination,
5821758216
'-configuration', configuration,
5821858217
'-archivePath', archivePath,
5821958218
`-authenticationKeyID`, projectRef.credential.appStoreConnectKeyId,

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/XcodeProject.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export class XcodeProject {
66
projectPath: string,
77
projectName: string,
88
platform: string,
9+
destination: string,
910
bundleId: string,
1011
projectDirectory: string,
1112
versionString: string,
@@ -17,6 +18,7 @@ export class XcodeProject {
1718
this.projectPath = projectPath;
1819
this.projectName = projectName;
1920
this.platform = platform;
21+
this.destination = destination;
2022
this.bundleId = bundleId;
2123
this.projectDirectory = projectDirectory;
2224
this.versionString = versionString;
@@ -31,6 +33,7 @@ export class XcodeProject {
3133
projectDirectory: string;
3234
credential: AppleCredential;
3335
platform: string;
36+
destination: string;
3437
archivePath: string;
3538
exportPath: string;
3639
executablePath: string;

src/xcode.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
6464
if (!bundleId) {
6565
throw new Error('Unable to determine the bundle ID');
6666
}
67-
await getPlatformSdkVersion(projectPath, scheme, platform);
67+
const destination = core.getInput('destination') || `generic/platform=${platform}`;
68+
core.debug(`Using destination: ${destination}`);
69+
await getPlatformSdkVersion(projectPath, scheme, platform, destination);
6870
let infoPlistPath = `${projectDirectory}/${projectName}/Info.plist`;
6971
if (!fs.existsSync(infoPlistPath)) {
7072
infoPlistPath = `${projectDirectory}/Info.plist`;
@@ -86,6 +88,7 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
8688
projectPath,
8789
projectName,
8890
platform,
91+
destination,
8992
bundleId,
9093
projectDirectory,
9194
cFBundleShortVersionString,
@@ -143,13 +146,14 @@ async function parseBuildSettings(projectPath: string): Promise<[string, string]
143146
return [platformMap[platform], bundleId];
144147
}
145148

146-
async function getPlatformSdkVersion(projectPath: string, scheme: string, platform: string) {
149+
async function getPlatformSdkVersion(projectPath: string, scheme: string, platform: string, destination: string): Promise<void> {
150+
await exec(xcodebuild, ['-downloadPlatform', platform]);
147151
let buildSettingsOutput = '';
148152
const projectSettingsArgs = [
149153
'build',
150154
'-project', projectPath,
151155
'-scheme', scheme,
152-
'-destination', `generic/platform=${platform}`,
156+
'-destination', destination,
153157
'-showBuildSettings'
154158
];
155159
if (!core.isDebug()) {
@@ -223,17 +227,12 @@ async function downloadPlatformSdkIfMissing(platform: string, version: string |
223227
if (version) {
224228
await exec('xcodes', ['runtimes', 'install', `${platform} ${version}`]);
225229
}
226-
else {
227-
await exec(xcodebuild, ['-downloadPlatform', platform]);
228-
}
229230
}
230231

231232
export async function ArchiveXcodeProject(projectRef: XcodeProject): Promise<XcodeProject> {
232233
const { projectPath, projectName, projectDirectory } = projectRef;
233234
const archivePath = `${projectDirectory}/${projectName}.xcarchive`;
234235
core.debug(`Archive path: ${archivePath}`);
235-
let destination = core.getInput('destination') || `generic/platform=${projectRef.platform}`;
236-
core.debug(`Using destination: ${destination}`);
237236
const configuration = core.getInput('configuration') || 'Release';
238237
core.debug(`Configuration: ${configuration}`);
239238
let entitlementsPath = core.getInput('entitlements-plist');
@@ -246,7 +245,7 @@ export async function ArchiveXcodeProject(projectRef: XcodeProject): Promise<Xco
246245
'archive',
247246
'-project', projectPath,
248247
'-scheme', projectRef.scheme,
249-
'-destination', destination,
248+
'-destination', projectRef.destination,
250249
'-configuration', configuration,
251250
'-archivePath', archivePath,
252251
`-authenticationKeyID`, projectRef.credential.appStoreConnectKeyId,

0 commit comments

Comments
 (0)