swift – Cocoapod podspec上的Preprocesor标志
发布时间:2020-12-14 04:35:48 所属栏目:百科 来源:网络整理
导读:我正在构建一个在其中一个方法中使用preprocesor标志的框架.类似下面的代码: public func heyStuck(overflow: String) { #if DEBUG print(overflow) #else print("ˉ_(ツ)_//ˉ") #endif} 关键是我使用Cocoapods导入我的框架,所以为了定义框架的标志DEBUG
我正在构建一个在其中一个方法中使用preprocesor标志的框架.类似下面的代码:
public func heyStuck(overflow: String) { #if DEBUG print(overflow) #else print("ˉ_(ツ)_//ˉ") #endif } 关键是我使用Cocoapods导入我的框架,所以为了定义框架的标志DEBUG,我必须在我的App Podfile中做这样的事情: post_install do |installer_representation| installer_representation.pods_project.targets.each do |target| target.build_configurations.each do |config| if config.name != 'Release' config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)','DEBUG=1'] end end end end 有没有办法将这些信息添加到podspec文件,以避免应用程序在他们的Podfile上定义这个东西? 解决方法
我终于得到了它,在我的podspec文件中使用以下魔术:
s.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS[config=Debug]' => '-DDEBUG',} (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |