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
Align resource bundle accessor generation with SPM #6146
Align resource bundle accessor generation with SPM #6146
Conversation
adcbe0d
to
10a7f25
Compare
@danibachar I think this is the right way to go about it. We should preserve the With this PR, we can also remove this line and it will resolve this issue. Let me know if you have time to work on this, otherwise, I can take it over π |
Hi, yes, I opened this PR which lead me to the understanding people are probably using. the objc accessor to access the target resources from the outside. I thought about it and I came to the conclusion that to comply with SPM we need to distinguish internal from public accessors. I'm going to add these changes + some others into my original PR if that is ok with you... I think in this way we can comply with SPM - i.e generate internal accessors for both objc and swift runtime. In addition to allow public accessor for both (with the same objc class) like today. struct BundleAccessorOptions {
let internal: Bool // if true will create the internal accessors
let public: Bool // if true will create the public accessor class, I do wonder if we should leave those in the same file as the internal ones?
} Then the backward compatibility will be simple. let bundleAccessorOptions = BundleAccessorOptions(internal: !disableBundleAccessors, public: !disableBundleAccessors) WDYT? |
I'd do two PRs:
|
It will introduce breaking changes though - wouldn't it? I mean we don't know if users are using the I have one example Fixture that is doing that - the But to your question - yes it will solve my issue I do think that changes here are quite simple and comprehensive, keeping backwards compatibility, and are not that big? |
We have never marketed that SPM resources can be available externally and I don't think our users should expect us to support that option when it's not available via vanilla integration. While technically a breaking change, I think it's something we can live with.
I'd still redo the PR and remove the |
Closing in favor of: #6124 |
# Conflicts: # Sources/TuistGenerator/Mappers/ResourcesProjectMapper.swift # Tests/TuistGeneratorTests/ProjectMappers/ResourcesProjectMapperTests.swift
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.
Can we also add the dependency from this issue into the app_with_spm_dependencies
fixture to confirm the bug is resolved (and that we won't introduce a regression for this in the future?)
Otherwise, just a couple of nits after which we can merge this.
/// Since \(target.name) is a \( | ||
target | ||
.product | ||
), the bundle containing the resources is copied into the final product. |
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.
This formatting is slightly odd. Is it actually treated as one 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.
I didn't touch this formatting, mise lint didn't change it, but indeed its considered as one comment - i.e one line
Example from the app_with_spm_dependencies
, the derived file Derived/Sources/TuistBundle+Styles
...
/// Since Styles is a staticFramework, the bundle containing the resources is copied into the final product.
...
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.
I can change it if you wish
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.
no, it's fine as long as it's treated as a single line of comment π
Tests/TuistGeneratorTests/ProjectMappers/ResourcesProjectMapperTests.swift
Outdated
Show resolved
Hide resolved
Note this following PR and related issue I have found with formatting the |
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.
Amazing work π
Resolves #6149
Short description π
Comply to SPM bundle accessors, both for internal and external module.
Following up on this PR with a more novel solution.
Currently Tuist have a mix of how it generates bundle accessors for both ObjC and Swift run time. This PR tries to unify them and comply to SPM logic.
How to test the changes locally π§
Use the
disableBundleAccessors: true
option.In a target with Swift code and Resources, code will be generated and linked to the target to support the
Bundle.module
accessor - similar to SPM.In a target with Objective-C code and Resources, code will be generated and linked to the target to support the
SWIFTPM_MODULE_BUNDLE
accessor macro - similar to SPM.Contributor checklist β
mise run lint:fix
Reviewer checklist β
changelog:added
,changelog:fixed
, orchangelog:changed
, and the title is usable as a changelog entry