我正在构建一个在其中一个方法中使用preprocesor标志的框架.类似下面的代码: public func heyStuck(overflow: String) { #if DEBUG print(overflow) #else print("¯\\_(ツ)_//¯") #endif} 关键是我使用Cocoapods导入
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',
}
