You are here: Building and Viewing an Application > Build a Native Library

Generate Native Library for an App

Applies to Kony Visualizer Classic.

You can build a native library for an app that is created in Kony Visualizer. Once you generate the native library, you can embed the native library in your platform specific native applications. For example, if you generated a native library for Android, you can use the library in Android native application.

The Native Library feature of Kony Visualizer uses some Kony application APIs and a few native APIs that establish the communication between Kony library and the native application.

The iOS library is created in the .zip format while the Android library is created in the .aar format. If there are any errors during the process of library creation, the Console section of Kony Visualizer logs the issues.

To generate native library for your app, do the following:

  1. In Kony Visualizer, from the File menu, click Product, and then Build.
    The Build generation page displays.
  2. Select Generate Native Library.
    Those builds which do not support generating Native library are disabled.

  3. Select the channel you want to generate the native library and then click Build.
  4. The build process starts.
    Once the build is complete, a success message is displayed. Hyperlink for location of generated library artifacts appears in the console.
  5. Click the hyperlink to navigate to the path to view the build files.

Integrating the Native Library into a Native App - Android

To integrate native library into a native app, do the following:

  1. Once you build the native library successfully for the application in Kony Visualizer, you must copy the generated aars of the application to the libs folder of app module of the Android native project. If the libs folder is not present in the app module of the native project, create the libs folder and paste the aar files in it.

    Location of aars in Kony Visualizer project:
    Mobile channel: <workspace>/temp/<AppID>/ build/luaandroid/dist/<AppID>_aars
    Tablet Channel: <workspace>/temp/<AppID>/build/luatabrcandroid/dist/<AppID>_aars

    Note: Hyperlink of the generated library artifacts location will appear in the build console of Kony Visualizer.

  2. In the native app's main project build.gradle, add the following snippet under allprojects > repositories scope.
    flatDir {
        dirs 'libs'
    }
    

    Here is how the code looks before adding flatDir

    Once the code is added, here is the view.
  3. In the build.gradle file of app module of the native project, to sync Kony application aars into the app module of native project, add the following code.
    fileTree(dir: 'libs', include: '**/*.aar')
        .each {
            File file - & gt;
            dependencies.add("implementation", [name: file.name.lastIndexOf('.').with {
                    it != -1 ? file.name[0.. & lt; it] : file.name
                },
                ext: 'aar'
            ])
    }
    
  4. Add gradle dependencies of Kony library application (mentioned under dependencies scopes )of build.gradle file to the native project app module build.gradle file dependencies scope.
    Mobile channel: <workspace>/temp/<AppID>/ build/luaandroid/dist/<AppID>
    Tablet channel : <workspace>/temp/<AppID>/build/luatabrcandroid/dist/<AppID>

    Note: Library application build.gradle file may contain multiple dependencies scope, so you must add all gradle dependencies under multiple dependencies scope of library application . If there are any external(remote) dependencies, then you should mention corresponding repository and url information in the native project main build.gradle file under allprojects repositories scope .

    Once you incorporate the changes mentioned in the steps above, the gradle file looks like the image below.

  5. Sync gradle changes of app module to add library artifacts.

Reduce Android App Binary Size

When you build a Kony app as Android library, native framework libraries (.so files)are bundled for supported 32 and 64-bit architectures in the library . For example, 32-bit architectures armeabi-v7a, x86, 64-bit architectures arm64-v8a, x86_64, and so on.

You can reduce the binary size of the native app by specifying the specific architecture of the library you want to support in your native app. You can do that by adding appropriate ndk filters to the app module build.gradle file of the native app.

android {
    defaultConfig {
        ndk {
            abiFilters "armeabi-v7a"
        }
    }
}

In this example, only armeabi-v7a architecture is bundled resulting in reduced binary size.

You can add more architectures you need by separating them with a comma. For example,

android {
    defaultConfig {
        ndk {
            abiFilters "armeabi-v7a, x86"
        }
    }

Integrating the Native Library into a Native App using integrateiOSLibrary Tool

You can integrate the native library in iOS using the integrateiOSLibrary tool.

  1. Download the integrateiOSLibrary tool from here.
  2. Open the tool and run the following arguments.
    ./integrateiOSLibrary -proj <path to xcodeproj> -lz <path to Generated iOS Native Library>

    Note: In case of xcworkspace, pass one of the projects in the workspace as an argument to the executable.


    Once you run the executable with arguments, the integrateiOSLibary tool adds all the frameworks packed in the generated iOS native library to App targets of the provided native XCode project.

    Note: All frameworks of Kony are dynamic frameworks. Hence, all the frameworks should get added to both Embed Frameworks and Link Binary with Libraries sections of App Targets of the provided native XCode project.

integrateiOSLibrary Executable Usage

The following table provides information on options that you can execute using the integrateiOSLibrary tool.

Options Requirement Details
--help Optional Executable Information about usage and options.
-g | --groupname Optional Group Name in Xcode Project to which frameworks need to be added. If a new group name is given, the tool will create that group in the Xcode project and adds all the frameworks to that group. If the group name is not provided, a group with generated library zip name will be created. ./integrateiOSLibrary -proj <path to xcodeproj> -lz <path to Generated iOS Native Library> -g <group name>
-lf | --libraryframeworks Optional

If frameworks generated with wrappers around library APIs need to be added to any framework target, pass respective framework targets using --frameworkTargets and respective frameworks(containing wrappers) using --libraryframeworks. You can provide multiple Frameworks separated by a comma.

./integrateiOSLibrary -proj <path to xcodeproj> -lz <path to Generated iOS Native Library> -f <frameworktarget1,frameworktarget2> -lf <libraryframework1,libraryframework2>

-f | --frameworkTargets Optional

If library APIs must be used in any framework target, provide that framework target as an argument. Tool will add the required frameworks which has library APIs to the provided framework targets. Multiple Framework Targets can be provided separated by comma

./integrateiOSLibrary -proj <path to xcodeproj> -lz <path to Generated iOS Native Library> -f <frameworktarget1,frameworktarget2>

--debug Optional Prints debug statements
-clean Optional

Removes all the Kony Frameworks added to the project. Argument : Pass xcodeproj to which kony frameworks are added and group name in the xcodeproj to which frameworks are added using -g option.

./integrateiOSLibrary --clean <path to Xcode project> -g <group name>

-proj Mandatory Xcode Project

 

Example

. / integrateiOSLibrary - proj / Users / abcd / iOSNativeProject / iOSNativeProject.xcodeproj - lz / Users / abcd / iOSNativeLibrary.zip

Note: If any of Kony frameworks are added manually to the XCode project, make sure to delete the frameworks manually before running the executable.

Integrating the Native Library into a Native App Manually - iOS

Once you build the native library for the application in Kony Visualizer, you must copy the generated .zip files of the application to the iOS native project. The generated library artifacts are present in a .zip file with the AppID (<AppID>.zip).

The location of the file is

<Workspace>/temp/<AppName>/build/server/(iphonekbf (or) ipadkbf (or) universalkbf)

Note: Path of the generated library artifacts location will appear in the build console of Kony Visualizer.

When you unzip the .zip file, it contains the following files.

To add frameworks to the iOS native project, do the following:

  1. Create a folder in the native project and copy all the frameworks in the .zip file that includes AppID.framework, frameworks in the Library Dependencies, and frameworks in Platform Dependencies.
  2. Open the XCode Project and add the folder as a group to the project. Initially uncheck all the targets in the Add to targets section.
  3. Navigate to Project > App Target >General and add all the dynamic Frameworks in the folder to the embedded binaries section.

Note: All the frameworks will be available in both Embedded Binaries and Link Binary with Libraries sections in Build Phases of the App target.

Integrating the Native Library into a Native App - Windows

Once you build the native library for the application in Kony Visualizer, you must copy the generated library artifacts of the application to the Windows native project.

The generated library artifacts are available in the following locations:

To link Kony App to the Windows native library, do the following:

  1. Download the KonyLibraryLinker tool from here.
  2. Open KonyLibraryLinker tool.
  3. Configure Target Path to the library artifacts for specific channels.
    Mobile channel: <workspace>/temp/<AppID>/build/windows10/Windows10Mobile/<AppID>
    Tablet Channel: <workspace>/temp/<AppID>/build/windows10/Windows10/<AppID>

Limitations

Android:

iOS:

The following features are not supported for the iOS platform:

 

 

Copyright © 2013 Kony, Inc. All rights reserved.