-
Notifications
You must be signed in to change notification settings - Fork 119
Provision Sourcery via SwiftPM instead of CocoaPods #15609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
| @@ -1,6 +1,168 @@ | |||
| { | |||
| "originHash" : "cd02791f9079102404056ed65d89c5c6bb997332bbfd1b03550dfdd51e57551e", | |||
| "originHash" : "bb374fb1cfe6769494b51a8da522b904ded4d3987ad68cd369eadb59e59f5e74", | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of dependencies coming via Sourcery. Luckily none of those affect the app.
| %w[Hardware Networking Storage Yosemite WooCommerce WooFoundation].each do |prefix| | ||
| puts "\n\nGenerating Copiable for #{prefix}..." | ||
| puts '=' * 100 | ||
|
|
||
| sh "./Pods/Sourcery/bin/sourcery --config CodeGeneration/Sourcery/Copiable/#{prefix}-Copiable.sourcery.yaml" | ||
| end | ||
|
|
||
| puts "\n\nDONE. Generated Copiable for all projects." | ||
|
|
||
| %w[Hardware Networking Yosemite WooFoundation].each do |prefix| | ||
| puts "\n\nGenerating Fakes for #{prefix}..." | ||
| puts '=' * 100 | ||
|
|
||
| sh "./Pods/Sourcery/bin/sourcery --config CodeGeneration/Sourcery/Fakes/#{prefix}-Fakes.yaml" | ||
| end | ||
|
|
||
| puts "\n\nDONE. Generated Fakes." | ||
| # See note in BuildTools/.sourcery.yml for why we call without arguments | ||
| run_package_plugin(cmd: 'sourcery-command') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, when running via Swift package plugin, Sourcery ignores the --config parameter and only reads from .sourcery.yml
Luckily, one can configure everything in .sourcery.yml (see below).
I think in the end that's a better approach. We don't need to loop through folders of look for files. The tool does it all for us.
| 3F0904022D26A40800D8ACCE /* WordPressAuthenticator */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (3F09041C2D26A40800D8ACCE /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = WordPressAuthenticator; sourceTree = "<group>"; }; | ||
| 3F09040E2D26A40800D8ACCE /* WordPressAuthenticatorTests */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (3FD28D5E2D271391002EBB3D /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = WordPressAuthenticatorTests; sourceTree = "<group>"; }; | ||
| 3F0904022D26A40800D8ACCE /* WordPressAuthenticator */ = { | ||
| isa = PBXFileSystemSynchronizedRootGroup; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these are generated by CocoaPods / Xcode 16.3 — See also #15608
|
Note: Failing unit test is unrelated and fixed here. |
staskus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Sourcery code gen continue to work 👍

Description
This is part of the ongoing work to move away from CocoaPods, https://linear.app/a8c/issue/AINFRA-216.
#15598 established a
BuildToolsfolder with a Swift package dedicated to dependencies that we only use as tools—i.e. not imported in the code base.Sourcery is one such dependency and this PR moves it to be provisioned via SwiftPM instead of CocoaPods.
See also https://linear.app/a8c/issue/AINFRA-404.
Steps to reproduce & Testing information
To verify the change works, checkout the branch and run
bundle exec rake generate. You'll see SwiftPM fetching all the Sourcery dependencies and after that running the binary to generate the various Swift files from the Sourcery templates. Because the templates have not changed ,there should be no additional change in your local repo.To verify Sourcery actually can generate update files, modify one of the two templates:
CodeGeneration/Sourcery/Copiable/Models+Copiable.swifttemplateCodeGeneration/Sourcery/Fakes/Fakes.swifttemplateand verify the updated files are consistent with the changes you made. Example:
Template change
Generated changes
Screenshots
RELEASE-NOTES.txtif necessary.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: