这些类应在您想向支付许可证费用的客户提供某些专业功能或在仿真器中限制整个框架使用时用于您的框架内。
这相当复杂,因为 CommonCrypto 并不可直接用于 Swift。因此,你需要执行以下操作:
module CommonCrypto [system] {
header "/usr/include/CommonCrypto/CommonCrypto.h"
export *
}
CommonCrypto
添加到 "构建设置 --> Swift编译器 - 搜索路径 --> 导入路径" 中// Set a License key (That will be provided by your customer)
THLicense.sharedLicense.setLicenseKey("db693f13bf2267c510a2e202afcca4067a16d8ed")
// Set a constant Salt
THLicense.sharedLicense.setSalt("123456")
// Only during development
//THLicense.sharedLicense.debugMode = true
// Check if the License is valid
if (THLicense.sharedLicense.isLicenseValid()) {
// continue with your framework execution
}
如果将其设置为调试模式,它将显示日志中的可能有效许可证密钥。目前,它使用 bundleId 和 salt 创建密钥,并按以下顺序执行检查
这样,您可以向一个公司中的所有应用程序或单个应用程序销售许可证
... 真心欢迎。也许有更好的实现此检查的方法或是需要额外的设置,所以我愿意在您的帮助下改进它。
此项目的源代码在标准 MIT 许可证下可用。请参阅 许可证文件。