Skip to content
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

SWIFTPM_MODULE_BUNDLE is not defined by rules_swift_package_manager for ObjC targets #774

Closed
krypt-lx opened this issue Nov 28, 2023 · 6 comments · Fixed by #781
Closed
Assignees
Labels
bug Something isn't working need more info Waiting for a response from the issue author or third-party.

Comments

@krypt-lx
Copy link
Contributor

krypt-lx commented Nov 28, 2023

Apparently SWIFTPM_MODULE_BUNDLE is thing, it is C precompiller flag defined for SMP packages
https://github.com/apple/swift-evolution/blob/main/proposals/0271-package-manager-resources.md#runtime-access-to-resources-bundle (at the end of the section)

Usage example
https://github.com/pocketsvg/PocketSVG/blob/10c6885e427e88d35fbb64010fbd6385cb58fef7/Sources/SVGEngine.mm#L899

There is similar bugreport for Tuist:
tuist/tuist#3785

@cgrindel
Copy link
Owner

Interesting. I had not run into this one. Thanks for reporting. We should be able to get this added shortly.

@cgrindel cgrindel added the bug Something isn't working label Nov 29, 2023
@cgrindel cgrindel self-assigned this Dec 2, 2023
@cgrindel
Copy link
Owner

cgrindel commented Dec 2, 2023

Just for clarification. SWIFTPM_MODULE_BUNDLE is a macro that returns the bundle. We will need to provide this in the same manner that we provide the Swift bundle accessor.

@cgrindel
Copy link
Owner

cgrindel commented Dec 2, 2023

Before implementing any changes in rules_swift_package_manager, I added PocketSVG to the resources example (#780). This works.

@krypt-lx Do you have an example that does not work?

@cgrindel cgrindel added the need more info Waiting for a response from the issue author or third-party. label Dec 2, 2023
@cgrindel
Copy link
Owner

cgrindel commented Dec 2, 2023

Possible duplicate of #372.

@krypt-lx
Copy link
Contributor Author

krypt-lx commented Dec 3, 2023

Well, as a quick fix I put the .plist it searches into main bundle (the lib tries to load it from main bundle if SWIFTPM_MODULE_BUNDLE is not defined)

As to example which didn't worked - I simply imported the lib in my Package.swift file.
The effect this bug causes in case of PockedSVG is not immediately obvious: the lib fails to parse some svgs because it is unable to load color aliases (such as "white", "yellow", etc). In my case it was one of SVGs for current project, so, I probably can't share it

@krypt-lx
Copy link
Contributor Author

krypt-lx commented Dec 3, 2023

It looks the tiger.svg image you imported from PocketSVG example is not using color aliases (only html-style colors, such as #cc7226), so, you can't see the issue

cgrindel added a commit that referenced this issue Dec 8, 2023
…th resources (#781)

- Generate `SWIFTPM_MODULE_BUNDLE` macro [inspired by the one provided
by
SPM](https://github.com/apple/swift-package-manager/blob/8387798811c6cc43761c5e1b48df2d3412dc5de4/Sources/Build/BuildDescription/ClangTargetBuildDescription.swift#L390).
- Ensure that the macro is available to all of the ObjC code by adding
the `-include` flag to the `copts` with the location of the resource
accessor header file.
- Update the `resources_example` to use a vendored version of
[AppLovin-MAX-Swift-Package](https://github.com/AppLovin/AppLovin-MAX-Swift-Package).
This package has an ObjC target with resources that expects the
`SWIFTPM_MODULE_BUNDLE` macro to be present.

Closes #372.
Closes #774.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need more info Waiting for a response from the issue author or third-party.
Projects
None yet
2 participants