- +iOS 13.0
TacirlerSDK 通过 CocoaPods 提供。要安装它,只需将以下几行添加到您的 Podfile 中
use_frameworks!
platform :ios, '13.0'
target 'YOUR-TARGET-NAME' do
pod 'forinvest-dob-ios'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
end
end
end
- 在目标应用中选择
签名与能力
选项卡,然后点击+能力
按钮,添加近场通信标签读取
能力。 - 添加您 Info.plist 文件中必要的权限;
<!--
FOR NFC
-->
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A0000002471001</string>
</array>
<key>NFCReaderUsageDescription</key>
<string>Permission string</string>
<!--
FOR Camera
-->
<key>NSCameraUsageDescription</key>
<string>Permission string</string>
<key>NSMicrophoneUsageDescription</key>
<string>Permission string</string>
- 确保您的
.entitlements
文件中有以下这些行;
<dict>
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>TAG</string>
</array>
</dict>
import UIKit
import TacirlerSDK
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Perform necessary tasks in case of memory shortage here.
}
@IBAction func clicked(_ sender: Any) {
// Customize your theme settings
// if you comment out this section it will be show the default app color theme in your device/simulator.
let customTheme = SDKConfiguration(
backgroundColor: UIColor.lightGray,
contentViewBackgroundColor: UIColor.cyan,
buttonEnabledBackgroundColor: UIColor.green,
buttonDisabledBackgroundColor: UIColor.red,
buttonTextColor: UIColor.purple,
placeHolderTextColor: UIColor.brown,
borderColor: UIColor.cyan,
tintColor: UIColor.purple,
iconColor: UIColor.orange,
checkBoxColor: UIColor.brown,
viewControllerTitleColor: UIColor.red,
logoImageName: "forinvest", // just put your forinvest.png file to under your project/assets folder
fontType: .interRegular,
// prefilled form args
name: "Yasin",
surname: "Köker",
idNumber: "12345678901",
email: "[email protected]",
jobID: 141 // Akademisyen
)
// Set the theme through SDKConfigManager
SDKConfigManager.shared.sdkConfiguration = customTheme
// Create TacirlerSDKViewController
let vc = TacirlerSDKViewController()
vc.authorizeToken(
// put your token and license id in here
// if you don't available or lost it contact with:
// [email protected]
inputToken: "YOUR_TOKEN",
licenseID: "YOUR_LICENSE_ID"
)
// Present TacirlerSDKViewController modally
vc.modalTransitionStyle = .coverVertical
vc.modalPresentationStyle = .fullScreen
present(vc, animated: true)
}
}
如果您在开发中使用 XCode 版本 14.3.1,您可以直接使用 'pod update' 命令拉取并使用更新后的 SDK。
然而,如果您已升级到 XCode 版本 15.0,在 'pod update' 后构建时可能会遇到以下错误
DT_TOOLCHAIN_DIR 无法用于评估 LIBRARY_SEARCH_PATHS,请使用 TOOLCHAIN_DIR
直到 Apple 或 CocoaPods 发布与该问题相关的更新之前,作为临时解决方案,在每个 'pod update' 之后,请在您的项目文件夹中的终端中按照以下步骤操作:运行以下脚本
find . -name "*.xcconfig" -type f -exec grep -l 'DT_TOOLCHAIN_DIR' {} \; | while IFS= read -r file; do sed -i '' 's/DT_TOOLCHAIN_DIR/TOOLCHAIN_DIR/g' "$file"; done
然后,重新打开项目并再次构建。在此步骤之后,您可能会遇到以下运行时错误
Sandbox:rsync(35790)拒绝(1)文件写入创建
针对此,您可以按照以下步骤操作
打开 Xcode 项目。
在左侧侧栏中点击项目名称以打开项目设置。
在“目标”部分中选择您要检查的目标。
点击“构建设置”选项卡。
在搜索栏中,输入“ENABLE_USER_SCRIPT_SANDBOXING”。
如果 ENABLE_USER_SCRIPT_SANDBOXING 的值为“否”,则表示已禁用。如果值为“是”,则已启用。