Skip to content

Commit

Permalink
feat(ios): ensure user defined xcconfig always takes priority (#5784)
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanWalker committed Feb 1, 2024
1 parent e47cff4 commit 500d751
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/definitions/ios.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ declare global {
buildConfig: IBuildConfig
): Promise<string[]>;
getXcodeProjectArgs(
projectRoot: string,
platformData: IPlatformData,
projectData: IProjectData
): string[];
}
Expand Down
2 changes: 1 addition & 1 deletion lib/services/ios/spm-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class SPMService implements ISPMService {
) {
await this.$xcodebuildCommandService.executeCommand(
this.$xcodebuildArgsService
.getXcodeProjectArgs(platformData.projectRoot, projectData)
.getXcodeProjectArgs(platformData, projectData)
.concat([
"-destination",
"generic/platform=iOS",
Expand Down
43 changes: 24 additions & 19 deletions lib/services/ios/xcodebuild-args-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class XcodebuildArgsService implements IXcodebuildArgsService {
)
)
.concat(this.getBuildLoggingArgs())
.concat(this.getXcodeProjectArgs(platformData.projectRoot, projectData));
.concat(this.getXcodeProjectArgs(platformData, projectData));

return args;
}
Expand All @@ -78,7 +78,7 @@ export class XcodebuildArgsService implements IXcodebuildArgsService {
buildConfig.release ? Configurations.Release : Configurations.Debug,
"-allowProvisioningUpdates",
]
.concat(this.getXcodeProjectArgs(platformData.projectRoot, projectData))
.concat(this.getXcodeProjectArgs(platformData, projectData))
.concat(architectures)
.concat(
this.getBuildCommonArgs(
Expand Down Expand Up @@ -108,38 +108,43 @@ export class XcodebuildArgsService implements IXcodebuildArgsService {
}

public getXcodeProjectArgs(
projectRoot: string,
platformData: IPlatformData,
projectData: IProjectData
): string[] {
const xcworkspacePath = path.join(
projectRoot,
platformData.projectRoot,
`${projectData.projectName}.xcworkspace`
);
// Introduced in Xcode 14+
// ref: https://forums.swift.org/t/telling-xcode-14-beta-4-to-trust-build-tool-plugins-programatically/59305/5
const skipPackageValidation = "-skipPackagePluginValidation";

const extraArgs: string[] = [
"-scheme",
projectData.projectName,
skipPackageValidation,
];

const BUILD_SETTINGS_FILE_PATH = path.join(
projectData.appResourcesDirectoryPath,
platformData.normalizedPlatformName,
constants.BUILD_XCCONFIG_FILE_NAME
);

if (this.$fs.exists(BUILD_SETTINGS_FILE_PATH)) {
extraArgs.push("-xcconfig");
extraArgs.push(BUILD_SETTINGS_FILE_PATH);
}

if (this.$fs.exists(xcworkspacePath)) {
return [
"-workspace",
xcworkspacePath,
"-scheme",
projectData.projectName,
skipPackageValidation,
];
return ["-workspace", xcworkspacePath, ...extraArgs];
}

const xcodeprojPath = path.join(
projectRoot,
platformData.projectRoot,
`${projectData.projectName}.xcodeproj`
);
return [
"-project",
xcodeprojPath,
"-scheme",
projectData.projectName,
skipPackageValidation,
];
return ["-project", xcodeprojPath, ...extraArgs];
}

private getBuildLoggingArgs(): string[] {
Expand Down

0 comments on commit 500d751

Please sign in to comment.