pod spec lint 错误:无法构建模块“Protobuf”,找不到文件:#import "google/protobuf/Any.pbobjc.h"
Posted
技术标签:
【中文标题】pod spec lint 错误:无法构建模块“Protobuf”,找不到文件:#import "google/protobuf/Any.pbobjc.h"【英文标题】:pod spec lint error: could not build module 'Protobuf', file not found: #import "google/protobuf/Any.pbobjc.h" 【发布时间】:2019-08-24 08:56:22 【问题描述】:我想将一些代码推送到主 pod,此代码依赖于Protobuf
。
s.dependency 'Protobuf', '3.3.0'
我尝试了以下三种方法来解决它。但我失败了。
# method 1
s.xcconfig =
# we have a math.h which conflicts with the system math.h unless
# we disable header maps
'GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS' => "1",
# method 2
s.compiler_flags = '-GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1'
# method 3
s.pod_target_xcconfig = 'GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS' => '1'
以下是我的规范文件:
Pod::Spec.new do |s|
s.name = 'KSAdSDK'
s.version = '2.0'
s.summary = 'KSAdSDK.'
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.homepage = 'http://xxxx/KSAdSDK'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = :type => 'MIT', :file => 'LICENSE'
s.author = 'xxxxx'
s.source = :git => 'http://xxx/KSAdSDK.git', :tag => s.version.to_s
s.ios.deployment_target = '8.0'
s.requires_arc = false
s.requires_arc = ['xxxx/**/*.m']
s.source_files = 'xxx/**/*'
s.public_header_files = 'xxxx/*.h'
s.frameworks = 'UIKit', 'MobileCoreServices', 'CoreGraphics', 'Security', 'SystemConfiguration', 'CoreTelephony', 'AdSupport', 'CoreData', 'StoreKit'
s.library = "z"
s.dependency 'AFNetworking'
s.dependency 'SDWebImage'
s.dependency 'MJExtension'
s.dependency 'Godzippa'
s.dependency 'Protobuf'
end
我用
pod lib lint --verbose --allow-warnings
失败了。
fatal error: 'google/protobuf/Any.pbobjc.h' file not found
#import "google/protobuf/Any.pbobjc.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
【问题讨论】:
【参考方案1】:使用
s.pod_target_xcconfig =
'GCC_PREPROCESSOR_DEFINITIONS' =>
'GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 '
https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseMessaging.podspec 上的完整示例
【讨论】:
以上是关于pod spec lint 错误:无法构建模块“Protobuf”,找不到文件:#import "google/protobuf/Any.pbobjc.h"的主要内容,如果未能解决你的问题,请参考以下文章
运行“pod spec lint”时出现“错误:预期类型”错误