How to include app icons into my Xcode project
Asked Answered
G

2

6

I've a problem to include new app icons. What I've already done is the following:

I archived and validated my app and got the information that icons with the resolutions 120x120 px, 152x152 px and 167x167 px are missing. So I created that PNG files and stored it in a folder in Finder.
Then I selected the root node in the project navigator (Xcode 8.2), went to the "General" tab and opened the "App Icons and Launch Images" disclosure. There I clicked the arrow icon. The asset manager is displayed with the entry "AppIcon" selected. So far so well.
Now the documentation says that I have to drag and drop my PNG files from the Finder to that asset table.

But my problem is that I'm a screenreader user so I can't use the mouse to handle such actions. That's why I want to ask whether there is an alternative way with a keyboard shortcut or over an import menu or maybe I can include the PNG files manually f.e. by editing the Xcode project file with a text editor? Thanks a lot for any help!

Gilberto answered 8/1, 2017 at 20:40 Comment(0)
P
6

The Assets.xcassets is simply a directory whithin your projects directory. You can modify the default app icon set by placing the .png files in:

Assets.xcassets/AppIcon.appiconset

and modifying the contained Assets.xcassets/AppIcon.appiconset/Contents.json file like this:

{
    "images" : [
{
  "size" : "20x20",
  "idiom" : "iphone",
  "filename" : "yourFileName.png",
  "scale" : "2x"
},
{
  "size" : "20x20",
  "idiom" : "iphone",
  "filename" : "yourFileName.png",
  "scale" : "3x"
},
{
  "size" : "29x29",
  "idiom" : "iphone",
  "filename" : "yourFileName.png",
  "scale" : "2x"
},
{
  "size" : "29x29",
  "idiom" : "iphone",
  "filename" : "yourFileName.png",
  "scale" : "3x"
},
{
  "size" : "40x40",
  "idiom" : "iphone",
  "filename" : "yourFileName.png",
  "scale" : "2x"
},
{
  "size" : "40x40",
  "idiom" : "iphone",
  "filename" : "yourFileName.png",
  "scale" : "3x"
},
{
  "idiom" : "iphone",
  "size" : "60x60",
  "scale" : "2x"
},
{
  "idiom" : "iphone",
  "size" : "60x60",
  "scale" : "3x"
},
{
  "idiom" : "ipad",
  "size" : "20x20",
  "scale" : "1x"
},
{
  "idiom" : "ipad",
  "size" : "20x20",
  "scale" : "2x"
},
{
  "idiom" : "ipad",
  "size" : "29x29",
  "scale" : "1x"
},
{
  "idiom" : "ipad",
  "size" : "29x29",
  "scale" : "2x"
},
{
  "idiom" : "ipad",
  "size" : "40x40",
  "scale" : "1x"
},
{
  "idiom" : "ipad",
  "size" : "40x40",
  "scale" : "2x"
},
{
  "idiom" : "ipad",
  "size" : "76x76",
  "scale" : "1x"
},
{
  "idiom" : "ipad",
  "size" : "76x76",
  "scale" : "2x"
},
{
  "idiom" : "ipad",
  "size" : "83.5x83.5",
  "scale" : "2x"
}
],
"info" : {
    "version" : 1,
    "author" : "xcode"
}
}

Maybe you have to create the JSON file.

Platysma answered 8/1, 2017 at 21:0 Comment(6)
My AppIcon.appiconset folder only contains the Contents.json file but no "default" icons. Is this correct? And is it strongly necessary to have a corresponding image for each entry in the json file? I ask because the validation process only demanded 120x120 px etc. but no 20x20 or 29x29... And is it necessary that I have to edit the json file manually or should I only paste the images in the folder and Xcode regenerates the file itself?Gilberto
This is correct. The JSON is not automatically created, so you will have to edit it manually. Only if you drag&drop the files in xcode. You cetrtainly have to add required images only. My Sample is meant as an example. If you are having trouble let me know.Platysma
I have edited the JSON with the complete list of possible iOS specific entries.Platysma
You're great! I followed your instructions and got it to work. The app is already uploaded. Thanks a lot for your help!Gilberto
When I do this my app won't build anymore and Xcode tells me there is no content. Where does Xcode look for yourFile.png, I have it in the same folder as Contents.json. I am also getting warnings about an "unassigned child" whatever that is.Nevanevada
I used your recommendation and drag Contents.json file also. It works.Wethington
F
1

Yes there is an alternate method to drag-and-drop:

1) Click on the assets.xcassets

2) Right click (or control-click) "AppIcon"

3) Click "Show In Finder"

4) That should take you to the actual folder where the icon set gets stored. You can copy all the individual image files (make sure they are named properly for XCode to differentiate between sizes) from wherever you have them stored, and then just paste them in here via Finder.

5) After you paste the image files in the folder, make sure they actually get pasted INSIDE the AppIcon.appiconset folder ~ they should be accessible through XCode.

Hope this helps

Fixed answered 8/1, 2017 at 20:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.