4 preprocessor frameworks cocoapods swift
我正在构建一个在其中一个方法中使用preprocesor标志的框架.类似下面的代码:
public func heyStuck(overflow: String) {
#if DEBUG
print(overflow)
#else
print("¯\\_(?)_//¯")
#endif
}
Run Code Online (Sandbox Code Playgroud)
关键是我使用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
Run Code Online (Sandbox Code Playgroud)
有没有办法将这些信息添加到podspec文件,以避免应用程序在他们的Podfile上定义这个东西?
小智 8
我终于得到了它,在我的podspec文件中使用以下魔术:
s.pod_target_xcconfig = {
'OTHER_SWIFT_FLAGS[config=Debug]' => '-DDEBUG',
}
Run Code Online (Sandbox Code Playgroud)
您可以尝试使用prefix_header_contents。例如:
s.prefix_header_contents = #define DEBUG 1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
900 次 |
| 最近记录: |