iOS SDK

To start working with Fleksy Keyboard SDK, we first need to sync the required dependency, set required flags, create a custom keyboard extension, and finally creating a KeyboardViewController extending the FKKeyboardViewController class.

To use the SDK, please note that you first need a license key which can be requested in the developer’s dashboard.
The below steps assume that you already have an existing project to add Fleksy Keyboard SDK support. In case you lack an existing project, follow the steps given at official Apple documentation to create a new project.

Setup

Let’s set up your Sample keyboard, which takes just a few minutes. Follow the instructions below to add the keyboard SDK to an existing application.

Step 1

Xcode provides support to add a new Custom Keyboard Extension target to your project that can be used to quickly generate required files and schemes to build your custom keyboard.

  1. Select your Project in the Project Navigator,
  2. Navigate to File > New > Target,
  3. Select the Custom Keyboard Extension from the Application Extension group and click next,
  4. Specify a Product Name (e.g. SampleKeyboard) and click finish.

Add new Custom Keyboard Extension target

Xcode will ask you if you want to activate the scheme for the newly created extension. Choose Activate.

Step 2

Add the FleksySDK package as a dependency using its repository URL, as follows:

  1. Navigate to Project’s General Pane > Package Dependencies,
  2. Click on the + button and enter the repository URL and click Add Package button.
https://github.com/FleksySDK/FleksySDK-iOS

Add FleksySDK package dependency

Step 3

Locate your Custom Keyboard Extension created in step 1 in the Project Navigatior.

  1. Modify the KeyboardViewController class present in it by removing the existing content in it.
  2. Import the FleksyKeyboardSDK package and inherit from FKKeyboardViewController.
  3. Override the method createConfiguration to return a configuration as shown below.
  4. Finally replace <your-license-key> and <your-license-secret> with your license.
It is recommended NOT to commit your license keys in the code but to store them as variables in the environment and access them during the compilation.
import FleksyKeyboardSDK

class KeyboardViewController: FleksyKeyboardSDK.FKKeyboardViewController {

    override func createConfiguration() -> KeyboardConfiguration {
        let style = StyleConfiguration()

        let appPopup = AppearancePopup()
        let appLongpress = AppearanceLongPress()
        let appearance = AppearanceConfiguration(
            objPopup: appPopup,
            objTouch: nil,
            objLongpress: appLongpress
        )

        let typing = TypingConfiguration()
        let panelConfig = PanelConfiguration()
        let debugConfig = DebugConfiguration(debug: ())

        let licenseConfig = LicenseConfiguration(
            licenseKey: "<your-license-key>",
            licenseSecret: "<your-license-secret>"
        )

        return KeyboardConfiguration(
            panel: panelConfig,
            capture: nil,
            style: style,
            appearance: appearance,
            typing: typing,
            specialKeys: nil,
            license: licenseConfig,
            debug: debugConfig
        )
    }
}

Step 4

FleksySDK doesn’t support building with bitcode so it must be disabled to avoid compilation failures.

  1. Select your Custom Keyboard Extension’s General Pane > Build Settings,
  2. Under the Build Options find the option Enable Bitcode and set it to No.

Disable bitcode

Step 5

  1. Navigate to Custom Keyboard Extension’s General Pane > Info > NSExtension,
  2. Under NSExtensionAttributes, find RequestsOpenAccess key of type Boolean and set its value to 1.

Add RequestsOpenAccess property

Your project is now ready to be built and run on a device of your choice.

Additional Resources


Something missing or found an error on our documentation? Please file an issue.

Last updated on August 31, 2022