All our latest news

Blog

Get the latest news delivered to you

Get connected with the sample apps

The VNC SDK includes sample apps for all supported platforms, and it’s only a few minutes’ work to get them up and running and to start evaluating connectivity and control.

You can connect to a Windows, Mac, Linux or Raspberry Pi computer from any combination of these platforms, and from an iOS or Android device or a modern web browser on any desktop platform. In this post, we’ll demonstrate an iPhone connecting to and controlling a Mac, but just check out the READMEs in the SDK samples folder to try out any other combination.

iPhone hero

What you'll need

This article assumes you’re set up for iOS development on your Mac, with provisioning profiles and developer certificates from Apple for your devices. You’ll also need:

  • The VNC SDK, available here.
  • A Mac running Mavericks or later.
  • Xcode 6.2+ with Developer Tools (xcode-select --install).
  • The OS X 10.10+ SDK and iOS 8+ SDK.
  • CMake for OS X, available here.
  • An iOS device running iOS 8+ (or a simulator).
  • Your API key and secret. Sign in to retrieve these (top right) if you don’t have them to hand.

Obtaining a pair of Cloud addresses

You’ll need a 'listen' Cloud address for the Server sample app on your Mac. Run the following command in the Terminal app, remembering to substitute in your API key and secret:

curl https://api.vnc.com/cloud/1.1/static-address -X POST -u your-API-key:your-API-secret -H "Content-Type:application/json" -H "Accept:application/json" -d '{"allowedActions":["listen"],"accessControl":{"groups":["test"]}}'

Run the following command to obtain a 'connect' Cloud address for the Viewer sample app on your iPhone:

curl https://api.vnc.com/cloud/1.1/static-address -X POST -u your-API-key:your-API-secret -H "Content-Type:application/json" -H "Accept:application/json" -d '{"allowedActions":["connect"],"groups":["test"]}'

Setting up your Mac

On your Mac, navigate to vnc-sdk/samples/basicServer and run the following commands:

cmake .
make
./basicServer listen-Cloud-address listen-Cloud-password

Note that the Server sample app generates and prints a VNC password, in this case 6351:

Blog Mac Server Sample App

Setting up your iPhone

On your Mac, open vnc-sdk/samples/basicVieweriOS/BasicVieweriOS.xcodeproj in Xcode.

Expand basicVieweriOS/appdelegate.m in Project navigator and hard-code the Viewer sample app's 'connect' Cloud address and Cloud password, and also the 'listen' Cloud address of the Server sample app (peer) to connect to:

Blog iOS Viewer Sample App

That's it!

Connect your iPhone to your Mac and build and run the app in Xcode. Note if you get an error, set Build Settings > All > Enable Bitcode to No.

On your iPhone, open the app, start a connection and enter the Server sample app password when prompted. You should see the screen of your Mac and be able to zoom and tap to mouse click where your finger is positioned. Click Show to open a virtual keyboard (and Hide to close it again), and Disconnect to terminate the connection at any time:

iPhone hero 2

Get the latest news delivered to you

on

×