How do you provide an icon for an action extension? - ios

All the extension types use the containing app's icon, with the exception of action extension. The Apple documentation says this:
In iOS, a custom Action extension uses a template image version of its
containing app’s icon, which you must provide.
However it does not say how you must provide the icon. It says:
For information on how to add an icon to your app extension, see
Creating an Asset Catalog and Adding an App Icon Set or Launch Image
Set.
But the links to "Creating an Asset Catalog" and "Adding an App Icon" documentation are links to how to add an icon for an app, they don't contain a section on how to add an icon specifically for an action extension.
The extension target does not contain an app icon section in the XCode general settings (unlike an app), so its icon presumably must be added via an asset catalog. However, even after I added an app icon image set to my extension's asset catalog, the extension's icon is still not appearing.
How am I supposed to add an icon for an action extension? And if it's via its asset catalog then why is that not working when I've added an icon image set to the asset catalog?

First, you need to have an asset catalog. You may already have this but if you don't, this is easy to create.
Click on the group that contains the extension files.
From the File menu, select New > File....
In the iOS section, click on Asset Catalog and then click Next.
Second, we need to add the app icons to our project. Note that the icons must have a transparent background. If you try to use icons with a solid background, iOS will not display the icon.
Click the + button and choose App Icons & Launch Images > New iOS App Icon.
By default, Xcode will call the icon AppIcon but it will also warn you that this name is in use. To remove this warning, choose a different name (e.g. AppIconExtension-iOS).
Drag your icons into the 60px placeholder. You will also need 120x120 (aka #2x) and 180x180px (aka #3x) icons. You can create additional icons if you want but these are not necessary.
Third, you need to tell Xcode to use the icon when building the extension.
In the Project Navigator, select your project at the top of the tree.
Select your extension as the Target and select Build Settings.
Search for Primary App Icon Set Name (or Asset Catalog App Icon Set Name before Xcode 15) and enter the name of your icon.
Build and run the extension.

In order to get it to work its not enough to add the assets to the asset catalog - its additionally necessary to set the Asset Catalog compiler options of Build Settings section of the extension to specify the name of the app icon set within the asset catalog:

We need a monochromatic icon for Extension application which has exactly same dimensions & type as we set on Appicon(Only name & icon type is differ).
Firstly we need to include assets to the extension target
Step 1:- For adding assets click on extension scheme->Build phases
->Copy Bundle Resources ->Click + -> Add assets OR Just add by click on assets in your extension target membership.
refer below screen shot
Step 2:- Now for setting up extension App icon click on Extension
application from targets area, Go to build settings ->Search Assets
catalog compiler option ->Enter your App icon name
refer below screen shot

The documentation for action extension icons isn't particularly helpful—try this answer, which provides a worked example, or this answer coupled with the discussion continued in chat.
For the icon itself, current guidance is as follows:
Use a template image for an action extension icon. A template image uses a mask to create an icon. Use black and white with appropriate transparency and antialiasing, and don’t include a drop shadow. Template images should be centered in an area measuring about 70px by 70px.

Got a lot of troubles trying to solve that problem but I eventually found a workaround (I don't like it, but it works):
I ended up installing the last version of Xcode 7.
I opened my project with Xcode 7 and then I followed the steps provided in this answer: https://stackoverflow.com/a/27333408/3844377.
Then I ran my project from Xcode 8 and it worked like a charm.

for Xcode 14, the key has changed to Primary App Icon Set Name in the Build Settings section of the extension

Related

ActionExtension Icon

I'm trying to change default Action Extension icon but unfortunately no result. Some topics I could find look outdated already.
What I already did:
Added Assets.xcassets folder to the ActionExtension folder.
Added App Icon type image named AppIcon and provided all image sizes with transparent background.
In Build Settings of the Action Extension for Primary App Icon Set Name field set AppIcon as a value.
So I see the target image was changed but still in the iPhone gallery where I try to run the action extension it shows default main app icon.
Would be thankful for any suggestions.
Thanks

App Extension Icon not showing

I have an app extension (Fileprovider-Extension) which Icon is not showing up when I change the FileProvider location (see screenshot). This only happens on Devices (also on the simulator) which iOS Version is 8.4!
I checked already:
Extension have its own images.xcasset-catalog
This images-catalog set an icon for all possible resolutions
The build Settings of the extension Target is updated to this Asset-Catalog also the Imageset that I want to have as Extension-App-Icon
The Asset-Catalog is already in the "Copy Bundle Resources"-Phase of the extension target
When I (initial) tap on the more button to manage my locations, I see (also on iOS 8.4 devices) the AppIcon from the Host-Application... that is really confusing me.
Another device running with iOS 8.1 shows an icon on that point but this is not the icon from the extension xcasset-catalog instead it shows the AppIcon from the Host-Application.
I also try the answers from this question: SO: Why isnt my ios8 application action extension app icon showing up but nothing helps me.
Can someone give me a hint what little point I looked over?
In my case, I first added a new Asset Catalog set to my extension.
In that Asset Catalog, I added an new AppIcon, using the + menu at the bottom. Note the name is: AppIcon
I then added my images to the new AppIcon.
Then under Targets, I selected my extension, then under Build Settings under Asset Catalog Compiler - Options, I added AppIcon to the Asset Catalog App Icon Set Name field.
You have to add a separate Asset Catalog to your app extention, as your app and your extention are not sharing files.
Right click your app extention folder in the Xcode browser on the left -> New File... -> Asset Catalog (Resource).
Then add a App Icon to your asset catalog. Select asset catalog in the Xcode browser -> + -> App Icons & Launch Images -> New iOS App Icon -> Set name: AppIcon.
Last step: You have to set the Asset Catalog App Icon. Go to Build Settings of your extention and search for: Asset Catalog App Icon Set Name and enter AppIcon.
Done!
The best answer for the same as following :
Select Project -> Goto "Build Phase"
Expands the "Compile Source"
Add "images.xcassests" of your mainProject
The bigest advantage of following above step is "Memory Management" + "Decrease Size Of Project Too".
Hope It helps...

Why is my iOs launcher and appicon not applying?

I need some help figuring out why I can't get a launch icon and appicon to apply to my project. I am running xcode Version 6.3.2. Note: another developer has already applied an appicon The following I have tried:
I created an asset catalog and added new app icon and launcher image via the plus sign button in the lower left of the asset window.
In the general settings of the app I clicked on "Use Asset Catalog" for both the launcher icon source and app icon source. I selected my asset catalog and it prompts me to migrate images, which I did.
My icon and launch icon are not applying even though I have followed these steps. How do I figure out why they are not applying?
EDIT:
All of the slots for the different devices are filled with a .png image. Now that I look at it I wonder if this could be the issue- when I select use asset catalog it migrates my images which creates a new subset of launch icons and all of those slots are empty. With that subset selected my project builds fine. If I select my original subset with the icons in the slots the build fails with message - The app icon set named "AppIcon" did not have any applicable content. Same for the launch icons.
Delete the app from the simulator or device and try again. Due to caching optimizations, sometimes resources are not updated if the name doesn't change.
You might also need to clean your project and rebuild it. Select Clean from the Product menu in Xcode.
It's a long shot, but your Asset Catalog may not be included in your target. Select the catalog file, open the File Inspector and check the Target Membership. Although I believe #Dave Batton has provided the correct answer.

With Xcode 5 and Asset Catalog, are we still required to include the CFBundleIcons key in Info.plist?

Finally I gut the Asset Catalog of Xcode 5 working for the app icons.
The app supports iOS 6 and up.
The remaining puzzle piece is: Is it still necessary to include a CFBundleIcons key? And do the file names matter?
Apple put together this document which talks about including CFBundleIcons key. I am confused because I don't see what the advantage of Asset Catalog is then.
Some tips for my fellow app developers:
Some icons in the App Icon Asset Catalog have the same size. You can reuse icons. By default, Xcode will copy them. When you drag an icon from Finder to the second placeholder, Xcode will create a heavy copy of your icon. It adds a -1 to the name. When you want to reuse an icon for two placeholders, right-click your "AppIcon" Asset Catalog item in the left under the "Images.xcassets" tab, and select "Show in Finder". You will see a folder named AppIcon.appiconset which contains a Contents.json file. Open this file in a text editor (like Sublime Text or Smultron), search for the file name of the duplicated icon, and rename the entry to match the name of the original. Then delete the duplicated icon.
To reveal the Asset Catalog, click on your project file at the top of the Project Navigator. Select your target. Scroll down to "App Icons" section. Click the arrow to the right.
To remove the gloss effect added by iOS, select your "AppIcon" asset catalog on the left. Then reveal the inspector. Click on the upper right icon in Xcode to show the right panel. Then click on the rightmost icon to see the properties inspector. Check "iOS icon is pre-rendered".
The fat 512x512 and 1024x1024 iTunesArtwork files without extension are only required for enterprise apps which are made for internal Ad Hoc distribution. App Store apps don't need this.
No, you don't need put CFBundleIcons in info.plist again. Xcode automatically add this to pist file. Just create Asset Catalog, set up project and you can upload it.
For my new Apps I just setup Asset Catalog and upload to AppStore well.

iOS 7 App Icons, Launch images And Naming Convention While Keeping iOS 6 Icons

I just finished an app on iOS 6 and bought a developer account a week ago so haven't had much time playing with the iOS 7 SDK. Just downloaded the Golden Master version and trying to upgrade my app to be compatible with iOS 7.
I realised that iOS 7 requires a little work with app icons. I have checked many related question and i am confused what to do. I already have an iOS 6 app with app icons and when i installed the golden master version i saw the following:
and for launch images:
I can create new flat icons for iOS 7 while i want iOS users to keep seeing the old ones.
What should i do? Use the "Use Asset Catalog" or add the icons manually and if i am adding the icons manually then what should i name these images? Thanks!
Absolutely Asset Catalog is you answer, it removes the need to follow naming conventions when you are adding or updating your app icons.
Below are the steps to Migrating an App Icon Set or Launch Image Set From Apple:
1- In the project navigator, select your target.
2- Select the General pane, and scroll to the App Icons section.
3- Specify an image in the App Icon table by clicking the folder icon on the right side of the image row and selecting the image file in the dialog that appears.
4-Migrate the images in the App Icon table to an asset catalog by clicking the Use Asset Catalog button, selecting an asset catalog from the popup menu, and clicking the Migrate button.
Alternatively, you can create an empty app icon set by choosing Editor > New App Icon, and add images to the set by dragging them from the Finder or by choosing Editor > Import.
You should use Asset Catalog:
I have investigated, how we can use Asset Catalog; Now it seems to be easy for me. I want to show you steps to add icons and splash in asset catalog.
Note: No need to make any entry in info.plist file :) And no any other configuration.
In below image, at right side, you will see highlighted area, where you can mention which icons you need. In case of mine, i have selected first four checkboxes; As its for my app requirements. You can select choices according to your requirements.
Now, see below image. As you will select any App icon then you will see its detail at right side selected area. It will help you to upload correct resolution icon.
If Correct resolution image will not be added then following warning will come. Just upload the image with correct resolution.
After uploading all required dimensions, you shouldn't get any warning.
In case you do not want to use Asset Catalog, you can add an iOS 7 icon for an old app by creating a 120x120 .png image. Name it Icon-120.png and drag in to the project.
Under TARGET > Your App > Info > Icon files, add one more entry in the Target Properties:
I tested on Xcode 5 and an app was submitted without the missing retina icon warning.
Okay adding to #null's awesome post about using the Asset Catalog.
You may need to do the following to get the App's Icon linked and working for Ad-Hoc distributions / production to be seen in Organiser, Test flight and possibly unknown AppStore locations.
After creating the Asset Catalog, take note of the name of the Launch Images and App Icon names listed in the .xassets in Xcode.
By Default this should be
AppIcon
LaunchImage
[To see this click on your .xassets folder/icon in Xcode.]
(this can be changed, so just take note of this variable for later)
What is created now each build is the following data structures in your .app:
For App Icons:
iPhone
AppIcon57x57.png (iPhone non retina) [Notice the Icon name prefix]
AppIcon57x57#2x.png (iPhone retina)
And the same format for each of the other icon resolutions.
iPad
AppIcon72x72~ipad.png (iPad non retina)
AppIcon72x72#2x~ipad.png (iPad retina)
(For iPad it is slightly different postfix)
Main Problem
Now I noticed that in my Info.plist in Xcode 5.0.1 it automatically attempted and failed to create a key for "Icon files (iOS 5)" after completing the creation of the Asset Catalog.
If it did create a reference successfully / this may have been patched by Apple or just worked, then all you have to do is review the image names to validate the format listed above.
Final Solution:
Add the following key to you main .plist
I suggest you open your main .plist with a external text editor such as TextWrangler rather than in Xcode to copy and paste the following key in.
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon57x57.png</string>
<string>AppIcon57x57#2x.png</string>
<string>AppIcon72x72~ipad.png</string>
<string>AppIcon72x72#2x~ipad.png</string>
</array>
</dict>
</dict>
Please Note I have only included my example resolutions, you will need to add them all.
If you want to add this Key in Xcode without an external editor, Use the following:
Icon files (iOS 5) - Dictionary
Primary Icon - Dictionary
Icon files - Array
Item 0 - String = AppIcon57x57.png
And for each other item / app icon.
Now when you finally archive your project the final .xcarchive payload .plist will now include the above stated icon locations to build and use.
Do not add the following to any .plist: Just an example of what Xcode will now generate for your final payload
<key>IconPaths</key>
<array>
<string>Applications/Example.app/AppIcon57x57.png</string>
<string>Applications/Example.app/AppIcon57x57#2x.png</string>
<string>Applications/Example.app/AppIcon72x72~ipad.png</string>
<string>Applications/Example.app/AppIcon72x72#2x~ipad.png</string>
</array>

Resources