LicenseKit helps you protect your Swift-based apps and libraries with commercial licenses.
LicenseKit lets you set up licenses in code
, in files
, fetch them from external apis
etc. LicenseKit licenses can specify an expiration date
, supported platforms
(iOS, macOS, tvOS, watchOS), bundle IDs
, tier
, customizable features
etc. which means that you can fully tailor your license offering.
LicenseKit requires a commercial license to be used. You can purchase a license from the LicenseKit website or use FREE
as license key to use the library with a limited number of licenses and features.
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 your Swift package so that your users get both your library and LicenseKit when fetching your package, or add the LicenseKit binary to your library distributable.
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.
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. If you received ABC123
as license key when signing up for LicenseKit, the code could look like this:
// You can use FREE as license key to test the trial version
let engine = try LicenseEngine(licenseKey: "ABC123") { 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 customer licenses:
let license = try await engine.getLicense(for: "customer 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 customer information, tier, activation and expiration dates, supported platforms (iOS, macOS, tvOS, watchOS), bundle IDs, features etc.
You can use licenses to protect functionality in your app or library. For instance, this class requires a .gold
tier OR that the license includes a certain feature:
public class MyVerySpecialClass {
public init() throws {
try license.validate(feature: .myCoolFeature, or: .gold)
...
}
...
}
This makes it impossible to create instances without a valid license, since the initializer will throw an error if the license is invalid.
For more information, please see the online documentation and getting started guide.
The online documentation has articles, code examples etc. that let you overview the various parts of the library.
The demo app lets you try out the library on iOS and macOS. Just open and run the Demo
project.
Feel free to reach out if you have any questions or need help any way:
LicenseKit is closed source. See the LICENSE file for more info.
link |
Stars: 52 |
Last commit: 5 days ago |
This version adds new features to the License
type.
License
can now specify allowsExpirationInProduction
to only have expired licenses fail validation when debugging, but not in production.License
has new name
and activationDate
properties.License
has a new validate(tier:)
function.License
has a new validate(feature:or:)
function.License
feature validation now supports nil strings.License
now has a single initializer that accepts both features and feature IDs.LicenseFeature
featureId
is no longer optional.LicenseEngine
getLicense
now uses an implicit parameter name.LicenseService
getLicense
now uses an implicit parameter name.Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics