You may find it beneficial to extract your Portals integration code and web assets to display within Portals into a standalone Swift Package.
Portals supports this procedure, but there are a few items to consider as you develop the Swift Package:
Add web assets as a Swift Package Resource. Ensure that you follow the "Copy" rule:
Some Swift packages may require a resource file to remain untouched or to retain a certain directory structure for resources. Use the copy(_:)
function to apply this rule and have Xcode copy the resource as is to the top level of the resource bundle. If you pass a directory path to the copy rule, Xcode retains the directory’s structure.
The "Copy" rule ensures that the directory structure of the web assets is retained.
The Portal initialization code will need to provide the bundle
:
let swiftPackagePortal = Portal( name: "foo" startDir: "path/to/foo", bundle: .module )
Once the steps above are complete, you will be able to leverage Portals within a Swift Package.
Comments
0 comments
Article is closed for comments.