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.7.0

Add the following to your .gitignore:


And then get the framework using:

carthage bootstrap --platform ios

Back in your Xcode project you will need to import some 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 under the new /Carthage/Build/iOS/ folder in your project into here, except for RxBlocking.framework, RxCocoa.framework, and RxTest.framework.

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”.


Lastly, you will then need to go into Build Settings, click on All, then search for bitcode. You need to change Enable Bitcode from “Yes” to “No”.


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 MAVSDK_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).

If you’re using a wifi bridge then you can start a UDP connection with the following:

drone.setMavlinkPort(mavlinkPort: "udp://:14550")

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).

Prior to building the SDK you will need to install the following packages via brew if you don’t already have them.

brew install xcodegen protobuf

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 MAVSDK-Swift.xcodeproj project file from project.yml.