hans hans - 1 year ago 90
Swift Question

Swift without Xcode importing class

I want to make a port my Node.js command line application to Swift, and I don't want to use Xcode to do it (on Linux).

Does the Swift Package Manager have a specific package structure, and will I be able to use existing Xcode frameworks for my application?



Answer Source

If you are on Linux, you can use the Swift Package Manager. It will allow you to import custom modules and to download external frameworks (aka dependencies). I believe however, you may need to build swift from source in order to use it.

The structure of your project will most likely need to change. SwiftPM is pretty strict about it.

With the typical setup of a package, you will need to have two sub folders within the Sources directory, one forming a library and the other forming an executable. For example,


This structure will allow you to import module MyLibrary from the main.swift file.

Note that the only difference here is a library doesn't contain a main.swift file, while the executable does.

You will also need to make a manifest file - Package.swift - with SwiftPM also requires for building packages. Here are some of their examples on how to build packages.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download