Navigation Menu

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

[SR-8260] Implementation story for resources #5352

Closed
swift-ci opened this issue Jul 16, 2018 · 3 comments
Closed

[SR-8260] Implementation story for resources #5352

swift-ci opened this issue Jul 16, 2018 · 3 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-8260
Radar None
Original Reporter wjk (JIRA User)
Type New Feature
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels New Feature
Assignee None
Priority Medium

md5: d271df3cd846c6aaee6d69dcff44cb9e

duplicates:

  • SR-2866 [SwiftPM] Need a way to include resources with targets

Issue Description:

Greetings Swift community.

I noticed while browsing the issues that swiftpm has no support for handling bundle resources. I had a few thoughts on how to implement that, which I would like to share before starting implementation in case anyone has any feedback:

Resource files for a hypothetical module Foo would be stored in `Resources/Foo`, alongside `Sources/Foo` and `Package.swift`. The Xcode project generator would create appropriate Xcode rules to have these files copied into the Resources directory of the target. All files in the `Resources/Foo` directory would be copied, except if the name starts with a dot (so that .gitignore, .DS_Store, and so on are automatically ignored). Subdirectory structure would be reproduced as-is, including *.lproj directories. (If generating for Xcode, then we would need to special-case these to use the proper Xcode conventions.) If there is a file called `Info.plist` in the root of the resources directory for the module, it would be set as the Info.plist file for the target in lieu of the one automatically generated by swiftpm (and not copied into the Resources directory, as that is considered incorrect behavior by Xcode).

If the developer is targeting a non-Apple platform, then a `Foo.resources` directory will be created next to the native binary and the resources copied there, such that the resulting structure would be compatible with the CFBundle implementation in swift-corelibs-foundation. The Info.plist would be copied in this case, as is required.

If on any platform the `Resources/Foo` directory should be missing, then it will be silently ignored. If targeting an Apple platform, then a default Info.plist should be generated, as swiftpm does already. If targeting a non-Apple platform, no message should be printed about a missing Info.plist, nor should one be generated by default. (This is because the library in question may not be using CFBundle, and as such creating .resources directories where they are unneeded would be a pointless activity.)

There are a few things I am unsure about, however:

  • If targeting an Apple platform but not using Xcode (i.e. `swift build` from the command line directly), what should we do?

  • If building for a non-Apple platform, how should we ensure that the .resources subdirectory is copied alongside the binary? If we separate the two, then the library may fail when it can't find its resources.

  • I am unsure how to generate the pbxproj constructs required to properly copy the resources. The best resource I have for pbxproj processing is the xcbuild project (https://github.com/facebook/xcbuild,)), but that is licensed under Facebook's unfriendly BSD+patent license, so I am hesitant to use it as an implementation resource. I may require the assistance of someone who knows more about Xcode here.

Thanks!

@ankitspd
Copy link
Member

Thanks for the writeup wjk (JIRA User)! A couple of SwiftPM contributors are working on a draft proposal for resources. They expect to put it out for discussion this fall (it'll take some time due to upcoming vacations).

@swift-ci
Copy link
Contributor Author

swift-ci commented Jan 5, 2019

Comment by Richard Venable (JIRA)

@aciidb0mb3r You mentioned there would be a draft proposal for resources expected last fall. Did that get published?

@swift-ci
Copy link
Contributor Author

Comment by Bastian Mueller (JIRA)

@aciidb0mb3r Any update on this?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants