Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-module projects in Swift

I'm developing an iOS application that is made of several distinct logical parts (i.e., "libraries").

What's the Swift way for creating such projects? How do I set it up in Xcode?

like image 842
j4zzcat Avatar asked Jul 20 '16 10:07

j4zzcat


People also ask

What is a module in Swift?

A module is a single unit of code distribution—a framework or application that's built and shipped as a single unit and that can be imported by another module with Swift's import keyword. Each build target (such as an app bundle or framework) in Xcode is treated as a separate module in Swift.

How do I add modules to Xcode?

You can't do this from the Xcode Welcome screen, but you can use the ⌃ ⌘ N (control + command + n) shortcut. Create a new empty folder and call it modules . You can choose a different name, but for this article, I will use modules . Add a new project to this workspace with ⇧ ⌘ N (shift + command + n).

How do I create a Swift package?

To create a new Swift package, open Xcode and select File > New > Swift Package. Choose a name and select a file location. Select “Create Git repository on my Mac” to put your package under version control. On completion, the Swift package opens in Xcode and looks similar to a standard Xcode project.


1 Answers

There are many ways to do it:

  • Using Xcode WorkSpace.
  • Using Pod: https://cocoapods.org/
  • Using incoming Swift Package Manager: https://swift.org/package-manager/

Happy coding

like image 152
Daniel Tran Avatar answered Oct 16 '22 23:10

Daniel Tran