Add SwiftLint support
The v100.x Toolkit had a SwiftLint build phase. We should add SwiftLint to the Toolkit, Example, ~and AuthenticatorExample projects~ (the Authenticator Example is essentially static and unchanging, so we're not going to lint that). The Samples team has already done this for the Swift Samples, so follow that pattern.
- [x] Add to Example App via Run Script Build Phase
- [ ] Add to Toolkit Package via SwiftLint SPM Plug-in.
We should also explore swift-format
Note: Swift lint is being added at the SDK level in 200.5 as a plugin. Ref Swift 2836. cc @zkline101 @mhdostal
Add to Example App via Run Script Build Phase
You may want to change this because once your Examples project is updated to the Xcode 15 recommended changes (it may already be upgraded), it will break that build phase. This is because Xcode will automatically change ENABLE_USER_SCRIPT_SANDBOXING = YES which prevents swift lint from being run. So it would be worth changing your swift lint in your examples app to a build tool plugin which you can find the directions in the SwiftLint repo.
Note that we ended up adding SwiftLint as a custom package rather than a plugin. See Swift 5164.
In today's discussion on using SwiftLint build tool plugin, there are some concerns about adding the plugin to the toolkit Swift Package
- For public facing products such as the toolkit Swift package and Samples app, because there are more people download and use them, than pull and contribute to them, adding it as a plugin will be an unnecessary overhead for their usage
- We might consider how to limit the SwiftLint tool to our contributors, so that users don't need to download them when they use the products (as a dependency)
- Using build phase script is viable for Samples as it doesn't force a user to install the program, but not viable for the toolkit
- Maybe there is a way like the environment variable in https://github.com/Esri/arcgis-maps-sdk-swift-toolkit/issues/275, so that the toolkit can set an env, and only contributors will download the SwiftLint build tool plugin when develop and compile the Swift package
- For internal-use product, such as the Swift API source code package, Swift API examples app, (maybe?) toolkit examples apps, we can use the build tool plugin as it can provide the convenience for everyone who has or doesn't have SwiftLint as a program installed on their machine.
The benefits of SwiftLint build tool plugin as of today (200.4)
- Being the SwiftLint binary package, it avoids the slow GitHub pull time for all the dependencies SwiftLint source package uses, which are about 5 more Swift packages
- It avoids the SourceKitten incompatible with Mac Catalyst, https://github.com/realm/SwiftLint/issues/5093
Esri fork of SwiftLint -> https://github.com/Esri/SwiftLint
~There're some blockers to integrating the plugin at this time (ref Swift 5176)~
Update: This can be consumed as a package plugin to lint package sources. The Toolkit example projects can add it as a package dependency $PROJECT -> Package Dependencies and then add a build tool plugin step under $TARGET -> Run Build Tool Plug-ins
Once this work is done we should carry out #698
Edit: Possible new issue with the SwiftLint SPM plug-in that should be resolved first @ Swift 5296