我正在构建一个在其中一种方法中使用预处理器标志的框架。类似于下面的代码:
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',
}
关于swift - Cocoapod podspec 上的预处理器标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38784082/