# LunkrSDK-iOS **Repository Path**: coremail/LunkrSDK-iOS ## Basic Information - **Project Name**: LunkrSDK-iOS - **Description**: 论客SDK-iOS及演示Demo - **Primary Language**: Swift - **License**: MPL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-29 - **Last Updated**: 2023-06-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Lunkr.xcframework使用指南 > Lunkr.xcframework主要包括几大功能: > 1. 社交(IM) > 2. 邮箱 > 3. 日程 > 4. 通讯录 > 5. 其他扩展功能 Lunkr.xcframework最低支持iOS 10.0及以上版本。 ### 使用指南 #### 1. 禁用Bitcode Targets - Build Settings - Build Options - Enable Bitcode - NO #### 2. 加入Lunkr.xcframework等自有依赖库 > 1. 将`LunkrSDK`复制进项目物理文件夹。(建议路径与`.xcodeproj`同层)。 > 2. 打开项目,将`LunkrSDK`文件夹拖入项目, 选中target - Build Settings - Framework Search Paths - 输入`$(PROJECT_DIR)/LunkrSDK`。(目的是为了项目找到这些库) > 3. `选中Target - General - Frameworks, Libraries, and Embedded Content`, 找到以下库,在`Embed`处选择`Embed & Sign` ``` CryptoSwift.xcframework CryptSuite.xcframework HtmlParser.xcframework LKToolKit.xcframework Log.xcframework Lunkr.xcframework QAccountFramework.xcframework QErrorFramework.xcframework QEventFramework.xcframework QRequestQueueKit.xcframework QRichWebView.xcframework ``` #### 3. 加入第三方依赖库 > Lunkr.xcframework同时采用了两种第三方库管理(原因是部分库在Pods管理下会崩溃,暂时未能找到其原因)。 > 1. CocoaPods > 2. Swift Package Manage(SPM), 1. 使用pod的方式,使用方式请参考[cocoapods官网](https://cocoapods.org/) > **注意将`LunkrDemoII `替换成你项目的target** podfile示例 ``` source 'https://cdn.cocoapods.org/' platform :ios, '10.0' # ignore all warnings from all pods inhibit_all_warnings! install! 'cocoapods', :generate_multiple_pod_projects => true target 'LunkrDemoII' do use_frameworks! pod 'AFNetworking', '~> 3.2.1', :inhibit_warnings => true pod 'UICKeyChainStore','~> 2.0.6' pod 'HMSegmentedControl','~> 1.5.2' pod 'SAMKeychain' pod 'MBProgressHUD' pod 'YYKit', :inhibit_warnings => true pod 'Realm', '~> 3.19.0' pod 'Masonry' pod 'SwiftyJSON' pod 'MJRefresh' pod 'NRTC','4.7.0' pod 'Fabric' pod 'Crashlytics' pod 'MGSwipeTableCell' pod 'Socket.IO-Client-Swift', '~> 15.2.0' pod 'FLAnimatedImage', '~> 1.0' end post_install do |installer| installer.pods_project.targets.each do |target| next unless target.name.start_with?('SwiftSoup') target.build_configurations.each do |config| next unless config.name.start_with?('Release') config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone' end end end # 苹果审核将拒绝UIWebView的使用, 移除UIWebView pre_install do |installer| puts 'pre_install begin....' dir_af = File.join(installer.sandbox.pod_dir('AFNetworking'), 'UIKit+AFNetworking') Dir.foreach(dir_af) {|x| real_path = File.join(dir_af, x) if (!File.directory?(real_path) && File.exists?(real_path)) if((x.start_with?('UIWebView') || x == 'UIKit+AFNetworking.h')) File.delete(real_path) puts 'delete:'+ x end end } puts 'end pre_install.' end ``` 2. 使用SPM(Swift Package Manager)管理几个特殊的Framework > 使用方式 [https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app) ``` https://github.com/SnapKit/SnapKit.git // 5.0.1 - NextMajor https://github.com/onevcat/Kingfisher.git // 5.15.4 - NextMajor https://github.com/scinfu/SwiftSoup.git // 2.3.2 - NextMajor ``` #### 4. Info.plist修改 > 源码编辑方式: 右击Info.plist -- Open As -- Source Code * 添加权限: 论客需要使用到图片\照相机等权限, 在主App的Info.plist中添加以下属性 * 添加ShortCut, Home页面长按或者3D Touch icon触发Menu * 添加Background权限(用于远程通知等) * UIFileSharingEnabled方便调试和日志提取(按需添加) ``` NSCalendarsUsageDescription 访问您的日历 NSCameraUsageDescription 访问您的相机以使用拍照、扫一扫等功能 NSContactsUsageDescription 访问您的通讯录以使用通讯录相关功能 NSFaceIDUsageDescription 使用您的FaceID以解锁App NSLocationWhenInUseUsageDescription 访问您的位置以使用位置相关功能 NSMicrophoneUsageDescription 访问您的麦克风以使用语音输入功能 NSPhotoLibraryAddUsageDescription App需要您的同意,才能保存图片到您的相册 NSPhotoLibraryUsageDescription 访问您的相册以发送图片 UIApplicationShortcutItems UIApplicationShortcutItemIconFile shortCut_write UIApplicationShortcutItemTitle 写信 UIApplicationShortcutItemType WriteMail UIApplicationShortcutItemIconFile shortCut_scanning UIApplicationShortcutItemTitle 扫一扫 UIApplicationShortcutItemType ScanQRCode UIApplicationShortcutItemIconFile shortCut_invoice UIApplicationShortcutItemTitle 企业发票 UIApplicationShortcutItemType Invoice UIApplicationShortcutItemIconFile shortCut_schedule UIApplicationShortcutItemTitle 日程 UIApplicationShortcutItemType Schedule UIBackgroundModes fetch remote-notification voip UIFileSharingEnabled ``` #### 5. Lunkr.xcframework使用方式 ##### 方式一:嵌入已有App 账号管理方式目前支持两种: 1. 用户名密码登录; 2. 单点登录(需要后台配合做二开) 暂仅演示用户名密码方式: ```swift var account: LKNormalAccount? { guard let username = usernameField.text, username.isEmpty == false, let password = passwordField.text, password.isEmpty == false, var server = serverField.text, server.isEmpty == false else { return nil } if server.hasPrefix("http") == false { server = "http://\(server)" } guard let serverURL = URL(string: server) else { return nil } return LKNormalAccount(username: username, password: password, server: serverURL) } @IBAction func pushBtnClicked(_ sender: Any) { guard let normalAccount = account else { return } self.normalAccount = normalAccount LunkrManager.shared.accountProvider = normalAccount LunkrManager.shared.show(from: self, email:usernameField.text, isPresent: false) } ``` ##### 3.2 App复制模式,整个App复制 > 更新AppDelegate如下 ```swift import UIKit import LKToolKit import Lunkr @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var watchApp: Any? var window: UIWindow? { get { LunkrManager.shared.appDelegate.window } set { LunkrManager.shared.appDelegate.window = newValue } } func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { let manager = LunkrManager.shared return manager.appDelegate.application(application, didFinishLaunchingWithOptions: launchOptions) } func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { return LunkrManager.shared.appDelegate.application(app, open: url, options: options) } func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { LunkrManager.shared.appDelegate.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken) } func application(_ applicatoin: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) { LunkrManager.shared.appDelegate.application(applicatoin, didFailToRegisterForRemoteNotificationsWithError: error) } func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { return LunkrManager.shared.appDelegate.application(application, continue: userActivity, restorationHandler: restorationHandler) } func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) { LunkrManager.shared.appDelegate.application(application, performActionFor: shortcutItem, completionHandler: completionHandler) } func application(_ application: UIApplication, didReceive notification: UILocalNotification) { LunkrManager.shared.appDelegate.application(application, didReceive: notification) } func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) { LunkrManager.shared.appDelegate.application(application, didReceiveRemoteNotification: userInfo) } func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { LunkrManager.shared.appDelegate.application(application, didFailToRegisterForRemoteNotificationsWithError: error) } } ``` ## 扩展能力 > 目前支持多种扩展 > * 第三方社交平台分享(如微信、QQ等) > * 视频会议(联通、网易、华为) > * 文件分享到App > * 支付宝红包 > * 崩溃 ``` // 配置的方式是拓展LunkrManager的各种delegate,如下所示: let manager = LunkrManager.shared manager.shareDelegate = self manager.chinaunicomOnlineConferenceDelegate = self manager.netEaseChatDelegate = netEaseHP manager.alipayDelegate = self manager.crashlyticsDelegate = self ``` #### 社交分享 [社交分享](MoreDocuments/SocialShare.md) #### 联通视频会议 1. 实现`LKChinaunicomOnlineConferenceProtocol`协议 2. 配置`LunkrManager.`的`chinaunicomOnlineConferenceDelegate`属性, 如下所示 ```swift LunkrManager.shared.chinaunicomOnlineConferenceDelegate = .. ``` #### 网易视频文档: > [https://dev.yunxin.163.com/docs/product/通用/NRTC/iOS_nrtc](http://dev.netease.im/docs/product/%E9%80%9A%E7%94%A8/NRTC/iOS_nrtc) 备注: searchHeader中添加ijksdl的父亲文件夹 #### ShareExtension 参考链接: [ShareExtension](MoreDocuments/ShareExtension.md) #### 使用支付宝(发红包功能) 1. 按照支付宝AlipaySDK的需要进行配置,官方文档:[https://opendocs.alipay.com/open/59/103676](https://opendocs.alipay.com/open/59/103676) 2. 设置类实现`LKAlipayProtocol` 3. 将`LKAlipayProtocl`实现类告知`LunkrManager` ``` let manager = LunkrManager.shared ... manager.alipayDelegate = self ``` ## FAQ **Q**: `$ pod install`时出错`LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60` **A**: 扩大缓存 `$ git config --global http.postBuffer 1048576000` **Q**: 如果提示第三方如AFNetworking找不到 **A**: 检查Framework Search Paths是否包含了`$(inherited)`, 没有的话加上`$(inherited)` **Q**:ld: '/Users/lunkr/Library/Developer/Xcode/DerivedData/LunkrDemo-bdbawvcvkzwksgfltvgfqqlbpwsu/Build/Products/Debug-iphoneos/Lunkr.framework/Lunkr' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/Users/lunkr/Library/Developer/Xcode/DerivedData/LunkrDemo-bdbawvcvkzwksgfltvgfqqlbpwsu/Build/Products/Debug-iphoneos/Lunkr.framework/Lunkr' for architecture arm64 **A**: 选中Target - Build Settings - Enable BItcode - No