On China-model iPhone and iPad devices, the Taiwan flag emoji may not render correctly. To keep behavior consistent for those cases, FairFlag uses a fixed rule for TW.
- On iOS and iPadOS, when the country code is
TW, FairFlag always uses the bundled ROC image asset. - For all other country codes, FairFlag keeps normal emoji-based rendering.
- Convert ISO country codes to flag emoji (
String.toFlagEmoji()). - Render an emoji string as a SwiftUI
Image(FairFlag.image(emoji:)). - Render a country code as a SwiftUI
Image(FairFlag.image(countryCode:)).
- Swift 5.3+
- iOS 13.0+
- iPadOS 13.0+
- watchOS 6.0+
- tvOS 13.0+
- macOS 10.15+
- visionOS 1.0+
Add FairFlag to your Package.swift:
.package(url: "https://github.com/tatsuz0u/FairFlag", from: "1.0.0")In a SwiftUI view:
import FairFlag
let emoji = "TW".toFlagEmoji()
let countryCodeImage =
FairFlag.image(countryCode: "TW")?
.resizable()
.frame(width: 20, height: 20)
let emojiImage = FairFlag.image(emoji: "🇹🇼")