Embedding Sample App inside Swift Package
2 min readJun 21, 2021
So you finally plan to harness the power of Swift Packages for sharing your custom code.
You may need a Sample App for the following reasons-
- During the development phase, you may like to simultaneously test- the implementation of your Swift Package.
- Once ready, showcasing the usage of your Swift Package.
This can be achieved by embedding a sample app inside a swift package-
Steps:
- Create a swift package: Example-
mkdir SPMAppKit
cd SPMAppKit
swift package init — name SPMAppKit - Open Package.swift
- Create a New App (SampleApp using File > New > Project > iOS > App) in the same hierarchy as Sources in your Swift Package directory (SPMAppKit here).
4. Now close the SwiftPackage(from Xcode) and open the SampleApp.
5. Drag and drop the base folder of the Swift Package inside the SampleApp
6. Add the Swift Package inside the Framework, Libraries and Embedded Contents of the SampleApp.
Cheers, now you are all set to work on the sample app!