THE SWIFT PACKAGE MANAGER — X — FILE

PACKAGE

A package is basically a collection of file with a manifest of instruction about how to use them. The package structure is written inside a manifest file, usually called Package.swift.

HOW TO ENABLE YOUR CURRENT FRAMEWORK XCODE PROJECT TO SUPPORT SPM?

To make your current project to support SPM is not that hard. The most important thing is that if you want to do it fast you must change the structure of your folders and how files relies on them. If you don’t do that you can still keep your current file configuration but you will have to work with the Package manifest to point targets to the right directories.

Duplicate Debug configuration by pressing the “+” button and rename it to Debug-test
Under the target build settings search for “Other swift flag” and write -DTEST only for Debug-test configuration
In the scheme for the target select Test and change its build configuration to Debug-test
Duplicate the LittleBlueTooth target
Set that target to compile with the -DTEST flag
In the general settings, be sure you have your dependency set in Frameworks and Libraries
Do the same in Build phases for Link Binary With Libraries
Modify the scheme to launch testing using the Debug-test configuration and using the + add the LittleBlueToothTests bundle
Remove the unit test bundle from the original target
  • Symlink must have a relative path to the repo, by default absolute path are created and they will work only on your machine

CONCLUSION

Do not confuse Xcode build configurations and settings with SPM they are not shared resources, they are two completely indipendent and decoupled system.
SPM is all about simplicity and in simplicity relies beauty .
SPM is the future, better get your hands dirty, before it’s too late.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store