Getting started in iOS


Firstly, make sure you have RubyGems installed, then install the xcodeproj gem:

gem install --user xcodeproj

Add the following to your Cartfile:

github "mavlink/MAVSDK-Swift" ~> 0.5.0

And then get the framework using:

carthage bootstrap --platform ios

Back in your Xcode project you will need to import the libraries. On your application targets’ General settings tab, in the “Linked Frameworks and Libraries” section, drag and drop all files with the file extension .framework into here, except for RxTest.framework or your app will crash.

On your application targets’ Build Phases settings tab, click the + icon and choose New Run Script Phase. Create a Run Script in which you specify your shell (ex: /bin/sh), add the following contents to the script area below the shell:

/usr/local/bin/carthage copy-frameworks

Add the paths to the frameworks under “Input Files".


Add the paths to the copied frameworks to the “Output Files”.



If you run into any issues with running the carthage command then you can clear the cache and try it again

rm -rf Carthage ~/Library/Caches/org.carthage.CarthageKit ~/Library/Caches/carthage

The steps below assume that your iOS device has a network connection to the drone, e.g. using WiFi.

By default, the SDK will connect using MAVLink on UDP port 14540, which is running by default when PX4 is run in SITL (software in the loop simulation). For now, the backend is limited to UDP even though the core supports UDP, TCP, and serial.

import Dronecode_SDK_Swift

let drone = Drone()

After that, you can start writing some code as described below.

For advanced users: note that startMavlink will run the SDK backend in a background thread on the iOS device. You could connect the SDK to another backend (say, running on a computer with IP by omitting the second line above and running only: let drone = Drone(address: "", port: 50051).

Start writing code

After that, you can start using the SDK, for instance:



     .do(onNext: { next in print(next) })

Learn more about RxSwift here, and have a look at our examples.


Check out the examples for more examples using this framework.


If you want to contribute, please check out:

Build the SDK

Most of the SDK is auto-generated from the proto files (see in proto/protos). Note that they come from a submodule (i.e. you may need to $ git submodule update --init --recursive).

To generate the source code, run:

bash tools/generate_from_protos.bash

After that, you can either build the code with SwiftPM using:

swift build

Or generate an iOS Xcode project with:


This will create the Dronecode-SDK-Swift.xcodeproj project file from project.yml. If you don’t have it already, install Xcodegen with:

brew install xcodegen