iOS SDK TWTRComposer counting image and URL against character count



I am the latest version of TwitterKit (2.5) and when I attempt to share a Tweet with an image and URL, the TWTRComposer is counting them character count. Twitter is supposed to no longer count media against the character count, and in fact I am able to post the exact same tweet from the web that I cannot post in-app (app says it is too long).

In my current use case, my actual tweet text is 100 characters. With an image and URL, TWTRComposer is showing that I am 8 characters over the limit. Yet, I can post this exact same Tweet with the exact same content from Chrome with 16 characters to spare.

Is this a known bug?

Code snippet:

func didTapShareToTwitter() {
        // Configure composer
        let composer = TWTRComposer()
        if shareImageURL != nil {
            if let imageData = NSData(contentsOfURL: shareImageURL!) {
                composer.setImage(UIImage(data: imageData))
        // Present composer
        composer.showFromViewController(self) { result in
            if (result == TWTRComposerResult.Cancelled) {
                log("Tweet composition cancelled.")
            else {
                log("Sending tweet...")


Looks like this an iOS system-level bug, not necessarily the Twitter SDK. The TWTRComposer is actually just a wrapper around the built-in iOS sharing view controller, SLComposeViewController.

The iOS SLComposeViewController still counts attached URLs and images against the total character limit (140) for Twitter as of the latest iOS release, 10.1. Most likely, Apple just hasn’t updated their OS code since Twitter made the move to not count images and URLs against the character limit earlier this year.

After doing some testing, I have come to the following conclusion:

  • On iOS, a URL counts as 23 characters no matter original length of the URL is.
  • On iOS, an image counts as 23 characters no matter what size it is.
  • Therefore, with an image and URL, we have only 94 characters available on iOS per Tweet. And there’s nothing that can be done about it unless Twitter updates their SDK or Apple fixes the iOS SLComposeViewController.


Yes, there is support on the display side for more then 140 characters, but the compose side, still needs some improvements. Thanks for raising this up!