I'm looking to include a demo app with a Swift Package of custom controls that shows implementation demos for each of the controls. Is there a way that I can include this in the Swift Package (and also develop/test the controls directly inside the package this way)?
What kind of app? SwiftPM only directly supports macOS/Linux executables.
If you want an iOS/tvOS/watchOS one you will need an Xcode project that links using a relative path to find your package. This is done by creating the example app and dragging the Package's containing directory into the Xcode project. You can then link the library. If you put this example app in the repo with the package then it will be distributed along with anyone who clones the package.
One important thing I have noticed (which is almost certainly a bug in Xcode) when doing this myself is that the Package.swift
and Example.xcodeproj
cannot be in the same directory. You have to nest the Xcode project into another directory or it will have issues building/linking a lot of the time. So if you run into any issues With what I have suggested also try this bandaid.
I have created an example on GitHub here that works for Xcode 11.3.