简体   繁体   English

Xcode:根据预处理器标志从资产目录中排除构建中的图像

[英]Xcode: Exclude images in build from asset catalog according to preprocessor flag

I have two apps that share almost everything except that one shows ads according to a preprocessor macro that is configured on the Build Settings tab. 我有两个应用程序几乎共享所有内容,除了一个应用程序会根据“构建设置”标签上配置的预处理器宏显示广告。

Now, following the same rule, I need to exclude images from the Asset Catalog, so this way the app with ads doesn't include things that it shouldn't, but I don't know how to do it. 现在,遵循相同的规则,我需要从“资产目录”中排除图像,因此带有广告的应用程序不会包含不应包含的内容,但我不知道该怎么做。 Any guidelines? 有准则吗?

Thanks 谢谢

Since you have two targets in your project, the simplest solution is to have three or more image assets (xcassets) in your project. 由于项目中有两个目标,所以最简单的解决方案是在项目中具有三个或更多图像资产(xcasset)。

One with images common to both targets, one with images specific to target A, and one with images specific to target B. 一个带有两个目标共同的图像,一个带有特定于目标A的图像,另一个带有特定于目标B的图像。

Then ensure that the two target-specific assets are only targeted to their respective project target. 然后,确保这两个特定于目标的资产仅针对各自的项目目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM