Giter VIP home page Giter VIP logo

alternate-icons's Introduction

AlternateIcons

Build Status Requires macOS 10.10+ Requires Swift 4.0 Requires Xcode 9

AlternateIcons is a Swift script that automates adding alternate app icons to your iOS app. Group your alternate icons inside an asset catalog, add a build phase and let the script set up your app. No more manual maintenance required!

Installation

From a Pre-built Archive

You can download a pre-compiled binary for the version you want to install in the Releases section of this repository.

Once the archive is expanded, run the install.sh script to install the script on your system.

From Source

You can build and install AlternateIcons from source using Make:

git clone https://github.com/alexaubry/alternate-icons.git
cd alternate-icons
make
make install

Setting up your app

To set up AlternateIcons as an Xcode build phase, do the following:

  1. Add your main icon to your main asset catalog.

  2. Create a new Xcode asset catalog to store your icons, and do not add it to your target.

NOTE In this example, we'll name the catalog "AlternateIcons".

  1. Add your alternate app icons to this asset catalog, using the 'New iOS App Icon' template.

  2. In the Build Phases section of your project target, add a new Run Script phase. The script should be:

    embed-alternate-icons
    

    You now need to specify the path to the Asset Catalog you've created at step 2 under "Input Files", for example:

    $(SRCROOT)/AlternateIcons.xcassets
    

    NOTE: This Run Script phase needs to be the last build phase in your build.

  3. Build your app.

Et voilà! All the icons have automatically been embedded into your app and are ready for use!

Changing the icon

You can now change the icon from your code using:

UIApplication.shared.setAlternateIconName(iconName) { error in
    // handle the result
}

Where iconName is the name of an icon set in your alternate icons asset catalog or nil if you want to return to the default icon.

📚 Read the documentation on developer.apple.com

Demo

A demo project is included in the Demo/ folder, to help you set up your app.

Make sure to install AlternateIcons before you build it.

How it works

Every time you build your app, the script will perform the following steps:

  1. Get the build products location from environment variables passed by Xcode
  2. Parse the Asset Catalog to build a list of icons to embed
  3. Copy the alternate icon files in the app bundle
  4. Update the CFBundleIcon and CFBundleIcon~ipad sections of the Info.plist with the list of alternate icon file names

Authors

Alexis Aubry, [email protected] <@_alexaubry>

Acknowledgements

AlternateIcons uses these open source libraries:

alternate-icons's People

Contributors

alexisakers avatar hackinggate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

alternate-icons's Issues

Can't compile library

Following the instructions, the project does not compile properly anymore. Looks like it can't reach the Files dependency for me at least. Running Mojave and Xcode 10

Build Failing

Getting this error:

Parsing build context
The operation couldn’t be completed. (Files.FileSystem.Item.PathError error 0.)
Command /bin/sh failed with exit code 1

screen shot 2018-03-26 at 12 34 57 pm

Having troubles sending Testfligh builds

Hey, first thank you for sharing this script with us. Its great! 👏

I'm having problems with the latest Xcode 9 build (beta6). When trying to send builds to testflight it gives me this errors:

[10:17:14]: Transporter transfer failed.

[10:17:14]: description length:8180571

ERROR ITMS-90713: "Missing Info.plist value. A value for the Info.plist key CFBundleIconName is missing in the bundle 'XXXXXX'. Apps that provide icons in the asset catalog must also provide this Info.plist key. For more information see http://help.apple.com/xcode/mac/current/#/dev10510b1f7."



[10:17:14]: description length:8180571

ERROR ITMS-90713: "Missing Info.plist value. A value for the Info.plist key CFBundleIconName is missing in the bundle 'XXXXXX'. Apps that provide icons in the asset catalog must also provide this Info.plist key. For more information see http://help.apple.com/xcode/mac/current/#/dev10510b1f7."

ERROR ITMS-90022: "Missing required icon file. The bundle does not contain an app icon for iPhone / iPod Touch of exactly '120x120' pixels, in .png format for iOS versions >= 7.0."

\nERROR ITMS-90022: "Missing required icon file. The bundle does not contain an app icon for iPhone / iPod Touch of exactly '120x120' pixels, in .png format for iOS versions >= 7.0."

The call to the iTMSTransporter completed with a non-zero exit status: 1. This indicates a failure.

If you have any info about this i can help submit a PR fixing this issue, just need some guidance :)

Thanks 👍

Support for asset catalog folders

For organizational purposes, could it be possible to support using icons that are in folders in the asset catalog? I tried but I didn't see any extra icons in the Bundle

Generation process fails if asset contains any sizes without icons

By default, Xcode will create icon assets with many sizes, not all of which will be filled. For instance, CarPlay and "iTunes Marketing" are created in Xcode 9, which there's no need to fill with images for app icons in most cases.

If you don't fill sizes with images, the filename key will be missing entirely:

    {
      "size" : "40x40",
      "idiom" : "iphone",
      "scale" : "2x"
    }

When encountering such items, the app fails with the following error: 💥 The operation couldn’t be completed. (Unbox.UnboxError error 0.)

The only way to get around this is to manually strip these parts out using a text editor. Unfortunately, since these are valid as far as Xcode is concerned, they empty sections will be re-added if you open the file again with Xcode.

Dependency

swift package clean
swift package update
Fetching https://github.com/JohnSundell/Files.git
error: dependency graph is unresolvable; found these conflicting requirements:

Dependencies: 
    https://github.com/JohnSundell/Files.git @ 1.11.0..<2.0.0
make: *** [build] Error 1

dyld: Library not loaded: @rpath/libswiftCore.dylib

Hi! Thanks for making this. It has worked great but after I updated macos & xcode with iPhoneOS13.2 to their latest versions I get an error in the script build phase.

[11:08:45]: ▸ �[35mdyld: Library not loaded: @rpath/libswiftCore.dylib�[0m
[11:08:45]: ▸ �[35m Referenced from: /usr/local/bin/embed-alternate-icons�[0m
[11:08:45]: ▸ �[35m Reason: image not found�[0

I have tried solutions out there but nothing works.

Works only on a clean build forlder

I've installed this, cleaned the build project and it works. If I stop and run it again it's like it doesn't see the assets, it sets only the primary icon.

If I clean the build project & run it again it works, but id doesn't on a second run without clean build

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.