Skip to main content

VPNGN In-App SDK for iOS

Installation

  1. Download the VPNGN SDK for iOS from the Downloads page

  2. Open Xcode

  3. Create two Network Extensions for two protocols:

    a. Go to File -> New -> Target

    b. Select Network Extension

    c. Use product name SocketTunnel for ShadowSocks and WGTunnel for Wireguard

    d. Put the content of the corresponding folder into the newly created extension source code folder

    e. Add Network Extensions capability and select Packet Filter checkbox

  4. For SocketTunnel extension ensure that:

    a. Framework and libraries section include: libVPNSDKSocksTunnel.xcframework and Tun2socks.xcframework

  5. Add Swift package: https://git.zx2c4.com/wireguard-apple

  6. For WGTunnel ensure that:

    a. Framework and libraries section include: WGTunnel-1.xcframework, WGTunnel-2.xcframework, WireGuardKit

  7. Use the following snippet in order to create VPNGN view controller:

        let vc = VPNSDK.VPNGNViewController()
    vc.setConfig(domain: "", shortToken: "", loginScreen: "user") {error, doHide in
    //Process logout
    doHide() // Hide view
    }

    Parameters:

    • domain - Your subdomain

    • shortToken - The end-user's short token

    • loginScreen - The Login screen to show in case that short token is empty:

      "user" for username/password login screen

      "token" for token based login screen

Traffic Counter (optional)

Add the IO Counter:

        vc.setIOCounter { bytesIn, bytesOut in 
// your code here
}