Emoji in Swift

Overview

Smile

❤️ Support my apps ❤️

❤️ ❤️ 😇 😍 🤘 ❤️ ❤️

Emoji in Swift. For reference, go to https://github.com/onmyway133/emoji

CI Status Version Carthage Compatible License Platform Swift

Features

  • Support emoji sequences
  • Handle skin tones, marks, genders, variation selectors
  • Support new iOS emojis

List

List all emojis

Smile.list()
emojiList
emojiCategories

Emoji

Check if a character is emoji

Smile.isEmoji(character: "🎉") // true

Check if a string contains any emoji

Smile.containsEmoji(string: "🎈 and 🎁") // true

Count number of emoji characters in a string

Smile.countEmoji("🎈 and 🎁") // 2

Count number of non-emoji characters in a string

Smile.countNonEmoji("🎈 and 🎁") // 5

Check if a string contains only a single emoji

Smile.isSingleEmoji("🎈 and 🎁") // false
Smile.isSingleEmoji("👨‍") // true
Smile.isSingleEmoji("👩🏽‍🧑‍") // false
Smile.isSingleEmoji("just plain text") // false

Check if a string contains only emojis

Smile.isEmojiOnly("🎈 and 🎁") // false
Smile.isEmojiOnly("👨‍") // true
Smile.isEmojiOnly("👩🏽‍🧑‍") // true
Smile.isEmojiOnly("just plain text") // false

Get emoji from unicode values

XCTAssertEqual(Smile.emoji(unicodeValues: [0x1F47B]), "👻")
XCTAssertEqual(Smile.emoji(unicodeValues: [0x0001F468, 0x200D, 0x2708]), "👨‍✈")

Unmodify an emoji

Smile.unmodify(emoji: "👨🏿") // 👨

Name

Show standard name of an emoji

Smile.name(emoji: "🇳🇴") // ["REGIONAL INDICATOR SYMBOL LETTER N", "REGIONAL INDICATOR SYMBOL LETTER O"])

Search emoji by keywords

Smile.emojis(keywords: ["GRINNING"]) // 😁, 😸

Flag

Search emoji flag by country code

Smile.emoji(countryCode: "no") // 🇳🇴

Alias

Search emoji by alias

Emoji data is from https://github.com/github/gemoji/blob/master/db/emoji.json

Smile.emoji(alias: "japanese_castle") // 🏯

Find alias by emoji

Smile.alias(emoji: "🏯") // japanese_castle

Replace alias within a string

Smile.replaceAlias(string: ":santa: is coming to :european_castle:") // 🎅 is coming to 🏰

Category

Find category of emoji

Emoji data is from https://github.com/github/gemoji/blob/master/db/Category-Emoji.json

Smile.category(emoji: "😁") // people

Manipulation

Extract all emojis within a string

Smile.extractEmojis(string: "Find 🔑and🔎") // 🔑🔎

Remove all emojis within a string

Smile.removeEmojis(string: "Find 🔑and🔎") // Find and

Assemble

Smile.assemble(emojis: ["👨", "🏫") // 👨‍🏫
Smile.assemble(emojis: ["👨", "👩", "👧", "👦"] // 👨‍👩‍👧‍👦

Disassemble

Smile.disassemble(emoji: "👨‍🏫") // [👨, 🏫]

Script

Update emoji list by running

node parser.js

Installation

Smile is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Smile'

Smile is also available through Carthage. To install just write into your Cartfile:

github "onmyway133/Smile"

Author

Khoa Pham, [email protected]

Contributing

We would love you to contribute to Smile, check the CONTRIBUTING file for more info.

License

Smile is available under the MIT license. See the LICENSE file for more info.

Comments
  • This repository should be made obsolete

    This repository should be made obsolete

    Since there is no active development on this repository since Nov 2018 (that's when 2.0.0 came out as a Pod) and no newer versions are released, I believe it is your duty to make it clear in the README.md that this repository is not actively maintained and people should steer clear of it. We have this repository as a dependency and now we have to do a lot of work to get rid of it. Thank you.

    opened by vandadnp 9
  • Demo support new Xcode

    Demo support new Xcode

    We need to upgrade demo Swift version, because new Xcode does not support the lower Swift version.

    $ cd Example/SmileDemo/
    $ pod install
    Analyzing dependencies
    Fetching podspec for `Smile` from `../../`
    Downloading dependencies
    Installing Smile (1.3.1)
    [!] Unable to determine Swift version for the following pods:
    
    - `Smile` does not specify a Swift version and none of the targets (`SmileDemo`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.
    
    opened by ykws 5
  • Fix isEmoji Function

    Fix isEmoji Function

    This PR updates the isEmoji function to check containsEmoji, containsOnlyEmoji, and isSingleEmoji in one function. This also resolves #22 where isEmoji returned false on several alternate emojis and resolves #15 where isEmoji would return true for an asterisk.

    Also updated readme file to account for these changes.

    Updated podsec file to version 2.0.2. If this pull request is merged please also push new version to CocoaPods.

    opened by justinkumpe 4
  • Make ⌚️ working

    Make ⌚️ working

    It makes the ⌚️ emoji working.

    Basically I found a deeper issue with Script/parser.js I think we should clean the item.emoji in the parse function.

    When I tried to flatten the item watch in emojiList I got ["⌚️", ""] instead of just ["⌚️"].

    So I manually fixed this one + added in the unicode list().

    I'll do a check on all emojis when I have some time.

    Let me know if somebody can handle the parser.js modification.

    opened by Francescu 4
  • Fix parser to fetch Emojis

    Fix parser to fetch Emojis

    Merging this PR will make the following changes

    • Migrate to Swift 5
    • Change version number to 2.0.1
    • Fix the parser file to generate Emoji.swift and Category.swift, because the categories JSON is not found on the CDN.
    opened by vinayjn 2
  • Fix matching strings with colon

    Fix matching strings with colon

    This PR will fix matching emojis inside strings with colon, like: "Let's sing together: In the :circus_tent:, there are :dog:, :cat: and :super_unicorn:"

    Before: "Let's sing together: In the :circus_tent:, there are 🐶, 🐱 and :super_unicorn:"

    After: "Let's sing together: In the 🎪, there are 🐶, 🐱 and :super_unicorn:"

    I've also fixed some other tests.

    opened by dstranz 1
  • First fix for issue #10

    First fix for issue #10

    Regarding issue #10

    When I tried

    XCTAssertEqual(Smile.extractEmojis(string: "Hello ⏰⌛️💳🆙."), "⏰⌛️💳🆙")
    

    I got

    XCTAssertEqual failed: ("⏰️💳🆙") is not equal to ("⏰⌛️💳🆙")
    

    So only ⌛️ seems to bug for now.

    I fixed adding 0x231B, which is ⌛️, in the list.

    I also added the range 0x23F0...0x23FA

    which at least includes

    ⏳ Hourglass Not Done | U+23F3
    ⏰ Alarm Clock | U+23F0
    ⏱️ Stopwatch | U+23F1, U+FE0F
    ⏲️ Timer Clock | U+23F2, U+FE0F
    ⏸️ Pause Button | U+23F8, U+FE0F
    ⏹️ Stop Button | U+23F9, U+FE0F
    ⏺️ Record Button | U+23FA, U+FE0F
    
    opened by Francescu 1
  • isEmoji function is returning false for alternate style emojis

    isEmoji function is returning false for alternate style emojis

    I have tried several alternate style emojis and they are all returning false in isEmoji. I tried several and any alternate styles I tried would return false. A couple I know I tried are 🤴🏻, 🦹🏻‍♀️

    opened by justinkumpe 0
  • TODO

    TODO

    TODO

    • [x] Update emoji list https://unicode.org/emoji/charts/full-emoji-list.html
    • [x] Multiple code points
    • [ ] Text to emoji https://meowni.ca/emoji-translate/
    • [ ] Image to emoji https://github.com/notwaldorf/emojillate

    Read more

    • http://apps.timwhitlock.info/emoji/tables/unicode
    • http://www.unicode.org/emoji/charts/emoji-zwj-sequences.html
    • https://oleb.net/blog/2016/12/emoji-4-0/
    • http://crunchybagel.com/using-emoji-skin-tone-modifiers-in-swift/
    • https://oleb.net/blog/2017/11/swift-4-strings/
    opened by onmyway133 0
  • Smile.unmodify handles ZWJ sequences in potentially unexpected ways

    Smile.unmodify handles ZWJ sequences in potentially unexpected ways

    Consider 👩🏻‍❤️‍💋‍👨🏼, which is formed of

    • 👩 (woman)
    • Light Skin Tone
    • ZERO WIDTH JOINER
    • HEAVY BLACK HEART
    • VARIATION SELECTOR-16
    • ZERO WIDTH JOINER
    • 💋 (kiss mark)
    • ZERO WIDTH JOINER
    • 👨 (man)
    • Medium-light Skin Tone

    If I do

    Smile.unmodify(emoji: "👩🏻‍❤️‍💋‍👨🏼")
    

    Everything except the 👩 is removed. This completely changes the meaning of the emoji, which I don't think unmodify is supposed to do. I had expected 👩‍❤️‍💋‍👨 instead. Is this intentional?

    opened by Sweeper777 2
  • Package.swift

    Package.swift

    // swift-tools-version:5.1 // The swift-tools-version declares the minimum version of Swift required to build this package.

    import PackageDescription

    let package = Package( name: "Smile", platforms: [ .macOS(.v10_15), ], products: [ // Products define the executables and libraries produced by a package, and make them visible to other packages. .library( name: "Smile", targets: ["Smile"]), ], dependencies: [ // Dependencies declare other packages that this package depends on. // .package(url: /* package url */, from: "1.0.0"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages which this package depends on. .target( name: "Smile", dependencies: [], path: "./Sources/"), .testTarget( name: "SmileTests", dependencies: ["Smile"], path: "./SmileTests/"), ] )

    opened by snaill 0
  • Build taking too long

    Build taking too long

    The pod is taking too long to build after upgrading to Swift 5. From the output below it takes about 20 minutes and this is just the best case. It takes longer than that sometimes.

    [23:33:54]: ▸ Processing Smile-Info.plist
    [23:33:54]: ▸ Copying Smile-umbrella.h
    [23:53:05]: ▸ Compiling Smile_vers.c
    [23:53:05]: ▸ Compiling Smile-dummy.m
    [23:53:06]: ▸ Compiling Smile_vers.c
    [23:53:06]: ▸ Compiling Smile-dummy.m
    [23:53:06]: ▸ Linking Smile
    [23:53:06]: ▸ Linking Smile
    [23:53:06]: ▸ Generating 'Smile.framework.dSYM'
    [23:53:06]: ▸ Touching Smile.framework
    
    opened by arnoldokoth 2
  • Man Juggling 🤹‍♂ from categories does not match emoji as man_juggling

    Man Juggling 🤹‍♂ from categories does not match emoji as man_juggling

    There is a strange behavior where the man_juggling from the emojiCategories isn't recognized as an emoji using isEmoji and doesn't any values in the emojiList when I do a CTRL-F in Xcode, even though it's very clearly there in the emojiList if I look visually.

    I'm not sure exactly what's wrong or how far it extends to other emoji, but it definitely seems like something isn't right.

    opened by joeboyscout04 3
Releases(2.1.0)
Owner
Khoa
Check my apps https://onmyway133.com/apps
Khoa
Emoji in Swift

Smile ❤️ Support my apps ❤️ Push Hero - pure Swift native macOS application to test push notifications PastePal - Pasteboard, note and shortcut manage

Khoa 478 Dec 30, 2022
A Swift framework for using custom emoji in strings.

Emojica – a Swift framework for using custom emoji in strings. What does it do? Emojica allows you to replace the standard emoji in your iOS apps with

Dan 101 Nov 7, 2022
Swift emoji string parsing library

Croc is a library for parsing emojis on iOS. It provides a simple and lightweight interface for detecting, generating, categorizing and managing emoji

Joe Kalash 125 Sep 27, 2021
A category on NSString to convert Emoji Cheat Sheet codes to their equivalent Unicode characters

NSString+Emojize A category on NSString to turn codes from Emoji Cheat Sheet into Unicode emoji characters. Getting Started In order to use NSString+E

DIY.org 643 Sep 8, 2022
A searchable emoji dropdown view.

NBEmojiSearchView Integrate a searchable emoji dropdown into your iOS app in just a few lines. To start searching, the user just types a :. Then, the

Neeraj Baid 85 Dec 23, 2022
A simple library that provides standard Unicode emoji support across all platforms

Twitter Emoji (Twemoji) A simple library that provides standard Unicode emoji support across all platforms. Twemoji v13.1 adheres to the Unicode 13.0

Twitter 15k Jan 8, 2023
The world's largest independent emoji font.

The world's largest independent emoji font.

JoyPixels Inc. 337 Dec 24, 2022
BonMot is a Swift attributed string library

BonMot (pronounced Bon Mo, French for good word) is a Swift attributed string library. It abstracts away the complexities of the iOS, macOS, tvOS, and

Rightpoint 3.4k Dec 30, 2022
Fully open source text editor for iOS written in Swift.

Edhita Fully open source text editor for iOS written in Swift. http://edhita.bornneet.com/ What Edhita means? Edhita (Romaji) == エディタ (Katakana) == Ed

Tatsuya Tobioka 1.2k Jan 1, 2023
A simple and customizable Markdown Parser for Swift

MarkdownKit MarkdownKit is a customizable and extensible Markdown parser for iOS and macOS. It supports many of the standard Markdown elements through

Bruno Oliveira 687 Dec 18, 2022
Marky Mark is a parser written in Swift that converts markdown into native views.

Marky Mark is a parser written in Swift that converts markdown into native views. The way it looks it highly customizable and the supported markdown syntax is easy to extend.

M2mobi 287 Nov 29, 2022
Swift Parser Combinators

Parsey Swift Parser Combinator Framework In addition to simple combinators, Parsey supports source location/range tracking, backtracking prevention, a

Richard Wei 56 Jun 30, 2022
Great Swift String Pluralize Extension

Pluralize.swift Great Swift String Pluralize Extension case-insensitive tons of rules for irregular nouns (plural form) supports uncountable nouns all

Joshua Arvin Lat 193 Nov 8, 2022
An NSPredicate DSL for iOS, OSX, tvOS, & watchOS. Inspired by SnapKit and lovingly written in Swift.

PrediKit A Swift NSPredicate DSL for iOS & OS X inspired by SnapKit, lovingly written in Swift, and created by that weird dude at KrakenDev. If you're

Hector Matos 542 Sep 24, 2022
PySwiftyRegex - Easily deal with Regex in Swift in a Pythonic way

PySwiftyRegex Easily deal with Regex in Swift in a Pythonic way.

Ce Zheng 232 Oct 12, 2022
Regular expressions for swift

Regex Advanced regular expressions for Swift Goals Regex library was mainly introduced to fulfill the needs of Swift Express - web application server

Crossroad Labs 328 Nov 20, 2022
👩‍🎨 Elegant Attributed String composition in Swift sauce

Elegant Attributed String composition in Swift sauce SwiftRichString is a lightweight library which allows to create and manipulate attributed strings

Daniele Margutti 2.9k Jan 5, 2023
SwiftVerbalExpressions is a Swift library that helps to construct difficult regular expressions

SwiftVerbalExpressions Swift Regular Expressions made easy SwiftVerbalExpressions is a Swift library that helps to construct difficult regular express

null 582 Jun 29, 2022
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.

PhoneNumberKit Swift 5.3 framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. Features F

Roy Marmelstein 4.7k Jan 8, 2023