Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to distribute iOS Demo app for Swift library via Swift Package Manager?

My Swift library FlexColorPicker just adopted Swift Package Manager support. The library itself can be added to any project via XCode by doing File → Swift Packages → Add Package Dependency... → choose target → enter https://github.com/RastislavMirek/FlexColorPicker → confirm. However, there is a demo that comes with the library that cannot be run when installed this way.

I want to add another (probably executable) product FlexColorPickerDemo to Package.swift that users can chose to include (or exclude) and then run inside their project just to see what they can do with the library. Besides adding new product and target to the Package.swift file I probably need to add main.swift, right? How should it look so that it allows running the demo as iOS app when installed via SPM?

Any help appreciated, even tutorial link, I don't really know what to Google...

like image 445
Rasto Avatar asked Oct 10 '19 12:10

Rasto


People also ask

How do I add demo app to Swift package?

Navigate to the app's directory, select Your_app. xcodeproj and hit Add. Navigate to the package's directory, and select the package directory only. Before hitting Add button, make sure "Create folder references for any added folders" is selected.

How do I distribute Swift framework?

To distribute code in binary form as a Swift package, create an XCFramework bundle, or artifact, that contains the binaries. Then, make the bundle available locally or on a server: When you host the binaries on a server, create a ZIP archive with the XCFramework in its root directory and make it available publicly.

How do I publish to Swift package manager?

Put Your Local Swift Package Under Version ControlOpen your Swift package, select the Source Control menu, choose New Git Repositories, check the checkbox next to your package, and click Create. This initializes a Git repository, adds your package to the staging area, and commits your files.


1 Answers

You want a complete demo project to be 'included' in a Package.swift file?

That's not possible, the same reason why bundled resources aren't useable (yet) by SwiftPM: How to include assets / resources in a Swift Package Manager library?

Best way imho would be to update your README file and explain how users can test the library, just like you're already doing.

like image 163
basvk Avatar answered Oct 19 '22 21:10

basvk