1. 场景
比如 Vendor 组件通过 CocoaPods 集成神策 iOS SDK,主 App 通过 CocoaPods 集成 Vendor 组件。
如何配置神策 iOS SDK 中 DISABLE_UIWEBVIEW、DISABLE_TRACK_GPS 这两个 subSpecs?
2. podspec 文件编写
pod库项目的创建流程和简单模块组件步骤一致,不在赘述。
该文件创建了一个 PrivateLib 模块,用于封装神策 SDK存放抽象的接口和头文件。具体的内容可以查看以下代码中的注释内容。
Pod::Spec. new do |spec| spec.name = "PrivateLib" spec.version = "0.0.1" spec.summary = "description" spec.description = <<- DESC DESC spec.license = "MIT" spec.author = { "" => "" } spec.source_files = "Classes" , "Classes/**/*.{h,m}" spec.exclude_files = "Classes/Exclude" # 配置系统Framework spec.frameworks = "UIKit" , "Foundation" # 配置依赖&配置 subspec (多个 subspec 使用多行) spec.dependency "SensorsAnalyticsSDK/DISABLE_UIWEBVIEW" spec.dependency "SensorsAnalyticsSDK/DISABLE_TRACK_GPS" end |
3. 客户端集成
podfile文件如下
# Uncomment the next line to define a global platform for your project # platform :ios, '9.0' target 'SubspecDemo' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! pod 'PrivateLib' , :path => '../PrivateLib' # Pods for SubspecDemo target 'SubspecDemoTests' do inherit! :search_paths # Pods for testing end target 'SubspecDemoUITests' do # Pods for testing end end |
每日一问的答案中可能无法全完解读这个问题,如果您是相关技术专家或者是对本问题有自己的见解,欢迎带着「批判性」的态度阅读,指正其中的不足。