Building within Xcode

Setting up an Xcode project for your Kitura application

You can develop, test and run your Kitura app in Xcode. This gives you productivity features such as debugging, autocompletion, and syntax checking.

Swift Package Manager can generate an Xcode project for you by reading your project’s Package.swift file. It will automatically set up several targets that will be built using Xcode — note that when Xcode builds the project it is not using swift build, rather it uses its internal build process.

tip Tip: Before starting this, make sure you can successfully build and run your Kitura app from the command-line using swift build.

Go to your project directory where you have your Package.swift file

Run:

swift package generate-xcodeproj

Open the generated project in Xcode.

Change the build scheme to your executable. Xcode defaults to the module of the same name, which won’t run.

Run.


Develop iOS application and Kitura on the same workspace

Follow the above instructions for creating an Xcode project for your Kitura app. For example:

./MyApp-server.xcodeproj

Create a new iOS project and sources in a new subdirectory e.g.

client/MyApp-ios.xcodeproj

Create a new Xcode workspace in the root of your directory:

./MyApp.xcworkspace

Open up Finder and drag and drop your MyApp-server.xcodeproj and MyApp-ios.xcodeproj to your workspace.

Be sure to choose to create new references to these projects and sources, but do not actually copy the files in the filesystem.

Select the scheme you wish to build the server and the client respectively.


Toolchain Settings

We want to use a specific version of toolchain for a Kitura app, however, for an iOS app we have to use Xcode’s default toolchain.

To solve this situation:

For iOS:

For Kitura app: