Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-25318] Improved team-id auto-selection and allow the team-id t… #9469

Merged
merged 2 commits into from
Sep 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 47 additions & 10 deletions iphone/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,10 @@ iOSBuilder.prototype.validate = function validate(logger, config, cli) {
this.target = cli.argv.target;
this.deployType = !/^dist-/.test(this.target) && cli.argv['deploy-type'] ? cli.argv['deploy-type'] : this.deployTypes[this.target];
this.buildType = cli.argv['build-type'] || '';
this.provisioningProfileUUID = cli.argv['pp-uuid'];
if (this.provisioningProfileUUID) {
this.provisioningProfile = this.findProvisioningProfile(this.target, this.provisioningProfileUUID);
}

// add the ios specific default icon to the list of icons
this.defaultIcons.unshift(path.join(this.projectDir, 'DefaultIcon-ios.png'));
Expand Down Expand Up @@ -1993,6 +1997,36 @@ iOSBuilder.prototype.validate = function validate(logger, config, cli) {
}.bind(this));
},

function validateTeamId() {
this.teamId = this.tiapp.ios['team-id'];
if (!this.teamId) {
if (this.provisioningProfile.team.length === 1) {
// only one team, so choose this over the appPrefix
this.teamId = this.provisioningProfile.team[0];
} else {
// we have multiple teams and we don't know which one to pick, so prefer the appPrefix
this.teamId = this.provisioningProfile.appPrefix;

// if the appPrefix is not in the list of teams, then we need to fail and force the user
// to manually specify their team id
if (this.provisioningProfile.team.length && this.provisioningProfile.team.indexOf(this.teamId) === -1) {
logger.log(__('Available teams:'));
this.provisioningProfile.team.forEach(function (id) {
logger.log(' ' + id.cyan);
});
logger.log();
logger.log('<ti:app xmlns:ti="http://ti.appcelerator.org">'.grey);
logger.log(' <ios>'.grey);
logger.log(' <team-id>TEAM ID</team-id>'.magenta);
logger.log(' </ios>'.grey);
logger.log('</ti:app>'.grey);
logger.log();
process.exit(1);
}
}
}
},

function toSymlinkOrNotToSymlink() {
this.symlinkLibrariesOnCopy = config.get('ios.symlinkResources', true) && !cli.argv['force-copy'] && !cli.argv['force-copy-all'];
this.symlinkFilesOnCopy = false;
Expand Down Expand Up @@ -2308,8 +2342,8 @@ iOSBuilder.prototype.initialize = function initialize() {
}).join('|'));
this.currentBuildManifest.modulesNativeHash = this.modulesNativeHash;
this.currentBuildManifest.gitHash = ti.manifest.githash;
this.currentBuildManifest.ppUuid = this.provisioningProfileUUID = argv['pp-uuid'];
this.currentBuildManifest.outputDir = this.cli.argv['output-dir'],
this.currentBuildManifest.ppUuid = this.provisioningProfileUUID;
this.currentBuildManifest.outputDir = this.cli.argv['output-dir'];
this.currentBuildManifest.forceCopy = this.forceCopy = !!argv['force-copy'];
this.currentBuildManifest.forceCopyAll = this.forceCopyAll = !!argv['force-copy-all'];
this.currentBuildManifest.name = this.tiapp.name,
Expand Down Expand Up @@ -2378,10 +2412,6 @@ iOSBuilder.prototype.initialize = function initialize() {
this.defaultLaunchScreenStoryboard = false;
}

if (this.provisioningProfileUUID) {
this.provisioningProfile = this.findProvisioningProfile(this.target, this.provisioningProfileUUID);
}

var defaultColor = this.defaultLaunchScreenStoryboard ? 'ffffff' : null,
color = this.tiapp.ios['default-background-color'] || defaultColor;
if (color) {
Expand Down Expand Up @@ -2544,6 +2574,7 @@ iOSBuilder.prototype.loginfo = function loginfo() {
} else if (/^dist-appstore|dist\-adhoc$/.test(this.target)) {
this.logger.info(__('iOS Distribution Certificate: %s', cyan(this.certDistributionName)));
}
this.logger.info(__('Team ID: %s', this.teamId ? cyan(this.teamId) : 'n/a'.grey));

// validate the min-ios-ver from the tiapp.xml
this.logger.info(__('Minimum iOS version: %s', cyan(version.format(this.minIosVer, 2, 3))));
Expand Down Expand Up @@ -3123,7 +3154,7 @@ iOSBuilder.prototype.createXcodeProject = function createXcodeProject(next) {
var targetAttr = attr.TargetAttributes || (attr.TargetAttributes = {});
var mainTargetAttr = targetAttr[mainTargetUuid] || (targetAttr[mainTargetUuid] = {});

mainTargetAttr.DevelopmentTeam = this.provisioningProfile.appPrefix;
mainTargetAttr.DevelopmentTeam = this.teamId;

// turn on any capabilities
Object.keys(caps).forEach(function (cap) {
Expand All @@ -3150,7 +3181,7 @@ iOSBuilder.prototype.createXcodeProject = function createXcodeProject(next) {
bs.PRODUCT_BUNDLE_IDENTIFIER = '"' + this.tiapp.id + '"';

if (this.provisioningProfile) {
bs.DEVELOPMENT_TEAM = this.provisioningProfile.appPrefix;
bs.DEVELOPMENT_TEAM = this.teamId;
bs.PROVISIONING_PROFILE = '"' + this.provisioningProfile.uuid + '"';
bs.PROVISIONING_PROFILE_SPECIFIER = '"' + this.provisioningProfile.name + '"';
}
Expand Down Expand Up @@ -3310,7 +3341,7 @@ iOSBuilder.prototype.createXcodeProject = function createXcodeProject(next) {

if (this.provisioningProfile) {
var ta = pbxProject.attributes.TargetAttributes[targetUuid] || (pbxProject.attributes.TargetAttributes[targetUuid] = {});
ta.DevelopmentTeam = this.provisioningProfile.appPrefix;
ta.DevelopmentTeam = this.teamId;

Object.keys(caps).forEach(function (cap) {
ta.SystemCapabilities || (ta.SystemCapabilities = {});
Expand Down Expand Up @@ -3497,7 +3528,13 @@ iOSBuilder.prototype.createXcodeProject = function createXcodeProject(next) {
if (/device|dist\-appstore|dist\-adhoc/.test(this.target)) {
var pp = this.findProvisioningProfile(this.target, target.ppUUIDs[this.target]);
extBuildSettings.PROVISIONING_PROFILE = '"' + pp.uuid + '"';
extBuildSettings.DEVELOPMENT_TEAM = pp.appPrefix;

// NOTE: if there isn't an explicit <team-id> in the tiapp.xml and there is no
// teams or more than 1 team in the provisioning profile, then we use the appPrefix
// which should be the team id, but can differ and since we don't check it, this
// next line of code could be problematic
extBuildSettings.DEVELOPMENT_TEAM = this.teamId || (pp.team.length === 1 ? pp.team[0] : pp.appPrefix);

extBuildSettings.PROVISIONING_PROFILE_SPECIFIER = '"' + pp.name + '"';
extBuildSettings.DEPLOYMENT_POSTPROCESSING = 'YES';
if (this.keychain) {
Expand Down
8 changes: 6 additions & 2 deletions iphone/cli/hooks/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,12 @@ exports.init = function (logger, config, cli) {
exportsOptions.method = 'enterprise';
}

if (pp.appPrefix) {
exportsOptions.teamId = pp.appPrefix;
if (builder.teamId || pp.team || pp.appPrefix) {
// NOTE: if there isn't an explicit <team-id> in the tiapp.xml and there is no
// teams or more than 1 team in the provisioning profile, then we use the appPrefix
// which should be the team id, but can differ and since we don't check it, this
// next line of code could be problematic
exportsOptions.teamId = builder.teamId || (pp.team.length === 1 ? pp.team[0] : pp.appPrefix);
}
}

Expand Down