Skip to content

Commit 500d751

Browse files
authored
feat(ios): ensure user defined xcconfig always takes priority (#5784)
1 parent e47cff4 commit 500d751

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

lib/definitions/ios.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ declare global {
5757
buildConfig: IBuildConfig
5858
): Promise<string[]>;
5959
getXcodeProjectArgs(
60-
projectRoot: string,
60+
platformData: IPlatformData,
6161
projectData: IProjectData
6262
): string[];
6363
}

lib/services/ios/spm-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class SPMService implements ISPMService {
7878
) {
7979
await this.$xcodebuildCommandService.executeCommand(
8080
this.$xcodebuildArgsService
81-
.getXcodeProjectArgs(platformData.projectRoot, projectData)
81+
.getXcodeProjectArgs(platformData, projectData)
8282
.concat([
8383
"-destination",
8484
"generic/platform=iOS",

lib/services/ios/xcodebuild-args-service.ts

+24-19
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class XcodebuildArgsService implements IXcodebuildArgsService {
5353
)
5454
)
5555
.concat(this.getBuildLoggingArgs())
56-
.concat(this.getXcodeProjectArgs(platformData.projectRoot, projectData));
56+
.concat(this.getXcodeProjectArgs(platformData, projectData));
5757

5858
return args;
5959
}
@@ -78,7 +78,7 @@ export class XcodebuildArgsService implements IXcodebuildArgsService {
7878
buildConfig.release ? Configurations.Release : Configurations.Debug,
7979
"-allowProvisioningUpdates",
8080
]
81-
.concat(this.getXcodeProjectArgs(platformData.projectRoot, projectData))
81+
.concat(this.getXcodeProjectArgs(platformData, projectData))
8282
.concat(architectures)
8383
.concat(
8484
this.getBuildCommonArgs(
@@ -108,38 +108,43 @@ export class XcodebuildArgsService implements IXcodebuildArgsService {
108108
}
109109

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

122+
const extraArgs: string[] = [
123+
"-scheme",
124+
projectData.projectName,
125+
skipPackageValidation,
126+
];
127+
128+
const BUILD_SETTINGS_FILE_PATH = path.join(
129+
projectData.appResourcesDirectoryPath,
130+
platformData.normalizedPlatformName,
131+
constants.BUILD_XCCONFIG_FILE_NAME
132+
);
133+
134+
if (this.$fs.exists(BUILD_SETTINGS_FILE_PATH)) {
135+
extraArgs.push("-xcconfig");
136+
extraArgs.push(BUILD_SETTINGS_FILE_PATH);
137+
}
138+
122139
if (this.$fs.exists(xcworkspacePath)) {
123-
return [
124-
"-workspace",
125-
xcworkspacePath,
126-
"-scheme",
127-
projectData.projectName,
128-
skipPackageValidation,
129-
];
140+
return ["-workspace", xcworkspacePath, ...extraArgs];
130141
}
131142

132143
const xcodeprojPath = path.join(
133-
projectRoot,
144+
platformData.projectRoot,
134145
`${projectData.projectName}.xcodeproj`
135146
);
136-
return [
137-
"-project",
138-
xcodeprojPath,
139-
"-scheme",
140-
projectData.projectName,
141-
skipPackageValidation,
142-
];
147+
return ["-project", xcodeprojPath, ...extraArgs];
143148
}
144149

145150
private getBuildLoggingArgs(): string[] {

0 commit comments

Comments
 (0)