-
Meet Swift Package plugins
Discover how you can perform actions on Swift packages and Xcode projects with Swift package plugins. We'll go over how these plugins work and explore how you can use them to generate source code and automate your development workflow.
Ressources
Vidéos connexes
WWDC23
WWDC22
WWDC19
-
Rechercher dans cette vidéo…
-
-
import PackagePlugin @main struct MyPlugin: ... { // Entry points specific to plugin capability. These entry points are invoked // when the plugin is applied to a package. } #if canImport(XcodeProjectPlugin) import XcodeProjectPlugin extension MyPlugin: ... { // Entry points specific to plugin capability. These entry points are invoked // when the plugin is applied to an Xcdeo project. } #endif -
8:33 - Structure of a command plugin with conditional support for Xcode projects when running in Xcode
import PackagePlugin @main struct MyPlugin: CommandPlugin { /// This entry point is called when operating on a Swift package. func performCommand(context: PluginContext, arguments: [String]) throws { debugPrint(context) } } #if canImport(XcodeProjectPlugin) import XcodeProjectPlugin extension MyPlugin: XcodeCommandPlugin { /// This entry point is called when operating on an Xcode project. func performCommand(context: XcodePluginContext, arguments: [String]) throws { debugPrint(context) } } #endif -
11:13 - Structure of a build tool plugin with conditional support for Xcode projects when running in Xcode
import PackagePlugin @main struct MyPlugin: BuildToolPlugin { /// This entry point is called when operating on a Swift package. func createBuildCommands(context: PluginContext, target: Target) throws -> [Command] debugPrint(context) return [] } } #if canImport(XcodeProjectPlugin) import XcodeProjectPlugin extension MyPlugin: XcodeBuildToolPlugin { /// This entry point is called when operating on an Xcode project. func createBuildCommands(context: XcodePluginContext, target: XcodeTarget) throws -> [Command] debugPrint(context) return [] } } #endif
-