- 开发的时候,经常有很多测试用文件会被拉入项目中,而打成的Release包并不需要包含这些文件。
- 在主工程中,可以在
BuildSettings
添加EXCLUDED_SOURCE_FILE_NAMES
解决这个问题。 - 可是Pod Lib里面操作就有点复杂了。
在pod lib中的配置
在LPDebugAsset.podspec
中添加资源配置
s.resource_bundles = {
'LPDebugAsset' => [
'LPDebugAsset/AssetsDebug/*', # Debug可访问
'LPDebugAsset/Assets/*', # Debug/Release可访问
]
}
上面的配置,会在TARGETS中生成蓝色资源Target:LPDebugAsset-LPDebugAsset
,会在沙盒生成文件夹:Frameworks/LPDebugAsset.framework/LPDebugAsset.bundle
如何在Release环境下,移除AssetsDebug
文件夹
方案1(不推荐)
在Podfile中添加配置EXCLUDED_SOURCE_FILE_NAMES
# 找到资源Target,并且添加配置
installer.pods_project.targets.each do |target|
if target.name == 'LPDebugAsset-LPDebugAsset'
target.build_configurations.each do |config|
if config.name == 'Release'
config.build_settings['EXCLUDED_SOURCE_FILE_NAMES'] ||= ''
config.build_settings['EXCLUDED_SOURCE_FILE_NAMES'] += ' LPDebugAsset/AssetsDebug/* LPDebugAsset/AssetsDebug/**/*'
end
end
end
end
方案1能解决问题,但是会影响到你的Podfile
方案2(推荐)
在podspec
中添加配置
s.pod_target_xcconfig = {
"EXCLUDED_SOURCE_FILE_NAMES" => "$(ExcludeFile_$(CONFIGURATION))",
"ExcludeFile_Release" => "LPDebugAsset/AssetsDebug/* LPDebugAsset/AssetsDebug/**/*",
"ExcludeFile_Debug" => "",
}
pod_target_xcconfig
不能指定只在LPDebugAsset.debug.xcconfigs
或LPDebugAsset.release.xcconfigs
中生成配置,所以采用取巧的方案来实现。