在 Xcode 中,如何为每个目标 iOS 应用使用不同的 AppIcon?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26668560/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:03:50  来源:igfitidea点击:

In Xcode, how do I use a different AppIcon for each target iOS App?

iosxcode

提问by gabor

I have one Xcode project (in Xcode 6.1) with a 4 targets for 4 different apps that share a lot of the same source code.

我有一个 Xcode 项目(在 Xcode 6.1 中),其中有 4 个目标,用于 4 个共享大量相同源代码的不同应用程序。

I'm trying to have each one of them show a different app icon.

我试图让他们每个人都显示不同的应用程序图标。

Going into Project > General > [select target] > App Icons and Launch Images, I see this:

进入 Project > General > [select target] > App Icons and Launch Images,我看到了这个:

Different AppIcons

不同的应用程序图标

But clicking on each AppIcon, I get to the exact same app icons - not the ones that I would like for each project.

但是单击每个 AppIcon,我会看到完全相同的应用程序图标 - 而不是我想要的每个项目的图标。

Is this just a bug in Xcode? How can I use different app icons for different targets?

这只是 Xcode 中的一个错误吗?如何为不同的目标使用不同的应用程序图标?

回答by mcfly soft

  • Click on your already existing xcassets File, where you have defined the Appicons for your first target and add a new Appicon.:
  • 单击您已经存在的 xcassets 文件,您已经在其中为您的第一个目标定义了 Appicons 并添加一个新的 Appicon。:

enter image description here

在此处输入图片说明

  • You can give the new Appicon a meaningfull name (In my case Appicon-Debug):
  • 你可以给新的 Appicon 一个有意义的名字(在我的例子中是 Appicon-Debug):

enter image description here

在此处输入图片说明

  • Go to your targets and select the new target:
  • 转到您的目标并选择新目标:

enter image description here

在此处输入图片说明

  • choose the new AppIcon under General -> "App Icons and Launch Images" -> "App Icons Source":
  • 在 General -> "App Icons and Launch Images" -> "App Icons Source" 下选择新的 AppIcon:

enter image description here

在此处输入图片说明

  • Clean the project and rebuild it.
  • 清理项目并重建它。

回答by Muhammad_Awaab

  1. Go to your app's Assets.xcassets and create a new iOS App Icon by clicking on the + button in the bottom left corner of target's section
  2. Name it AppIcon-Test or Debug or whatever name suits you.
  3. Go to xcassets folder and in the utilities panel allow target membership to both in the File Inspector View. Make sure the all target membership's are enabled for both AppIcon sets.
  4. Select the target for which you want to change icon in the project settings. In "General" Scroll down to App Icons and Launch Images. Select your appicon set for the respective target in App Icons source
  1. 转到您的应用程序的 Assets.xcassets 并通过单击目标部分左下角的 + 按钮创建一个新的 iOS 应用程序图标
  2. 将其命名为 AppIcon-Test 或 Debug 或任何适合您的名称。
  3. 转到 xcassets 文件夹并在实用程序面板中允许目标成员资格在文件检查器视图中同时存在。确保为两个 AppIcon 集启用所有目标成员资格。
  4. 在项目设置中选择要更改图标的目标。在“常规”中向下滚动到应用程序图标并启动图像。在 App Icons 源中为相应的目标选择您的 appicon 集

Go to your app's Assets.xcassets and create a new iOS App Icon by clicking on the + button in the bottom left corner of target's section

Go to your app's Assets.xcassets and create a new iOS App Icon by clicking on the + button in the bottom left corner of target's section

Name it AppIcon-Test or Debug or whatever name suits you.

Name it AppIcon-Test or Debug or whatever name suits you.

Go to xcassets folder and in the utilities panel allow target membership to both in the File Inspector View. Make sure the all target membership's are enabled for both AppIcon sets.

Go to xcassets folder and in the utilities panel allow target membership to both in the File Inspector View. Make sure the all target membership's are enabled for both AppIcon sets.

Select the target for which you want to change icon in the project settings. In "General" Scroll down to App Icons and Launch Images. Select your appicon set for the respective target in App Icons source

Select the target for which you want to change icon in the project settings. In "General" Scroll down to App Icons and Launch Images. Select your appicon set for the respective target in App Icons source

Happy coding :)

快乐编码:)

回答by Hodson

I had a similar issue when using multiple targets. Trying to change which asset set is used just didn't work, it would always just auto select the first one in the list. The way I solved this was to rename the AppIconin each asset set e.g. AppIconMobileand AppIconTablet.

使用多个目标时,我遇到了类似的问题。尝试更改使用的资产集是行不通的,它总是会自动选择列表中的第一个。我解决这个问题的方法是重命名AppIcon每个资产集中的AppIconMobileAppIconTablet

回答by Senthil Kumar Kaliathan

CLick on the Arrow at right most, which will take you to Xc-assets screen, where you can set images.

单击最右侧的箭头,将带您到 Xc-assets 屏幕,您可以在其中设置图像。

Similarly click on other target and set images. If you open your project in finder window, you can notice ProjectName.xcassets where you can see different app icons set. you can copy directly to this folder aswell

同样点击其他目标并设置图像。如果您在 finder 窗口中打开您的项目,您会注意到 ProjectName.xcassets,您可以在其中看到不同的应用程序图标集。你也可以直接复制到这个文件夹

回答by Jin

I think you just need to create Assets.xcassets for each target

我认为你只需要为每个目标创建 Assets.xcassets

Then create an AppIcon in Asset, no need to give it a different name in each asset

然后在Asset中创建一个AppIcon,不需要在每个资产中给它一个不同的名字

Select the AppIcon on the general section of each target

在每个目标的常规部分选择 AppIcon

enter image description here

enter image description here

enter image description here

enter image description here