-
Notifications
You must be signed in to change notification settings - Fork 0
Building your Kitura application in Xcode
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.
Before starting this, make sure you can successfully build and run your Kitura app from the command-line using
swift build
. Also, install the xcodeproj gem usinggem install xcodeproj
.
- 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.
- 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
andMyApp-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:
For iOS:
- 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 toXcode
=>Toolchains
and select your desired toolchain.