You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VS2017 for Mac的Xamarin iOS中按Target选择对应xcassets

How to Use Target-Specific XCAssets in Visual Studio 2017 for Mac (Xamarin.iOS)

Got it, let’s walk through how to set this up—this is totally doable, just a bit different from Xcode’s workflow. Here’s how to replicate that target-specific asset behavior for your Xamarin.iOS project:

Step 1: Create Separate XCAssets Catalogs

  • Right-click your Xamarin.iOS project > Add > New File
  • Pick iOS > Asset Catalog from the template list, name it something like CustomerAImages.xcassets (repeat this for every customer/target you need)
  • Add your unique images to each catalog—feel free to use identical image names across catalogs since they’ll be tied to different targets

Step 2: Assign Target Membership to Each XCAssets

This is the critical step that mirrors Xcode’s target selection:

  • In the Solution Explorer, select one of your xcassets catalogs
  • Open the Properties Pad (if it’s hidden, go to View > Pad > Properties)
  • First, confirm the Build Action dropdown is set to BundleResource—this ensures the assets get bundled with the app
  • Expand the Target Membership section (it might be collapsed by default)
  • Uncheck all target boxes except the one this catalog belongs to. For example, CustomerAImages.xcassets should only have the CustomerATarget box checked, and same logic applies to other catalogs.

Step 3: Use Images as Normal

  • Reference images in your code just like you usually would (e.g., UIImage.FromBundle("Logo"))
  • When you build a specific target, only the xcassets catalog marked for that target will be included in the app bundle—so the correct image loads automatically.

Quick Troubleshooting Tips

  • If images don’t show up, double-check the Target Membership settings—this is the most common misstep
  • Ensure every xcassets has a build action of BundleResource (not None or any other option)
  • Clean and rebuild your solution after adjusting target membership to make sure old assets are cleared from the bundle

内容的提问来源于stack exchange,提问作者Seeking guidance

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:08:31