Swift Chat: iMessage rebuilt as a SwiftUI view (free, 1.0)

I spent about a year rebuilding iMessage in SwiftUI. It's very accurate, bubbles that only get a tail at the end of a series, typing dots breathe in a wave, Delivered fades into Read, the keyboard can be dragged down from the top of the input bar, bubbles are on springs. It uses a UICollectionView, because List and ScrollView can't do that stuff.

This week I made it free and tagged 1.0 as Swift Chat.

import SwiftChat

Chat(messages) { message in
    Message(message.text, role: message.role, timestamp: message.sentAt)
        .messageStatus(message.status)
}
.chatTypingIndicators(typing)
.chatInputCapabilities([.photoLibrary, .files])
.onChatSend { text, media in
    await conversation.send(text, media)
}

Photos and videos in bubbles, reactions, group chats, typing indicators, read receipts, pagination. iOS 18+, Swift 6.

- Package: GitHub - unionst/swift-chat: SwiftChat: an iMessage-faithful chat UI for SwiftUI. Tails, typing indicators, read receipts, attachments, keyboard handling. One view. · GitHub

Happy to answer anything. Keyboard management was probably the hardest part.

9 Likes

Swift Chat 1.0.6 adds an assistant style, which is good for AI chat apps. .chatStyle(.assistant) animates a bubble in with your question to the top of the screen and then streams the answer underneath as markdown, just like Siri and ChatGPT do. Photos come at full width, and any SwiftUI view can be placed in the assistant’s response. .chatTypingStatus also lets you add nice thinking token animations.

Chat(thread.messages, typingUsers: thread.thinking ? [assistant] : []) { message in
    Message(message.text, role: message.role, timestamp: message.sentAt)
}
.chatStyle(.assistant)
.chatTypingStatus(thread.status)

Video: Swift Chat: the assistant style
Starter app that streams Claude: GitHub - unionst/swift-chat-ai-starter: A complete iPhone chat app that streams Claude, built on Swift Chat's assistant style · GitHub

1 Like