这是我的 SDK 的 podspec:
#
# Be sure to run `pod spec lint Core.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#
Pod::Spec.new do |s|
s.name = "TiendeoCore"
s.version = "0.1.10"
s.summary = "Tiendeo Core"
s.homepage = "https://www.tiendeo.com"
s.license = 'Custom'
s.author = { "Tiendeo" => "info@tiendeo.com" }
s.platform = :ios, '10.0'
#REMOTE
s.source = { "http" => "https://tiendeo.jfrog.io/tiendeo/pods/TiendeoCore/TiendeoCore-0.1.10.zip" }
#LOCAL# s.source = { :git => "https://gitlab.tiendeo.com/ios/core-ios.git", :tag => s.version }
s.dependency "Governor", "~> 0.2.5"
s.dependency "AlamofireObjectMapper", "~> 5.2"
s.dependency "Alamofire", "~> 4.8"
s.dependency "RealmSwift", "~> 3.11.1"
s.dependency "RxSwift", "~> 4.2.0"
s.default_subspec = 'Lite'
s.subspec 'Lite' do |lite|
lite.name = "Lite"
#REMOTE
lite.framework = "TiendeoCore"
#REMOTE
lite.vendored_frameworks = 'TiendeoCore.framework'
#LOCAL# lite.source_files = ["Source/**/*.swift", "Source/Core.h"]
#LOCAL# lite.public_header_files = ["Source/Core.h"]
#LOCAL# lite.resource_bundles = {
#LOCAL# 'TiendeoCore' => ['Source/**/*.{xib,png,jpg,json,xcdatamodeld,xcdatamodel,xcassets,ttf,lproj}']
#LOCAL# }
end
s.subspec 'Full' do |full|
full.name = "Full"
#REMOTE
full.framework = "TiendeoCore"
#REMOTE
full.vendored_frameworks = 'TiendeoCore.framework'
#LOCAL# full.source_files = ["Source/**/*.swift", "Source/Core.h"]
#LOCAL# full.public_header_files = ["Source/Core.h"]
#LOCAL# full.resource_bundles = {
#LOCAL# 'TiendeoCore' => ['Source/**/*.{xib,png,jpg,json,xcdatamodeld,xcdatamodel,xcassets,ttf,lproj}']
#LOCAL# }
full.xcconfig = {
'OTHER_SWIFT_FLAGS' => '$(inherited) -DFULLTIENDEOCORE'
}
full.dependency "TiendeoAuth", "~> 0.0.6"
full.dependency "FacebookCore", '~> 0.4.0'
end
end
我正在构建一个TiendeoCore.framework,用于使用命令将其上传到 cocoapods(我有一个构建 .framework 并复制模拟器架构的脚本,我正在显示脚本的主要命令):
xcodebuild -workspace "${WORKSPACE_PATH}" -scheme "${TARGET_NAME}" -configuration ${CONFIGURATION} -sdk iphoneos ONLY_ACTIVE_ARCH=NO ARCHS='arm64 armv7' BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode" BITCODE_GENERATION_MODE=bitcode clean build
xcodebuild -workspace "${WORKSPACE_PATH}" -scheme "${TARGET_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6' ONLY_ACTIVE_ARCH=NO ARCHS='i386 x86_64' BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode" BITCODE_GENERATION_MODE=bitcode clean build
将框架上传到 cocoapods 成功完成,但是当我在我的项目上安装版本(构建并运行正常)时,应用程序在启动时抛出此错误:
dyld: Library not loaded: @rpath/Bolts.framework/Bolts
Referenced from: /private/var/containers/Bundle/Application/43993CDF-61A7-405F-BA37-6FAD4B8B5FFF/ViewerPro-Demo.app/Frameworks/TiendeoCore.framework/TiendeoCore
Reason: image not found
我的 podspec 有两个子规范(lite和full),我默认安装lite版本,但在运行时TiendeoCore.framworks抛出需要full subspec的依赖,在这种情况下是 Facebook。
在我的代码中,我有一个名为FULLTIENDEOCORE的预处理标志来包含使用完整版本依赖项的源代码:
#if FULLTIENDEOCORE
import TiendeoAuth
#endif
因此,如果在OTHER_SWIFT_FLAGS中声明了标志,那么代码将被执行(这个标志被添加到完整子规范中的podspec 中)。
我不知道我错过了什么。
提前致谢。