Skip to content

Commit

Permalink
fix: Provide signing arguments as command line parameters (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Sep 22, 2023
1 parent 40a81eb commit 51ba527
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
16 changes: 2 additions & 14 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fs, tempDir, plist } from '@appium/support';
import { fs, plist } from '@appium/support';
import { exec } from 'teen_process';
import path from 'path';
import log from './logger';
Expand Down Expand Up @@ -157,18 +157,6 @@ async function setRealDeviceSecurity (keychainPath, keychainPassword) {
await exec('security', ['set-keychain-settings', '-t', '3600', '-l', keychainPath]);
}

async function generateXcodeConfigFile (orgId, signingId) {
log.debug(`Generating xcode config file for orgId '${orgId}' and signingId ` +
`'${signingId}'`);
const contents = `DEVELOPMENT_TEAM = ${orgId}
CODE_SIGN_IDENTITY = ${signingId}
`;
const xcconfigPath = await tempDir.path('appium-temp.xcconfig');
log.debug(`Writing xcode config file to ${xcconfigPath}`);
await fs.writeFile(xcconfigPath, contents, 'utf8');
return xcconfigPath;
}

/**
* Information of the device under test
* @typedef {Object} DeviceInfo
Expand Down Expand Up @@ -394,7 +382,7 @@ async function getPIDsListeningOnPort (port, filteringFunc = null) {
}

export { updateProjectFile, resetProjectFile, setRealDeviceSecurity,
getAdditionalRunContent, getXctestrunFileName, generateXcodeConfigFile,
getAdditionalRunContent, getXctestrunFileName,
setXctestrunFile, getXctestrunFilePath, killProcess, randomInt,
getWDAUpgradeTimestamp, resetTestProcesses,
getPIDsListeningOnPort, killAppUsingPattern, isTvOS
Expand Down
19 changes: 12 additions & 7 deletions lib/xcodebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fs, logger, timing } from '@appium/support';
import defaultLogger from './logger';
import B from 'bluebird';
import {
setRealDeviceSecurity, generateXcodeConfigFile, setXctestrunFile,
setRealDeviceSecurity, setXctestrunFile,
updateProjectFile, resetProjectFile, killProcess,
getWDAUpgradeTimestamp, isTvOS } from './utils';
import _ from 'lodash';
Expand Down Expand Up @@ -238,9 +238,17 @@ class XcodeBuild {
'Will build for the default platform instead');
}

if (this.realDevice && this.xcodeConfigFile) {
this.log.debug(`Using Xcode configuration file: '${this.xcodeConfigFile}'`);
args.push('-xcconfig', this.xcodeConfigFile);
if (this.realDevice) {
if (this.xcodeConfigFile) {
this.log.debug(`Using Xcode configuration file: '${this.xcodeConfigFile}'`);
args.push('-xcconfig', this.xcodeConfigFile);
}
if (this.xcodeOrgId && this.xcodeSigningId) {
args.push(
`DEVELOPMENT_TEAM=${this.xcodeOrgId}`,
`CODE_SIGN_IDENTITY=${this.xcodeSigningId}`,
);
}
}

if (!process.env.APPIUM_XCUITEST_TREAT_WARNINGS_AS_ERRORS) {
Expand All @@ -260,9 +268,6 @@ class XcodeBuild {
if (this.keychainPath && this.keychainPassword) {
await setRealDeviceSecurity(this.keychainPath, this.keychainPassword);
}
if (this.xcodeOrgId && this.xcodeSigningId && !this.xcodeConfigFile) {
this.xcodeConfigFile = await generateXcodeConfigFile(this.xcodeOrgId, this.xcodeSigningId);
}
}

const {cmd, args} = this.getCommand(buildOnly);
Expand Down

0 comments on commit 51ba527

Please sign in to comment.