Slide 1

Slide 1 text

GENERATING CODE AND OTHER MISCHIEF WITH SWIFT PACKAGE MANAGER PLUGINS 360IDEV | DENVER, CO | AUGUST 2022 ELLEN SHAPIRO | @DESIGNATEDNERD | GUSTO.COM

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

ALCATRAZ

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

! XCODE GHOST

Slide 19

Slide 19 text

! XCODE GHOST

Slide 20

Slide 20 text

! STRAWHORSE

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

!

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

XCODE SOURCE EXTENSIONS

Slide 26

Slide 26 text

REQUIRED HOST MAC APP

Slide 27

Slide 27 text

REQUIRED HOST MAC APP ▸ ! Can now be distributed easily on the Mac App store

Slide 28

Slide 28 text

REQUIRED HOST MAC APP ▸ ! Can now be distributed easily on the Mac App store ▸ " Sandboxing restrictions

Slide 29

Slide 29 text

REQUIRED HOST MAC APP ▸ ! Can now be distributed easily on the Mac App store ▸ " Sandboxing restrictions ▸ # Often winds up with an empty app

Slide 30

Slide 30 text

func perform(with invocation: XCSourceEditorCommandInvocation, completionHandler: @escaping (Error?) -> Void) { // Actual code of plugin }

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

ONLY SINGLE-FILE TEXT BUFFER ACCESS

Slide 33

Slide 33 text

ONLY SINGLE-FILE TEXT BUFFER ACCESS ▸ ! Does allow at least some sorting, linting, formatting

Slide 34

Slide 34 text

ONLY SINGLE-FILE TEXT BUFFER ACCESS ▸ ! Does allow at least some sorting, linting, formatting ▸ ☹ Only ever the current file

Slide 35

Slide 35 text

ONLY SINGLE-FILE TEXT BUFFER ACCESS ▸ ! Does allow at least some sorting, linting, formatting ▸ ☹ Only ever the current file ▸ # No access to the AST

Slide 36

Slide 36 text

ONLY SINGLE-FILE TEXT BUFFER ACCESS ▸ ! Does allow at least some sorting, linting, formatting ▸ ☹ Only ever the current file ▸ # No access to the AST ▸ $ No access to file or project structure

Slide 37

Slide 37 text

ONLY SINGLE-FILE TEXT BUFFER ACCESS ▸ ! Does allow at least some sorting, linting, formatting ▸ ☹ Only ever the current file ▸ # No access to the AST ▸ $ No access to file or project structure ▸ $ No user interface permitted

Slide 38

Slide 38 text

FURTHER INVOCATION LIMITATIONS

Slide 39

Slide 39 text

FURTHER INVOCATION LIMITATIONS ▸ ! Cannot run in background

Slide 40

Slide 40 text

FURTHER INVOCATION LIMITATIONS ▸ ! Cannot run in background ▸ " Must be actively invoked by the user

Slide 41

Slide 41 text

FURTHER INVOCATION LIMITATIONS ▸ ! Cannot run in background ▸ " Must be actively invoked by the user ▸ # No default key binding

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

SWIFT PACKAGE MANAGER ! PLUGINS

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

✅ SWIFT 5.6

Slide 53

Slide 53 text

✅ SWIFT 5.6 ! XCODE 14

Slide 54

Slide 54 text

1. COMMAND PLUGINS 2. BUILD TOOL PLUGINS

Slide 55

Slide 55 text

COMMAND PLUGINS

Slide 56

Slide 56 text

CODE FROM "CREATE SWIFT PACKAGE PLUGINS" HTTPS://DEVELOPER.APPLE.COM/VIDEOS/PLAY/WWDC2022/110401/

Slide 57

Slide 57 text

COMMAND PLUGINS ▸ Can ask permission to write in the package directory

Slide 58

Slide 58 text

// Package.swift .plugin( name: "GenerateContributors", capability: .command( intent: .custom(verb: "regenerate-contributors-list", description: "Generates the CONTRIBUTORS.txt file based on Git logs"), permissions: [ .writeToPackageDirectory(reason: "This command write the new CONTRIBUTORS.txt to the source root.") ] )),

Slide 59

Slide 59 text

// Package.swift .plugin( name: "GenerateContributors", capability: .command( intent: .custom(verb: "regenerate-contributors-list", description: "Generates the CONTRIBUTORS.txt file based on Git logs"), permissions: [ .writeToPackageDirectory(reason: "This command write the new CONTRIBUTORS.txt to the source root.") ] )),

Slide 60

Slide 60 text

COMMAND PLUGINS ▸ Can ask permission to write in the package directory ▸ Can be invoked at the command line

Slide 61

Slide 61 text

// Get all plugins available on a particular package swift package plugin --list // Run a specific plugin, in this case GenerateContributors swift package regenerate-contributors-list

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

COMMAND PLUGINS ▸ Can ask permission to write in the package directory ▸ Can be invoked at the command line ▸ Can be invoked from a menu item in Xcode

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

COMMAND PLUGINS ▸ Can ask permission to write in the package directory ▸ Can be invoked at the command line ▸ Can be invoked from a menu item Xcode ▸ Either way, must be invoked separately from the build process

Slide 70

Slide 70 text

BUILD TOOL PLUGINS

Slide 71

Slide 71 text

BUILD TOOL PLUGINS RUN AUTOMATICALLY ON EVERY BUILD

Slide 72

Slide 72 text

BUILD TOOL PLUGINS (THE THING I REALLY WANT TO USE)

Slide 73

Slide 73 text

THE MORE COMPLICATED BUT LESS COMPLICATED WAY: EMBED A PACKAGE IN YOUR .XCODEPROJ

Slide 74

Slide 74 text

MORE COMPLICATED (YOU HAVE TO ADD A WHOLE SWIFT PACKAGE TO YOUR PROJECT)

Slide 75

Slide 75 text

LESS COMPLICATED (IT WORKS WAY MORE RELIABLY)

Slide 76

Slide 76 text

SAMPLE APP https://github.com/designatednerd/ RadioactiveCat

Slide 77

Slide 77 text

via https://energyeducation.ca/encyclopedia/Half_life

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

BUILD TOOL EASY MODE BRING IN SOMEONE ELSE'S PLUGIN

Slide 82

Slide 82 text

DO NIL DISTURB HTTPS://GITHUB.COM/ICANZILB/ DONILDISTURBPLUGIN

Slide 83

Slide 83 text

// Package.swift .dependencies: [ .package(url: "https://github.com/icanzilb/ DoNilDisturbPlugin.git", from: "0.0.5"), ]

Slide 84

Slide 84 text

// Package.swift .target( name: "Cats", dependencies: [ ], plugins: [ .plugin(name: "DoNilDisturbPlugin", package: "DoNilDisturbPlugin") ] ),

Slide 85

Slide 85 text

No content

Slide 86

Slide 86 text

DO NOT BLINDLY CLICK TRUST & ENABLE ALL

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

No content

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

No content

Slide 91

Slide 91 text

No content

Slide 92

Slide 92 text

BUILD TOOL HARD MODE: CREATE YOUR OWN PLUGIN

Slide 93

Slide 93 text

DON'T BUILD YOUR PLUGIN AND THE PACKAGE YOU'RE TESTING IT AGAINST IN THE SAME REPO

Slide 94

Slide 94 text

GITHUB.COM/DESIGNATEDNERD/ DATEDIMAGEGENERATOR

Slide 95

Slide 95 text

PLUGIN VS. EXECUTABLE

Slide 96

Slide 96 text

// File structure of the Swift Lib ! DatedImageGenerator ! Plugins ! DatedImageGenerator " DatedImageGenerator.swift ! Sources ! DatedImage " DatedImage.swift " ExifDateFormatter.swift ! DatedImageGeneratorExecutable " DatedImageGeneratorExecutable.swift ! Tests ! DatedImageGeneratorTests " DatedImageGeneratorExecutable.swift " Media.xcassets

Slide 97

Slide 97 text

// File structure of the Swift Lib ! DatedImageGenerator ! Plugins ! DatedImageGenerator " DatedImageGenerator.swift ! Sources ! DatedImage " DatedImage.swift " ExifDateFormatter.swift ! DatedImageGeneratorExecutable " DatedImageGeneratorExecutable.swift ! Tests ! DatedImageGeneratorTests " DatedImageGeneratorExecutable.swift " Media.xcassets

Slide 98

Slide 98 text

// File structure of the Swift Lib ! DatedImageGenerator ! Plugins ! DatedImageGenerator " DatedImageGenerator.swift ! Sources ! DatedImage " DatedImage.swift " ExifDateFormatter.swift ! DatedImageGeneratorExecutable " DatedImageGeneratorExecutable.swift ! Tests ! DatedImageGeneratorTests " DatedImageGeneratorExecutable.swift " Media.xcassets

Slide 99

Slide 99 text

// File structure of the Swift Lib ! DatedImageGenerator ! Plugins ! DatedImageGenerator " DatedImageGenerator.swift ! Sources ! DatedImage " DatedImage.swift " ExifDateFormatter.swift ! DatedImageGeneratorExecutable " DatedImageGeneratorExecutable.swift ! Tests ! DatedImageGeneratorTests " DatedImageGeneratorExecutable.swift " Media.xcassets

Slide 100

Slide 100 text

// File structure of the Swift Lib ! DatedImageGenerator ! Plugins ! DatedImageGenerator " DatedImageGenerator.swift ! Sources ! DatedImage // <-- Exported library used in executable and main app " DatedImage.swift " ExifDateFormatter.swift ! DatedImageGeneratorExecutable " DatedImageGeneratorExecutable.swift ! Tests ! DatedImageGeneratorTests " DatedImageGeneratorExecutable.swift " Media.xcassets

Slide 101

Slide 101 text

// File structure of the Swift Lib ! DatedImageGenerator ! Plugins ! DatedImageGenerator " DatedImageGenerator.swift ! Sources ! DatedImage // <-- Exported Framework used in executable and main app " DatedImage.swift " ExifDateFormatter.swift ! DatedImageGeneratorExecutable // <-- The thing that does all the work " DatedImageGeneratorExecutable.swift ! Tests ! DatedImageGeneratorTests " DatedImageGeneratorExecutable.swift " Media.xcassets

Slide 102

Slide 102 text

// File structure of the Swift Lib ! DatedImageGenerator ! Plugins ! DatedImageGenerator " DatedImageGenerator.swift ! Sources ! DatedImage " DatedImage.swift " ExifDateFormatter.swift ! DatedImageGeneratorExecutable " DatedImageGeneratorExecutable.swift ! Tests ! DatedImageGeneratorTests " DatedImageGeneratorExecutable.swift " Media.xcassets

Slide 103

Slide 103 text

// Plugins/DatedImageGenerator.swift @main struct DatedImageGenerator: BuildToolPlugin { func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] { // TODO: Create info for build command return [ .buildCommand( displayName: "Generate Dated Images", executable: try context.tool(named: "DatedImageGeneratorExecutable").path, // more to come here arguments: "TODO", outputFiles: ["TODO"] ) ] } }

Slide 104

Slide 104 text

WHAT'S IN THE EXECUTABLE?

Slide 105

Slide 105 text

// Sources/DatedImageGeneratorExecutable/ // DatedImageGeneratorExecutable.swift @main struct DatedImageGeneratorExecutable { static func main() throws { // How do we get information from the Plugin? } }

Slide 106

Slide 106 text

// Sources/DatedImageGeneratorExecutable/ // DatedImageGeneratorExecutable.swift @main struct DatedImageGeneratorExecutable { static func main() throws { // Grab the 2nd argument as a string ProcessInfo.processInfo.arguments[1] } }

Slide 107

Slide 107 text

// Sources/DatedImageGeneratorExecutable/ // DatedImageGeneratorExecutable.swift @main struct DatedImageGeneratorExecutable { static func main() throws { // Turn it into Data Data(ProcessInfo.processInfo.arguments[1].utf8)) } }

Slide 108

Slide 108 text

// Sources/DatedImageGeneratorExecutable/ // DatedImageGeneratorExecutable.swift @main struct DatedImageGeneratorExecutable { static func main() throws { // Decode it into a codable object! let invocation = try JSONDecoder() .decode(PluginInvocation.self, from: Data(ProcessInfo.processInfo.arguments[1].utf8)) } }

Slide 109

Slide 109 text

"I should just put the codable object in the executable and import it into the plugin"

Slide 110

Slide 110 text

No content

Slide 111

Slide 111 text

No content

Slide 112

Slide 112 text

No content

Slide 113

Slide 113 text

// One copy of this in the plugin, one in the executable struct PluginInvocation: Codable { let catalogPaths: [String] let outputPath: String func encodedString() throws -> String { let data = try JSONEncoder().encode(self) return String(decoding: data, as: UTF8.self) } }

Slide 114

Slide 114 text

// One copy of this in the plugin, one in the executable // (or share with a common lib) struct PluginInvocation: Codable { let catalogPaths: [String] let outputPath: String func encodedString() throws -> String { let data = try JSONEncoder().encode(self) return String(decoding: data, as: UTF8.self) } }

Slide 115

Slide 115 text

// Plugins/DatedImageGenerator.swift @main struct DatedImageGenerator: BuildToolPlugin { func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] { guard let target = target as? SourceModuleTarget else { throw ImageGenError.notASourceModule } let assetCatalogPaths = target.sourceFiles(withSuffix: "xcassets") .compactMap { assetCatalog in return assetCatalog.path.string } let outputPath = context.pluginWorkDirectory .appending(["DatedImages.swift"]) let invocation = PluginInvocation(catalogPaths: assetCatalogPaths, outputPath: outputPath.string) return [ .buildCommand( displayName: "Generate Dated Images", executable: try context.tool(named: "DatedImageGeneratorExecutable").path, arguments: [try invocation.encodedString()], outputFiles: [outputPath] ) ] } }

Slide 116

Slide 116 text

// Plugins/DatedImageGenerator.swift @main struct DatedImageGenerator: BuildToolPlugin { func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] { guard let target = target as? SourceModuleTarget else { throw ImageGenError.notASourceModule } let assetCatalogPaths = target.sourceFiles(withSuffix: "xcassets") .compactMap { assetCatalog in return assetCatalog.path.string } let outputPath = context.pluginWorkDirectory .appending(["DatedImages.swift"]) let invocation = PluginInvocation(catalogPaths: assetCatalogPaths, outputPath: outputPath.string) return [ .buildCommand( displayName: "Generate Dated Images", executable: try context.tool(named: "DatedImageGeneratorExecutable").path, arguments: [try invocation.encodedString()], outputFiles: [outputPath] ) ] } }

Slide 117

Slide 117 text

! TARGET (TECHNICALLY PACKAGEPLUGIN.TARGET)

Slide 118

Slide 118 text

// Plugins/DatedImageGenerator.swift @main struct DatedImageGenerator: BuildToolPlugin { func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] { guard let target = target as? SourceModuleTarget else { throw ImageGenError.notASourceModule } let assetCatalogPaths = target.sourceFiles(withSuffix: "xcassets") .compactMap { assetCatalog in return assetCatalog.path.string } let outputPath = context.pluginWorkDirectory .appending(["DatedImages.swift"]) let invocation = PluginInvocation(catalogPaths: assetCatalogPaths, outputPath: outputPath.string) return [ .buildCommand( displayName: "Generate Dated Images", executable: try context.tool(named: "DatedImageGeneratorExecutable").path, arguments: [try invocation.encodedString()], outputFiles: [outputPath] ) ] } }

Slide 119

Slide 119 text

! PLUGIN CONTEXT (TECHNICALLY PACKAGEPLUGIN.PLUGINCONTEXT)

Slide 120

Slide 120 text

PLUGINWORKDIRECTORY IS YOUR SANDBOX

Slide 121

Slide 121 text

// Plugins/DatedImageGenerator.swift @main struct DatedImageGenerator: BuildToolPlugin { func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] { guard let target = target as? SourceModuleTarget else { throw ImageGenError.notASourceModule } let assetCatalogPaths = target.sourceFiles(withSuffix: "xcassets") .compactMap { assetCatalog in return assetCatalog.path.string } let outputPath = context.pluginWorkDirectory .appending(["DatedImages.swift"]) let invocation = PluginInvocation(catalogPaths: assetCatalogPaths, outputPath: outputPath.string) return [ .buildCommand( displayName: "Generate Dated Images", executable: try context.tool(named: "DatedImageGeneratorExecutable").path, arguments: [try invocation.encodedString()], outputFiles: [outputPath] ) ] } }

Slide 122

Slide 122 text

// Plugins/DatedImageGenerator.swift @main struct DatedImageGenerator: BuildToolPlugin { func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] { guard let target = target as? SourceModuleTarget else { throw ImageGenError.notASourceModule } let assetCatalogPaths = target.sourceFiles(withSuffix: "xcassets") .compactMap { assetCatalog in return assetCatalog.path.string } let outputPath = context.pluginWorkDirectory .appending(["DatedImages.swift"]) let invocation = PluginInvocation(catalogPaths: assetCatalogPaths, outputPath: outputPath.string) return [ .buildCommand( displayName: "Generate Dated Images", executable: try context.tool(named: "DatedImageGeneratorExecutable").path, arguments: [try invocation.encodedString()], outputFiles: [outputPath] ) ] } }

Slide 123

Slide 123 text

No content

Slide 124

Slide 124 text

QUICK RECAP OF PLUGIN CREATION

Slide 125

Slide 125 text

QUICK RECAP OF PLUGIN CREATION ▸ Create a plugin in Plugins

Slide 126

Slide 126 text

QUICK RECAP OF PLUGIN CREATION ▸ Create a plugin in Plugins ▸ Create an executable it will call in Sources

Slide 127

Slide 127 text

QUICK RECAP OF PLUGIN CREATION ▸ Create a plugin in Plugins ▸ Create an executable it will call in Sources ▸ Use a codable object to pass data between them

Slide 128

Slide 128 text

QUICK RECAP OF PLUGIN CREATION ▸ Create a plugin in Plugins ▸ Create an executable it will call in Sources ▸ Use a codable object to pass data between them ▸ Note that the plugin depends on but cannot import the executable

Slide 129

Slide 129 text

! BACK TO THE KITTAHS!

Slide 130

Slide 130 text

// In Cats/Package.swift dependencies: [ .package(url: "https://github.com/designatednerd/ DatedImageGenerator.git", from: "0.0.1"), .package(url: "https://github.com/icanzilb/ DoNilDisturbPlugin.git", from: "0.0.5"), ],

Slide 131

Slide 131 text

// In Cats/Package.swift .target( name: "Cats", dependencies: [ .product(name: "DatedImage", package: "DatedImageGenerator"), ], plugins: [ .plugin(name: "DatedImageGenerator", package: "DatedImageGenerator"), .plugin(name: "DoNilDisturbPlugin", package: "DoNilDisturbPlugin") ] ),

Slide 132

Slide 132 text

// In Cats/Package.swift .target( name: "Cats", dependencies: [ .product(name: "DatedImage", package: "DatedImageGenerator"), ], plugins: [ .plugin(name: "DatedImageGenerator", package: "DatedImageGenerator"), .plugin(name: "DoNilDisturbPlugin", package: "DoNilDisturbPlugin") ] ),

Slide 133

Slide 133 text

// In Cats/Package.swift .target( name: "Cats", dependencies: [ .product(name: "DatedImage", package: "DatedImageGenerator"), ], plugins: [ .plugin(name: "DatedImageGenerator", package: "DatedImageGenerator"), .plugin(name: "DoNilDisturbPlugin", package: "DoNilDisturbPlugin") ] ),

Slide 134

Slide 134 text

No content

Slide 135

Slide 135 text

No content

Slide 136

Slide 136 text

No content

Slide 137

Slide 137 text

No content

Slide 138

Slide 138 text

No content

Slide 139

Slide 139 text

No content

Slide 140

Slide 140 text

WHAT ABOUT RUNNING PLUGINS ON AN APP TARGET?

Slide 141

Slide 141 text

XCODE PROJECT PLUGIN

Slide 142

Slide 142 text

XCODE PROJECT PLUGIN (A KIND OF BUILD TOOL PLUGIN)

Slide 143

Slide 143 text

#if canImport(XcodeProjectPlugin) import XcodeProjectPlugin extension DatedImageGenerator: XcodeBuildToolPlugin { func createBuildCommands(context: XcodePluginContext, target: XcodeTarget) throws -> [Command] { let assetCatalogPaths = context.xcodeProject.filePaths .filter({ $0.string.hasSuffix("xcassets")}) .map { $0.string } // Rest of the code the same as in the main plugin } } #endif

Slide 144

Slide 144 text

#if canImport(XcodeProjectPlugin) import XcodeProjectPlugin extension DatedImageGenerator: XcodeBuildToolPlugin { func createBuildCommands(context: XcodePluginContext, target: XcodeTarget) throws -> [Command] { let assetCatalogPaths = context.xcodeProject.filePaths .filter({ $0.string.hasSuffix("xcassets")}) .map { $0.string } // Rest of the code the same as in the main plugin } } #endif

Slide 145

Slide 145 text

#if canImport(XcodeProjectPlugin) import XcodeProjectPlugin extension DatedImageGenerator: XcodeBuildToolPlugin { func createBuildCommands(context: XcodePluginContext, target: XcodeTarget) throws -> [Command] { let assetCatalogPaths = context.xcodeProject.filePaths .filter({ $0.string.hasSuffix("xcassets")}) .map { $0.string } // Rest of the code the same as in the main plugin } } #endif

Slide 146

Slide 146 text

#if canImport(XcodeProjectPlugin) import XcodeProjectPlugin extension DatedImageGenerator: XcodeBuildToolPlugin { func createBuildCommands(context: XcodePluginContext, target: XcodeTarget) throws -> [Command] { let assetCatalogPaths = context.xcodeProject.filePaths .filter({ $0.string.hasSuffix("xcassets")}) .map { $0.string } // Rest of the code the same as in the main plugin } } #endif

Slide 147

Slide 147 text

#if canImport(XcodeProjectPlugin) import XcodeProjectPlugin extension DatedImageGenerator: XcodeBuildToolPlugin { func createBuildCommands(context: XcodePluginContext, target: XcodeTarget) throws -> [Command] { let assetCatalogPaths = context.xcodeProject.filePaths .filter({ $0.string.hasSuffix("xcassets")}) .map { $0.string } // Rest of the code the same as in the main plugin } } #endif

Slide 148

Slide 148 text

No content

Slide 149

Slide 149 text

No content

Slide 150

Slide 150 text

No content

Slide 151

Slide 151 text

No content

Slide 152

Slide 152 text

No content

Slide 153

Slide 153 text

No content

Slide 154

Slide 154 text

SPM PLUGIN LIMITATIONS

Slide 155

Slide 155 text

SPM PLUGIN LIMITATIONS (that I've found so far)

Slide 156

Slide 156 text

SPM PLUGIN LIMITATIONS (that I've found so far) ▸ Still no UI for you

Slide 157

Slide 157 text

SPM PLUGIN LIMITATIONS (that I've found so far) ▸ Still no UI for you ▸ You can't even ask to use the network

Slide 158

Slide 158 text

SPM PLUGIN LIMITATIONS (that I've found so far) ▸ Still no UI for you ▸ You can't even ask to use the network ▸ You can't share data between plugins

Slide 159

Slide 159 text

SPM PLUGIN LIMITATIONS (that I've found so far) ▸ Still no UI for you ▸ You can't even ask to use the network ▸ You can't share data between plugins ▸ Can't do anything with build results

Slide 160

Slide 160 text

! PLUGIN WISH LIST

Slide 161

Slide 161 text

PLUGIN WISH LIST ▸ File metadata

Slide 162

Slide 162 text

PLUGIN WISH LIST ▸ File metadata ▸ Ability to show UI in Xcode

Slide 163

Slide 163 text

OBLIGATORY SUMMARY SLIDE

Slide 164

Slide 164 text

OBLIGATORY SUMMARY SLIDE ▸ Alcatraz

Slide 165

Slide 165 text

OBLIGATORY SUMMARY SLIDE ▸ Alcatraz ! " Xcode 8 Extensions

Slide 166

Slide 166 text

OBLIGATORY SUMMARY SLIDE ▸ Alcatraz ! " Xcode 8 Extensions ▸ SPM Plugins to the rescue!

Slide 167

Slide 167 text

OBLIGATORY SUMMARY SLIDE ▸ Alcatraz ! " Xcode 8 Extensions ▸ SPM Plugins to the rescue! ▸ Command plugins: On demand, Build tool plugins: On every build

Slide 168

Slide 168 text

OBLIGATORY SUMMARY SLIDE ▸ Alcatraz ! " Xcode 8 Extensions ▸ SPM Plugins to the rescue! ▸ Command plugins: On demand, Build tool plugins: On every build ▸ Security: Be super-mindful of which plugins you use

Slide 169

Slide 169 text

OBLIGATORY SUMMARY SLIDE ▸ Alcatraz ! " Xcode 8 Extensions ▸ SPM Plugins to the rescue! ▸ Command plugins: On demand, Build tool plugins: On every build ▸ Security: Be super-mindful of which plugins you use ▸ Building plugins is a bit complicated, but also pretty fun

Slide 170

Slide 170 text

THANK YOU!

Slide 171

Slide 171 text

SWIFT-EVOLUTION LINKS! ▸ SE-0303: Extensible Build Tools github.com/apple/swift-evolution/ blob/main/proposals/0303-swiftpm-extensible-build-tools.md ▸ SE-0325: Additional Plugin APIs github.com/apple/swift-evolution/ blob/main/proposals/0325-swiftpm-additional-plugin-apis.md ▸ SE-0332: SPM Command Plugins github.com/apple/swift-evolution/ blob/main/proposals/0332-swiftpm-command-plugins.md

Slide 172

Slide 172 text

! SLIGHTLY TERRIFYING LINKS! ▸ Xcode Ghost details: en.wikipedia.org/wiki/XcodeGhost ▸ Strawhorse leaked document: theintercept.com/document/ 2015/03/10/strawhorse-attacking-macos-ios-software- development-kit ▸ Strawhorse Context: theintercept.com/2015/03/10/ispy-cia- campaign-steal-apples-secrets/

Slide 173

Slide 173 text

! PLUGIN LINKS! ▸ Do Nil Disturb: github.com/icanzilb/DoNilDisturbPlugin ▸ Swift SafeURL: github.com/baguio/SwiftSafeURL