Skip to content

Commit bfd5b3f

Browse files
fix: build with Xcode 10 may fail for missing plugins...xcconfig file
In the iOS Project template we have include for plugins-debug.xcconfig (or plugins-release.xcconfig when building in release mode). CLI should produce such file, but it does not do it when the project does not have build.xcconfig in its App_Resources and neither of the plugins have such file. With previous Xcode versions, this case was leading to warnings in the output, however they are errors now and the build fails. Fix this by adding an empty file in such case.
1 parent 2abae5f commit bfd5b3f

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

lib/services/ios-project-service.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,13 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
13011301
await this.mergeXcconfigFiles(appResourcesXcconfigPath, pluginsXcconfigFilePath);
13021302
}
13031303

1304+
if (!this.$fs.exists(pluginsXcconfigFilePath)) {
1305+
// We need the pluginsXcconfig file to exist in platforms dir as it is required in the native template:
1306+
// https://github.com/NativeScript/ios-runtime/blob/9c2b7b5f70b9bee8452b7a24aa6b646214c7d2be/build/project-template/__PROJECT_NAME__/build-debug.xcconfig#L3
1307+
// From Xcode 10 in case the file is missing, this include fails and the build itself fails (was a warning in previous Xcode versions).
1308+
this.$fs.writeFile(pluginsXcconfigFilePath, "");
1309+
}
1310+
13041311
// Set Entitlements Property to point to default file if not set explicitly by the user.
13051312
const entitlementsPropertyValue = this.$xCConfigService.readPropertyValue(pluginsXcconfigFilePath, constants.CODE_SIGN_ENTITLEMENTS);
13061313
if (entitlementsPropertyValue === null && this.$fs.exists(this.$iOSEntitlementsService.getPlatformsEntitlementsPath(projectData))) {

test/ios-project-service.ts

+14
Original file line numberDiff line numberDiff line change
@@ -1029,4 +1029,18 @@ describe("Merge Project XCConfig files", () => {
10291029
assertPropertyValues(expected, destinationFilePath, testInjector);
10301030
}
10311031
});
1032+
1033+
it("creates empty plugins-<config>.xcconfig in case there are no build.xcconfig in App_Resources and in plugins", async () => {
1034+
// run merge for all release: debug|release
1035+
for (const release in [true, false]) {
1036+
await (<any>iOSProjectService).mergeProjectXcconfigFiles(release, projectData);
1037+
1038+
const destinationFilePath = release ? (<any>iOSProjectService).getPluginsReleaseXcconfigFilePath(projectData)
1039+
: (<any>iOSProjectService).getPluginsDebugXcconfigFilePath(projectData);
1040+
1041+
assert.isTrue(fs.exists(destinationFilePath), 'Target build xcconfig is missing for release: ' + release);
1042+
const content = fs.readFile(destinationFilePath).toString();
1043+
assert.equal(content, "");
1044+
}
1045+
});
10321046
});

0 commit comments

Comments
 (0)