Skip to content

fix: apple team id not being used when persisted to the platforms folder #5821

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

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 58 additions & 39 deletions lib/services/ios/ios-signing-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,17 @@ export class IOSSigningService implements IiOSSigningService {
"project.pbxproj"
);
}

private readTeamIdFromFile(projectRoot: string): string | undefined {
try {
const filePath = path.join(projectRoot, "teamid");
if (this.$fs.exists(filePath)) {
return this.$fs.readText(filePath);
}
} catch (e) {
this.$logger.trace("Unable to read file: teamid. Error is: ", e);
}
return undefined;
}
private async getDevelopmentTeam(
projectData: IProjectData,
projectRoot: string,
Expand Down Expand Up @@ -345,45 +355,54 @@ export class IOSSigningService implements IiOSSigningService {
)}. Specify team in app/App_Resources/iOS/build.xcconfig file in the following way: DEVELOPMENT_TEAM = <team id>`
);
}

const choices: string[] = [];
for (const team of teams) {
choices.push(team.name + " (" + team.id + ")");
const fromFile = this.readTeamIdFromFile(projectRoot);
if (fromFile) {
const idFromFile = teams.find((value) => value.id === fromFile);
if (idFromFile) {
teamId = idFromFile.id;
this.$logger.info(`Team Id resolved from file: '${teamId}'.`);
}
}
const choice = await this.$prompter.promptForChoice(
"Found multiple development teams, select one:",
choices
);
teamId = teams[choices.indexOf(choice)].id;

const choicesPersist = [
"Yes, set the DEVELOPMENT_TEAM setting in build.xcconfig file.",
"Yes, persist the team id in platforms folder.",
"No, don't persist this setting.",
];
const choicePersist = await this.$prompter.promptForChoice(
"Do you want to make teamId: " +
teamId +
" a persistent choice for your app?",
choicesPersist
);
switch (choicesPersist.indexOf(choicePersist)) {
case 0:
const xcconfigFile = path.join(
projectData.appResourcesDirectoryPath,
"iOS",
BUILD_XCCONFIG_FILE_NAME
);
this.$fs.appendFile(
xcconfigFile,
"\nDEVELOPMENT_TEAM = " + teamId + "\n"
);
break;
case 1:
this.$fs.writeFile(path.join(projectRoot, "teamid"), teamId);
break;
default:
break;
if (!teamId) {
const choices: string[] = [];
for (const team of teams) {
choices.push(team.name + " (" + team.id + ")");
}
const choice = await this.$prompter.promptForChoice(
"Found multiple development teams, select one:",
choices
);
teamId = teams[choices.indexOf(choice)].id;

const choicesPersist = [
"Yes, set the DEVELOPMENT_TEAM setting in build.xcconfig file.",
"Yes, persist the team id in platforms folder.",
"No, don't persist this setting.",
];
const choicePersist = await this.$prompter.promptForChoice(
"Do you want to make teamId: " +
teamId +
" a persistent choice for your app?",
choicesPersist
);
switch (choicesPersist.indexOf(choicePersist)) {
case 0:
const xcconfigFile = path.join(
projectData.appResourcesDirectoryPath,
"iOS",
BUILD_XCCONFIG_FILE_NAME
);
this.$fs.appendFile(
xcconfigFile,
"\nDEVELOPMENT_TEAM = " + teamId + "\n"
);
break;
case 1:
this.$fs.writeFile(path.join(projectRoot, "teamid"), teamId);
break;
default:
break;
}
}
}
}
Expand Down