Skip to content

Commit c2d4a69

Browse files
authored
feat(apple): support team signing on Swift macro SPM targets (#6060)
1 parent 7976333 commit c2d4a69

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,18 @@ export class XcodebuildArgsService implements IXcodebuildArgsService {
227227
extraArgs.push(`${swiftUIBootProperty}=${swiftUIBootValue}`);
228228
}
229229

230+
// Swift macro/compiler-plugin SPM targets must be code-signed with a
231+
// development team when building for a device. Pass DEVELOPMENT_TEAM as a
232+
// command-line build setting so it applies to SPM package targets too.
233+
const developmentTeamProperty = "DEVELOPMENT_TEAM";
234+
const developmentTeamValue = this.$xcconfigService.readPropertyValue(
235+
BUILD_SETTINGS_FILE_PATH,
236+
developmentTeamProperty,
237+
);
238+
if (developmentTeamValue) {
239+
extraArgs.push(`${developmentTeamProperty}=${developmentTeamValue}`);
240+
}
241+
230242
if (this.$fs.exists(xcworkspacePath)) {
231243
return ["-workspace", xcworkspacePath, ...extraArgs];
232244
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,24 @@ describe("xcodebuildArgsService", () => {
101101
assert.include(actualArgs, "SWIFT_ENABLE_EXPLICIT_MODULES=YES");
102102
assert.notInclude(actualArgs, "SWIFT_ENABLE_EXPLICIT_MODULES=NO");
103103
});
104+
105+
it("should include DEVELOPMENT_TEAM from build.xcconfig", () => {
106+
const injector = createTestInjector({
107+
logLevel: "INFO",
108+
hasProjectWorkspace: false,
109+
buildXcconfigContent: "DEVELOPMENT_TEAM = TEAM123",
110+
});
111+
const xcodebuildArgsService: IXcodebuildArgsService = injector.resolve(
112+
"xcodebuildArgsService",
113+
);
114+
115+
const actualArgs = xcodebuildArgsService.getXcodeProjectArgs(
116+
<any>{ projectRoot, normalizedPlatformName },
117+
<any>{ projectName, appResourcesDirectoryPath },
118+
);
119+
120+
assert.include(actualArgs, "DEVELOPMENT_TEAM=TEAM123");
121+
});
104122
});
105123

106124
describe("getBuildForSimulatorArgs", () => {

0 commit comments

Comments
 (0)