Swiftpack.co - LicenseKit/LicenseKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by LicenseKit.
LicenseKit/LicenseKit 0.4.0
LicenseKit helps you protect your Swift-based apps and libraries with a commercial license.
⭐️ 49
🕓 3 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/LicenseKit/LicenseKit.git", from: "0.4.0")

Version Platform Swift 5.6 Closed-Source License Twitter: @danielsaidi

About LicenseKit

LicenseKit helps you protect your Swift-based apps and libraries with a commercial license.

LicenseKit lets you specify your licenses in code, files or fetch them from an external api. Licenses can specify expiration date, supported platforms (iOS, macOS, tvOS, watchOS), bundle IDs, tier, features etc.

LicenseKit requires a commercial license to be used. You can obtain a license from the LicenseKit website or use FREE as license key to use the library with a capped number of licenses.

Supported Platforms

LicenseKit supports iOS 13, macOS 12, tvOS 13 and watchOS 6.

This means that you can use LicenseKit to protect your software on all major Apple platforms.

Installation

LicenseKit can be installed with the Swift Package Manager:

https://github.com/LicenseKit/LicenseKit.git

LicenseKit only has to be added to the main app target. If you are using LicenseKit with a library, make sure to set up SPM so that your users get both your library and LicenseKit.

Getting started

The online documentation has a getting-started guide that will help you get started with LicenseKit.

Basically, you should first create a LicenseEngine with your(!) LicenceKit license key:

let engine = try LicenseEngine(licenseKey: "...") { license in
    LocalLicenseService(
        license: license,
        licenses: [
            License(licenseKey: "license-key-1"),
            License(licenseKey: "license-key-2")
        ]
    )
}

If the license key is valid and refers to a valid license, the license engine will be created with the service you define in the service builder. If not, a LicenseError is thrown.

Once you have a license engine, you can use it to handle licenses:

let license = try await engine.getLicense(for: "license key")

Just like when creating a license engine, the license will be returned if the license key is valid and refers to a valid license, otherwise a LicenseError is thrown.

Licenses can specify expiration date, supported platforms (iOS, macOS, tvOS, watchOS), bundle IDs, tier, features etc.

You can use licenses to protect functionality within your app or library. For instance, this class requires a LicenseTier/gold tier license:

public class MyVerySpecialClass {

    public init() throws {
        let requiredTier = LicenseTier.gold
        if license.tier.level < requiredTier.level {
            throw LicenseError.higherLicenseTierRequired(requiredTier)
        }
        ...
    }

    ...
}

This makes it impossible to create instances without a valid license, since the initializer will throw an error if the license is invalid.

Free license

There's a free trial license that you can use to try out LicenseKit with a capped number of licenses.

To use LicenseKit with this license, just use FREE as license key when creating a license engine instance:

let engine = try LicenseEngine(licenseKey: "FREE") { license in
    ...
}

This lets you use LocalLicenseService or CsvLicenseService with up to 10 licenses.

Documentation

The online documentation has articles, code examples etc. that let you overview the various parts of the library.

The online documentation is currently iOS-specific. To generate documentation for other platforms, open the package in Xcode, select a simulator then run Product/Build Documentation.

Demo app

This project has a demo app that lets you explore the library. To try it out, just open and run Demo/Demo.xcodeproj.

Contact

Feel free to reach out if you have any questions or need help any way:

License

LicenseKit is closed source. See the LICENSE file for more info.

GitHub

link
Stars: 49
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

3 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics