3.5 KiB
EmojiKit
A lightweight script that queries all available emoji releases from Unicode.org and makes them easily available in any product for the Apple ecosystem.
Usage
The main idea behind this script is that there is no full list of supported emojis that can be easily used in Swift. This script fetches the full list of emojis from Unicode.org, parses them and returns a structured .json file where all emojis are sorted in their official category. The .json files can be easily read afterwards for further usage in any product.
- Clone this repository and
cdinto the repository - Run
swift run -c release EmojiKitto build the package - Move the product into
/usr/local/binto make it available systemwide withcp .build/release/EmojiKit /usr/bin/emojiKit - Call the script from anywhere with `emojiKit download -v
Alternatively you can simply run
sh build.shto do steps 2. and 3. in one go.
Arguments:
- path: Specify the directory where the
emoji_v<version>.jsonfile should be stored. Only provide the directory like/Desktopor.for the current directory, not the whole file path. - version (--version, -v): New emojis are released yearly (in general). Currently only version
14and15(latest) are supported. But you can easily extend the script by adding new cases to theEmojiUnicodeVersionenum.
Usage with Xcode
Swift Package Manager and CocoaPods support is planned for the future. Currently, you need to do some manual steps to use the emojis with Xcode and Swift.
- In your Xcode project, add a file called
emoji_v<version>to your assets, Make sure that they are included under Build Phases - Copy Bundle Resources (if not add them manually there). For each version (currentlyv14andv15) you need to add a separate file into Xcode. - Run the script as describe above and specify the directory of the files you added in Xcode as the
<path>argument. - The script will query the emojis and saves them to your files in Xcode.
- Afterwards you're ready to use them in Xcode by either reading the data yourself or using the
EmojiManager.swiftincluded in this repository. - Simply copy the
EmojiManager.swiftandEmojiCategory.swiftfiles into your Xcode project. - Afterwards you can load the emojis by calling
EmojiManager.getAvailableEmojis(). The manager automatically fetches the correct unicode version depending on the device's iOS version to only show supported ones (you need to run the script for all supported versions first to make the automatic loading work).
Note: Version 14 includes all emojis that are supported on devices from
iOS 15.4to<iOS 16.4. Devices with an iOS Version>iOS 16.5require version 15.
Error Handling
- If you see emojis on your device that are displayed as a
?you're most likely running your App on a device belowiOS 15.4. Anything belowiOS 15.4is unfortunately not supported. If you still want to use it simply add a new case in theEmojiUnicodeVersion, e.g.v13 = 13to make it work (no guarantees though). - If the
EmojiManagerdoesn't return any emojis, there are two possible reasons. First, you didn't run the script for the version you're trying to load, so your.jsonfiles are empty or non-existent. Simply run the script for all supported version and it should work. If not make sure that the.jsonfiles are included in the Build Phases - Copy Bundle Resources for each target that wants to use theEmojiManager.