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: Before starting this, make sure you can successfully build and run your Kitura app from the command-line using
‣ Go to your project directory where you have your
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.
Develop iOS application and Kitura on the same workspace
‣ Follow the above instructions for creating an Xcode project for your Kitura app. For example:
‣ Create a new iOS project and sources in a new subdirectory e.g.
‣ Create a new Xcode workspace in the root of your directory:
‣ Open up Finder and drag and drop your
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.
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:
- Set the toolchain setting to Xcode’s default (menu: Xcode => Toolchains).
For Kitura app:
- Download the correct toolchain directly from swift.org (the toolchain might be under
Older snapshots), install it, then go to
Toolchainsand select your desired toolchain.