iOS

To start working with Fleksy Core SDK, we first need to sync the required dependency, set required flags, and finally obtain an instance of the FleksyLib class.

The CoreSDK requires Xcode 14 or later.
To use the SDK, please note that you first need valid license credentials (key and secret) which can be requested in the developer’s dashboard.
The below steps assume that you already have an existing project to add Fleksy Core SDK support. In case you lack an existing project, follow the steps given at official Apple documentation to create a new project.

Setup

To use Fleksy Core SDK in your app, add the package as a dependency using its repository URL, as follows:

  1. Navigate to Project’s General Pane > Package Dependencies,
  2. Click the + button, enter the repository URL, and click the Add Package button.

Repository URL:

https://github.com/FleksySDK/FleksyCoreSDK-iOS

Instantiating FleksyLib

The FleksyLib class is the primary way to interact with the Fleksy Core SDK. You need to create an instance of FleksyLib to start using the autocorrection, next word prediction, and swipe functionalities.

To create a FleksyLib instance, you need to pass it a valid language file (.jet extension) and a LibraryConfiguration object.

For example:

let languageFile = URL(fileURLWithPath: "resourceArchive-en-US.jet")

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

Now obtain an instance of FleksyLib:

let fleksyLib = try! FleksyLib(languageFileURL: languageFile, configuration: libraryConfiguration)

Now you can start using the methods from the FleksyLib instance.

Overview of FleksyLib’s Methods

There are 3 main methods offered by FleksyLib namely:

There are also additional methods available that can be explored in the class as per requirements.

The currentWordPrediction and nextWordPrediction methods can be used within any application that wishes to take benefit of autocorrection and next word predictions. Both method requires an instance of TypingContext as a parameter.

In case you are integrating the Fleksy Core SDK in your custom keyboard application, you can use additional methods offered by the FleksyLib instance. The swipePrediction and currentWordPrediction (overload method) methods requires an instance of TypingContext and a list of LayoutPoint.

An instance of LayoutPoint contains information regarding the position of the key (within the keyboard) where the user has tapped. The Fleksy Engine uses that to offer better predictions. It is important to note that a valid LayoutType must be provided as a parameter to LibraryConfiguration when instantiating FleksyLib before any methods utilizing LayoutPoint can be used.

Working with Languages

The Fleksy Core SDK supports many languages other than the default starting language. A complete list of supported languages can be found in the Languages section. To work with different languages, the SDK offers various methods in the LanguagesHelper class, among which the two main methods are:

  • availableLanguages that allows you to obtain a list of all supported languages from Fleksy’s remote server, and
  • downloadLanguageFile that can download a given language from Fleksy’s remote server at a given path and invoke a callback function to trigger a custom action.

There are also additional methods available that can be explored in the class as per requirements.

Additional Resources


Something needs to be added, or found an error in our documentation? Please let us know by either on our GitHub or Discord.

Last updated on February 22, 2023