Skip to content

Commit 87ecb5d

Browse files
authored
Supplemental fix for XcodeProjectPlugin support in package init template (#6451)
This is a supplemental fix for #6446 that removes the `async` specifier and corrects the protocol conformance of the Xcode command plug-in. This change should have been part of that PR. - remove the `async` specifier since the entry point that XcodeProjectPlugin defines isn't async - correct the protocol conformance of the Xcode command plug-in - update the unit tests rdar://108166582
1 parent 942a1e8 commit 87ecb5d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Sources/Workspace/InitPackage.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ public final class InitPackage {
422422
423423
extension \(typeName): XcodeBuildToolPlugin {
424424
// Entry point for creating build commands for targets in Xcode projects.
425-
func createBuildCommands(context: XcodePluginContext, target: XcodeTarget) async throws -> [Command] {
425+
func createBuildCommands(context: XcodePluginContext, target: XcodeTarget) throws -> [Command] {
426426
// Find the code generator tool to run (replace this with the actual one).
427427
let generatorTool = try context.tool(named: "my-code-generator")
428428
@@ -469,9 +469,9 @@ public final class InitPackage {
469469
#if canImport(XcodeProjectPlugin)
470470
import XcodeProjectPlugin
471471
472-
extension MyCommandPlugin: CommandPlugin {
472+
extension MyCommandPlugin: XcodeCommandPlugin {
473473
// Entry point for command plugins applied to Xcode projects.
474-
func performCommand(context: XcodePluginContext, arguments: [String]) async throws {
474+
func performCommand(context: XcodePluginContext, arguments: [String]) throws {
475475
print("Hello, World!")
476476
}
477477
}

Tests/WorkspaceTests/InitTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ class InitTests: XCTestCase {
179179
XCTAssertMatch(sourceContents, .contains("struct MyCommandPlugin: CommandPlugin"))
180180
XCTAssertMatch(sourceContents, .contains("performCommand(context: PluginContext"))
181181
XCTAssertMatch(sourceContents, .contains("import XcodeProjectPlugin"))
182+
XCTAssertMatch(sourceContents, .contains("extension MyCommandPlugin: XcodeCommandPlugin"))
182183
XCTAssertMatch(sourceContents, .contains("performCommand(context: XcodePluginContext"))
183184
}
184185
}
@@ -212,6 +213,7 @@ class InitTests: XCTestCase {
212213
XCTAssertMatch(sourceContents, .contains("struct MyBuildToolPlugin: BuildToolPlugin"))
213214
XCTAssertMatch(sourceContents, .contains("createBuildCommands(context: PluginContext"))
214215
XCTAssertMatch(sourceContents, .contains("import XcodeProjectPlugin"))
216+
XCTAssertMatch(sourceContents, .contains("extension MyBuildToolPlugin: XcodeBuildToolPlugin"))
215217
XCTAssertMatch(sourceContents, .contains("createBuildCommands(context: XcodePluginContext"))
216218
}
217219
}

0 commit comments

Comments
 (0)