Swift 5.3 Platforms License

Twitter feeds for SwiftUI


  • Twitter API v1.1 and v2
  • iOS 14+
  • Xcode 13+


Add the package to Package.swift dependencies:

dependencies: [
    .package(url: "", from: "0.1.0")


Import TweetieFeed:

import TweetieFeed

In your App struct, initialize a TweetieFeedUISettings instance as StateObject, then give this instance to environmentObject:

struct MyApp: App {
    @StateObject var uiSettings = TweetieFeedUISettings()
    var body: some Scene {
        WindowGroup {
            ContentView(viewModel: ExampleViewModel())

TweetieFeedUISettings takes the following optional parameters to customize the view:

Parameter Description
backgroundDark Color change background color UI at the dark mode
backgroundLight Color change background color UI at the light mode
tweetBackgroundDark Color change tweet background at the dark mode
tweetBackgroundLight Color change tweet background at the light mode
tweetBorderDark Color change tweet border at the dark mode
tweetBorderLight Color change tweet border at the light mode
retweetedStatusTextColor Color.secondary by default: change retweeted status text
footerTextColor Color.gray by default: change text in the footer (retweet & favorite)
tweetBodyCornerRadius CGFloat 15 by default: change corner radius tweet card
localeIdentifier String by default “en_US”: change locale to display the date

In your view model, use TweetieFeedDecoder to decode the data according the API version:

class YourViewModel: ObservableObject {
    var feedDecoder: TweetieFeedDecoder?
    init(feedDecoder: TweetieFeedDecoder? = nil) {
        self.feedDecoder = feedDecoder
    func getData(version: TwitterAPIVersion = .v1) {
        // Fetch Twitter API data here
        let task = URLSession.shared.dataTask(with: request) { data, _, _ in
            DispatchQueue.main.async {
                self.feedDecoder = TweetieFeedDecoder(data: data, version: version)

In your SwiftUI view, declare a TweetieFeedView with the TweetieFeedDecoder instance created before:

VStack {
    TweetieFeedView(tweetieDecoder: viewModel.feedDecoder)
.onAppear {

Don’t forget to add the onAppear modifier that calls the view model method that handles data fetching and decoding.

You can find an example in the Example folder.

Twitter API fields (required / recommended)


tweet_mode=extended is required.


These fields are recommended for best display but not required.


  • attachments.media_keys
  • author_id is required
  • entities.mentions.username
  • in_reply_to_user_id


  • attachments
  • author_id
  • created_at is required
  • entities
  • id
  • in_reply_to_user_id
  • possibly_sensitive
  • public_metrics
  • reply_settings
  • text


  • created_at
  • description
  • entities
  • id
  • name
  • profile_image_url
  • username


  • heigh
  • media_key
  • preview_image_url
  • type
  • url
  • width

Buy Me A Coffee


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


View Github