How to include assets / resources in a Swift Package Manager library?

后端 未结 6 804
挽巷
挽巷 2020-12-15 15:35

I would like to ship my library using Apple\'s Swift Package Manager. However my lib includes a .bundle file with several strings translated in different languages. Using co

6条回答
  •  粉色の甜心
    2020-12-15 16:00

    starting on Swift 5.3, thanks to SE-0271, you can add bundle resources on swift package manager by adding resources on your .target declaration.

    example:

    .target(
       name: "HelloWorldProgram",
       dependencies: [], 
       resources: [.process(Images), .process("README.md")]
    )
    

    if you want to learn more, I have written an article on medium, discussing this topic

提交回复
热议问题