converts a pdf into multiple app icons for iOS and watchOS
convertappicon converts a pdf into multiple app icons. It is a macOS tool written in Swift and currently supports generating iOS icons (iPhone, iPad and watch). The easiest way is to execute it from a project target script phase inside of Xcode.
IMPORTANT: Put the master pdf file into the project right alongside the destination AppIcon with an additional tailing ‘Pdf’ asset name (see sample). You do not need to bundle/copy the pdf to the target itself.
Xcode supports (named) images from pdf assets for a long time, but sadly the app icon itself is an exception: up to 18 png files have to be arranged manually inside of Xcode to provide a proper app icon.
Due to an app offering multiple, pre-defined app icons to the user as an alternative as well, this can be a cumbersome task.
For that reason, I’ve created this script during a hackathon as a proof of concept and then later moved from a bash/ImageMagick/scripting setup to a native Swift tool.
Feel free to ask questions, fork or create pull requests - [email protected]
convertappicon [-c] [-h] [-t] [-s iphone ipad watch marketing] APPICONSETPATH
APPICONSETPATH : The last parameter is the (partial) path to the destination .appiconset folder. It will traverse down and tries to find the first matching subfolder.
-c : Will clean the target folder first.
-h : Will show this help.
-t : Test only, will print app icon path, master pdf path and all possible icons only.
-s : Select icon categories: ‘iphone’, ‘ipad’, ‘watch’ or ‘marketing’ - if omitted all of them will be created.
There is a sample project showing you how the tool is going to be integrated. It was setup in the following steps:
Assets.xcassets
entry (a default AppIcon
asset should already be set up but empty)AppIconPdf
Single Scale
)convertappicon
script and add the "${SRCROOT}"
folderAppIcon
asset contains all iconsProviding "${SRCROOT}"
in a target build script is usually enough but if you have multiple icons, you must provide the full folder path.