In order to use the Virgil Infrastructure setup your client and implement the required mechanisms using the following guide.
Don't see your language? Virgil is also available as a REST API.
The Virgil SDK is provided as a framework named VirgilSDK. The package is distributed via Carthage and CocoaPods
INSTALLING THE PACKAGE
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
To integrate VirgilSDK into your Xcode project using CocoaPods, specify it in your Podfile:
platform :ios, '10.0'
target '' do
pod 'VirgilSDK', '~> 4.5.0'
Then, run the following command:
> CocoaPods 0.36+ is required to build VirgilSDK 4.0.0+.
As of version 4.2.0 VirgilSDK is available for integration using Carthage.
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate VirgilSDK into your Xcode project using Carthage, perform following steps:
- Create an empty file with name Cartfile in your project's root folder, that lists the frameworks you’d like to use in your project.
- Add the following line to your Cartfile
github "VirgilSecurity/virgil-sdk-x" ~> 4.6.0
- Run carthage update. This will fetch dependencies into a Carthage/Checkouts folder inside your project's folder, then build each one or download a pre-compiled framework.
- On your application targets’ “General” settings tab, in the “Linked Frameworks and Libraries” section, add each framework you want to use from the Carthage/Build folder inside your project's folder.
- 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:
and add the paths to the frameworks you want to use under “Input Files”, e.g.:
Although VirgilSDK pod is using Objective-C as its primary language it might be quite easily used in a Swift application.
All public API is available from Swift and is bridged using NS_SWIFT_NAME where needed.
If you want to use VirgilSDK from swift it is necessary to perform the following:
- Create a new header file in the Swift project.
- Name it something like BridgingHeader.h
- Put there the following lines:
- In the Xcode build settings find the setting called Objective-C Bridging Header and set the path to your BridgingHeader.h file. Be aware that this path is relative to your Xcode project's folder. After adding bridging header setting you should be able to use the SDK.
You can find more information about using Objective-C and Swift in the same project here.
Obtain an Access Token
When users want to start sending and receiving messages in a browser or mobile device, Virgil can't trust them right away. Clients have to be provided with a unique identity, thus, you'll need to give your users the Access Token that tells Virgil who they are and what they can do.
Each user must send to you the Access Token request with their registration request. Then, your service that will be responsible for handling access requests must handle them in case of users successful registration on your Application server.
// an example of an Access Token representation
With a Token
With the Access Token we can initialize the Virgil PFS SDK on the client-side to start doing fun stuff like sending and receiving messages. To initialize the on a client-side you need to use the following code:
let virgil = VSSVirgilApi(token: "[YOUR_ACCESS_TOKEN_HERE]")
Without a Token
In case of a creation you don't need to initialize the SDK with the Access Token. For more information about the Global Virgil Card creation check out the Creating Global Card guide.
Use the following code to initialize the Virgil SDK without the Access Token.
let virgil = VSSVirgilApi()