You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.9 KiB

10 years ago
iOS + ZeroTier SDK
====
Welcome!
Imagine a flat, encrypted, no-configuration LAN for all of the instances of your iOS app.
10 years ago
This short tutorial will show you how to enable ZeroTier functionality for your iOS app with little to no code modification. Check out our [ZeroTier SDK](https://www.zerotier.com/blog) page for more info on how the integration works.
10 years ago
***
**Step 1: Build iOS framework**
10 years ago
- `make ios_app_framework`
- This will output to `build/ios_app_framework/Release-iphoneos/ZeroTierSDK_iOS.framework`
10 years ago
**Step 2: Integrate SDK into project**
10 years ago
- Add the resultant framework package to your project
- Add `src` directory to *Build Settings -> Header Search Paths*
- Add `build/ios_app_framework/Release-iphoneos/` to *Build Settings -> Framework Search Paths*
- Add `ZeroTierSDK.frameworkiOS` to *General->Embedded Binaries*
- Add `src/wrappers/swift/ZTSDK.swift`, `src/wrappers/swift/XcodeWrapper.cpp` and `src/wrappers/swift/XcodeWrapper.hpp` to your project:
- Set `src/wrappers/swift/Apple-Bridging-Header.h` as your bridging-header in *Build Settings -> Objective-C Bridging-header*
10 years ago
**Step 3: Start the ZeroTier service**
10 years ago
Start the service:
10 years ago
```
zt.start_service(nil);
zt.join_network(nwid);
10 years ago
```
Listen for incoming connections:
10 years ago
```
let sock: Int32 = zt.socket(AF_INET, SOCK_STREAM, 0)
let ztaddr: ZTAddress = ZTAddress(AF_INET, serverAddr, Int16(serverPort))
let bind_err = zt.bind(sock, ztaddr)
zt_listen(sock, 1);
let accepted_sock: Int32 = zt.accept(sock, ztaddr)
```
Or, establish a connection:
```
let sock: Int32 = zt.socket(AF_INET, SOCK_STREAM, 0)
let ztaddr: ZTAddress = ZTAddress(AF_INET, serverAddr, Int16(serverPort))
let connect_err: Int32 = zt.connect(sock, ztaddr)
10 years ago
```
**Alternative APIs**
10 years ago
CLick [here](../../../../docs/api_discussion.md) to learn more about alternative APIs such as the Intercept and SOCKS5 Proxy.