Skip to content

Commit

Permalink
Add Xcode project comparability.
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaRU committed Feb 10, 2024
1 parent 3533e83 commit e61ce06
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Plugins/PackageBuildInfoPlugin/plugin.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/////
//// plugin.swift
/// Copyright © 2022 Dmitriy Borovikov. All rights reserved.
/// Copyright © 2024 Dmitriy Borovikov. All rights reserved.
//

import PackagePlugin
Expand All @@ -23,3 +23,21 @@ struct PackageBuildInfoPlugin: BuildToolPlugin {
return [command]
}
}

#if canImport(XcodeProjectPlugin)
import XcodeProjectPlugin
extension PackageBuildInfoPlugin: XcodeBuildToolPlugin {
func createBuildCommands(context: XcodeProjectPlugin.XcodePluginContext, target: XcodeProjectPlugin.XcodeTarget) throws -> [PackagePlugin.Command] {
let outputFile = context.pluginWorkDirectory.appending("packageBuildInfo.swift")
let command: Command = .prebuildCommand(
displayName:
"Generating \(outputFile.lastComponent) for \(context.xcodeProject.directory)",
executable:
try context.tool(named: "PackageBuildInfo").path,
arguments: [ "\(context.xcodeProject.directory)", "\(outputFile)" ],
outputFilesDirectory: context.pluginWorkDirectory
)
return [command]
}
}
#endif

0 comments on commit e61ce06

Please sign in to comment.