Closed faizan-ali-mlk closed 2 months ago
Actually, it shouldn't be surprising that Swift packages depend on other packages transitively. However, on macOS, the SwiftLint plugin depends on a compiled binary only. So the sources shouldn't be required. There seems to be a bug in Xcode/Swift Package Manager, though, so that still all dependencies are loaded and compiled.
main
branch and let us know if it works.Thank you for the quick reply. I tested it by setting the main branch in SPM, but the result is the same.
I am also confused about one more flow. When I add the package, I get this popup.
If I set the target for my app, I encounter the following errors, and my project does not compile. However, it works without selecting the target. I am sharing this information in case you can help me understand why that popup is appearing.
> Note: I am using Xcode 15.2 and Macbook Pro with M1 Chip
If I set the target for my app, I encounter the following errors, and my project does not compile.
SwiftLint can also be consumed as a library (e.g. to develop your own version with extensions). It's a normal Swift package that provides three products: the executable, the library and the plugin.
To use the plugin only you must not assign the other products to any of your targets. Otherwise, they will be seen as dependencies that must be compiled for the target platform. But SwiftLint only builds on macOS (and Linux).
I tested it by setting the main branch in SPM, but the result is the same.
Xcode and SPM behave a bit surprising with respect to binary dependencies. All source dependencies are still downloaded and checked out even though they won't be used in later steps. That's why you see all the packages listed in Xcode. Yet, the build should be fast (at least on main
), because the binary SwiftLint framework is consumed to actually build/link the plugin.
ok @SimplyDanny, so will this issue be resolve or I should switch to Pod, Because i am not liking it that i have not 1 or 2 but almost 8 other libraries which i am not intended to use it.
ok @SimplyDanny, so will this issue be resolve or I should switch to Pod, Because i am not liking it that i have not 1 or 2 but almost 8 other libraries which i am not intended to use it.
I don't think we can do anything on the SwiftLint side. This might rather be an issue with SPM or Xcode. If you can reproduce it with a small example, you may open a ticket on their side.
Hello @SimplyDanny, how about providing a binary only repository for the plugin? I think its a pretty common use case that swiftlint is consumed by iOS / Mac developers and they don't necessarily need to import the actual framework. In our company, the main reason we are using the plugin is for an SDK project (a swift package with many modules) and we don't have build phases to invoke swiftlint. Of course we can wrap the SDK in an app and run the lint from there but its very inneficient as compared to running an individual swift module. Do you think this is a worthy use case?
What I asked above is for the purposes of avoiding "spilling out" internal Swiftlint dependencies so they are never resolved by the consumer.
Xcode and SPM behave a bit surprising with respect to binary dependencies. All source dependencies are still downloaded and checked out even though they won't be used in later steps. That's why you see all the packages listed in Xcode. Yet, the build should be fast (at least on
main
), because the binary SwiftLint framework is consumed to actually build/link the plugin.
I've been bitten by this before - thinking that this unnecessarily downloaded source was the source for what was executing, when it was not, and I find this SPM behaviour generally quite annoying.
I did try playing around a while ago with making a binary only package, but I don't think I got it to the point where it was working. Because of the limitations of SPM I think it might require a dedicated repo, which is also a pain. I think it would be less confusing for the user though.
I would like to second the request by @filiplazov to create a separate repo for build plugin distribution.
After integration SwiftLint as a build plugin in our projects, we have noticed that SPM is extremely slow when doing the initial package fetch operation. This is because it is downloading an entire git repository with all commit history, branches and tags, which is case of SwiftLint is more than 1.5 GB in size just for the main repository.
There is a long-standing issue about this on SPM Github page, but it doesn't look like it's going to be resolved any time soon: https://github.com/apple/swift-package-manager/issues/6062
As could be seen in the issue description, Lottie had the similar problem, and they were able to work around the SPM limitations it by switching to a separate repo for binary releases.
For your interest: I'm currently working on a separate repository for the plugins that stays in sync with the main SwiftLint repository without any manual maintenance effort. I think the benefit of it will be significant compared to the hassle that's caused by the aggregation in one repository and the way SPM treats it.
SwiftLintPlugins should be ready to use now. Let me know if this matches what you were asking for. Also give a shout if something doesn't work properly.
This looks perfect. Thank you @SimplyDanny..
@SimplyDanny I switched my projects to your repo, and everything works perfectly! Thanks a lot!
Hi,
I am trying to add SwiftLint using Swift Package Manager (SPM), but I don't know why it contains extra packages with it. I tested with CocoaPods, but there it is not adding any extra packages. I also tried to install other packages using SPM, like Alamofire, but that also did not add extra packages with it. I searched the issue logs, but I don't think anyone else is experiencing this issue. Please see the screenshots for the issue display.
Swiftlint using package manager
AlamoreFire Using Package manager