This Swift package allows you to show a view with all available emoji on the OS, navigate through the list of emojis and categories, search for emojis based on keywords, and select an emoji.
Emoji list | Emoji search | Emoji settings |
---|---|---|
Emoji list | Emoji search |
---|---|
EmojiPicker can be integrated as an Xcode project target or a Swift package target.
- Go to
File
->Add Package Dependencies
. - Type https://github.com/tyiu/EmojiPicker.git into the search field.
- Select
EmojiPicker
from the search results. - Select
Up to Next Major Version
starting from the latest release as the dependency rule. - Ensure your project is selected next to
Add to Project
. - Click
Add Package
. - On the package product dialog, add
EmojiPicker
to your target and clickAdd Package
.
In your Package.swift
file:
- Add the EmojiPicker package dependency to https://github.com/tyiu/EmojiPicker.git
- Add
EmojiPicker
as a dependency on the targets that need to use the SDK.
let package = Package(
// ...
dependencies: [
// ...
.package(url: "https://github.com/tyiu/EmojiPicker.git", .upToNextMajor(from: "0.1.1"))
],
targets: [
.target(
// ...
dependencies: ["EmojiPicker"]
),
.testTarget(
// ...
dependencies: ["EmojiPicker"]
)
]
)
Import EmojiPicker
in the file you want to use it in:
import EmojiPicker
Then add EmojiPickerView
as a view. Here is a complete example:
import SwiftUI
import EmojiPicker
import EmojiKit
struct ContentView: View {
@State
var selectedEmoji: Emoji?
@State
var displayEmojiPicker: Bool = false
var body: some View {
VStack {
VStack {
Text(selectedEmoji?.value ?? "")
.font(.largeTitle)
Text(selectedEmoji?.localizedKeywords["en"]?.joined(separator: ", ") ?? "")
.font(.title3)
}
.padding(8)
Button {
displayEmojiPicker = true
} label: {
Text("Select standard emoji")
}
.buttonStyle(.borderedProminent)
}
.padding()
.sheet(isPresented: $displayEmojiPicker) {
NavigationView {
EmojiPickerView(selectedEmoji: $selectedEmoji)
.padding(.top, 32)
.navigationTitle("Emojis")
.navigationBarTitleDisplayMode(.inline)
}
}
}
}
You can access to sample project on folder EmojiPickerSample
This Swift package was forked from Kelvas09/EmojiPicker.