Home / iOS / TidBITS News Shows How an Old 32-bit iOS App Becomes 64-bit – TidBITS

TidBITS News Shows How an Old 32-bit iOS App Becomes 64-bit – TidBITS

As Adam explained in “Apple to Deprecate 32-bit iOS Apps” (15 May 2017), Apple has been slowly tightening the noose on 32-bit apps, first introducing 64-bit processors in new devices, then requiring that newly submitted apps include a 64-bit “slice,” then permitting submission of apps without a 32-bit slice, and now warning users that 32-bit-only apps won’t run in future systems. You may even now be seeing some favorite old app threatened with extinction. And you may be wondering why the developer doesn’t just update it for 64-bit and keep it alive.

If the App Store no longer lists this app, there’s your answer: the developer is no longer paying Apple the annual $99 membership fee and thus isn’t actively maintaining the app. But even for an active Apple Developer Program member, updating an old app to 64-bit isn’t so simple. True, it’s usually trivial to turn on 64-bitness and recompile the app. But when an app project is opened and compiled with the latest version of Xcode, it is linked against Apple’s most recent system software development kit (SDK). That changes everything. The most recent system is iOS 10, and the app may not be ready for iOS 10.

Reviving TidBITS News — Let’s take as an example the TidBITS News 2.0 app that I’ve just updated for iOS 10. It was last compiled against the iOS 6 SDK. So how did it manage to keep running in iOS 7, 8, 9, and 10? Basically, the device’s system has been giving TidBITS News a lot of help, essentially by pretending to be iOS 6. A screenshot of the old TidBITS News app next to the new one is a dead giveaway:

On the left, you see TidBITS News running under iOS 10; but it doesn’t look like an iOS 10 app. There’s a separate black status bar (and there’s a black linen-weave background, visible behind the date display, that Apple abandoned years ago). This is iOS 10 emulating iOS 6. Compare that to the new TidBITS app on the right.

iOS 10 apps have a transparent status bar; the navigation bar, with its gradient background color, stretches up behind it. (I’ll talk about other interface changes later.)

And the app’s look is the least of our worries. To compile and run as an iOS 10-native app, TidBITS News must speak iOS 10. Technically, it must adopt the iOS 10 application programming interface (API) — the way an app talks to the runtime. A lot has changed under the hood, since iOS 6, in how you do that. That’s why, following the publication of my developer book “Programming iOS 6,” I’ve had to write four subsequent editions (entitled “Programming iOS 7” and so on).

To revive TidBITS News, therefore, I effectively had to rewrite the code from scratch as if I were creating the same app today, doing things the iOS 10 way. Luckily, TidBITS News is a fairly small, simple app; it has only three “scenes” — the master view (the list of article headlines and blurbs), the detail view (one complete article), and the player view (for listening to a recorded version of an article). But imagining a much more elaborate app, you can appreciate why a developer might not be willing to recast an old 32-bit app as 64-bit — it could be more work than it’s worth. (And the fact that Apple forces all updates to be given away for free means that it will generate absolutely no income from existing users. Is it
any wonder apps are abandoned?)

The rest of this article describes how the iOS 10 TidBITS News app differs from the iOS 6 version. If such technicalities don’t interest you, just download the new TidBITS News and check it out! Even if you’re not a developer, however, you might find the details to be an interesting illustration of how much iOS has changed in just four years.

Language — The iOS 6 programming language was Objective-C. With iOS 8, Apple introduced Swift, and I chose to rewrite the new TidBITS News in Swift because that has made the app’s code much easier for me to read and maintain. I’m sorry, diehard Objective-C fans, but I just find Swift a lot more elegant and legible.

On the downside, switching to Swift makes the app a larger download, because a Swift app must include the entire Swift language — Swift isn’t yet built into your device’s system the way Objective-C is.

Split View — On an iPhone, the TidBITS News app is a navigation interface: you see just the master view, and when you tap a headline/blurb listing, it is replaced by the detail view. On an iPad, TidBITS News appears as a split view, with both those “scenes” together, the master view on the left and the detail view on the right.

In iOS 6, the split view was an iPad-only widget. That meant that TidBITS News was effectively two apps in one, with two completely different interfaces and two distinct sets of code for dealing with them.

Nowadays, the split view is native to both the iPad and the iPhone. To cope with the iPhone’s smaller size, the split view automatically collapses so that it looks and behaves like the old navigation interface. This change made the rewrite simpler, although managing a split view so that it looks and works correctly under all circumstances turns out to be rather tricky.

Player — The iOS 6 TidBITS News app plays an online recorded article using a widget called MPMovieController. Apple abandoned that widget some time back, replacing it with AVPlayerViewController.

This change has given me more control over how the player view appears. There used to be an ugly QuickTime logo that I couldn’t get rid of; that logo is now gone. On an iPhone, the player view covers the screen; on an iPad, it is inset somewhat, with the rest of the interface visible darkly behind it. This is much less obnoxious on the large screen, I think. (You, the user, can make the player itself fullscreen, but my advice is: don’t. If I could have found a way to prevent you from doing this, I would have.)

iPad Split Screen — Return with me now to those halcyon days in 2010 when I first wrote TidBITS News. In those primitive times, developers worshipped a magic number: 320. The iPhone was 320 pixels wide, and that was an immutable fact — so much so that I had actually hard-coded it into the app. The iPad, too, came in only one size, and the split view master display was also 320 pixels wide. In effect, the iPad’s master display was an iPhone inside the iPad.

Over the years, as Apple has introduced more hardware, iPhone screens have become wider and iPads have become bigger. As if this weren’t bad enough, iOS 9 introduced split screen mode, which lets users of modern iPads slide another app’s interface in from the right side. You can even resize the split to make two apps share the screen simultaneously. I found coping with this to be the hardest part of the rewrite — so hard, in fact, that for a time I contemplated opting out of this feature entirely. (There is a switch for turning it off in the app bundle’s system settings.)

The difficulty is two-fold. First, depending on the device and the size of the split, the app effectively changes from an iPad app to an iPhone app, and then back again when the user removes the split, in real time. Second, the range of possible sizes, and in particular the range of possible aspect ratios, that the app can adopt is bewildering, ranging from exceedingly tall and thin to virtually square. This turn means that a split view’s master view can have even more possible widths.

A modern app’s interface must, therefore, be planned so as to cope with these changes. I think I’ve managed to do that, but honestly, I’m not entirely certain. I wish Apple had never introduced this feature.

Decisions, Decisions — Other design changes were more or less elective surgery:

  • I changed the fonts of the headline/blurb display in the master view because I wanted to adopt Dynamic Type — the font size depends on your setting in Settings > Display & Brightness > Text Size.

  • I removed the label at the top of the master view telling when you last updated from the RSS feed, freeing more screen real estate. That information is now visible when you slide the master table down to reveal the refresh control.

  • The detail view now shows the article’s title statically at the top so you know what article you’re reading even as you scroll through its body. (The title is offset downward for a complicated reason: it’s a tappable link, but Apple extends the tappable area of the navigation bar buttons downward, so that in trying to tap the title, when it was flush up against the navigation bar, I found myself accidentally tapping a button instead.)

  • The iOS 6 detail view displays an article’s content in a UIWebView. The modern-day analog is WKWebView; UIWebView still exists, but it’s no longer under active development by Apple, so I’ve chosen to adopt WKWebView. I don’t think you’ll be able to tell the difference.

  • When you tapped a link in the detail view, you used to be rocketed into Safari. That was a pity, because it took you out of the TidBITS News app, perhaps accidentally. iOS 9 introduced the SFSafariViewController, which effectively allows a Safari process to be embedded inside another app; I’ve now adopted that feature. (If, however, you preview a link on a device with 3D Touch, you can still end up in Safari; I hope to change that in a future update.)

  • One major feature of the iOS 6 version is actually missing in the iOS 10 version: state saving and restoration. This won’t matter to you until you run TidBITS News, background it to use another app, and come back later to find that iOS has killed TidBITS News in the background. In an ideal world, you wouldn’t even notice this had happened because you would be able to pick up right where you’d left off. In the new version, however, if iOS decides to reclaim the memory TidBITS News was using, you won’t return to the story you were previously reading. Instead, the app starts from scratch, goes out on the Internet to get a new copy of the feed, and starts over at whatever is now the first article. Fortunately, TidBITS
    News is relatively tiny, so it’s less likely to be expunged from memory than most apps. I hope, in some future update, to add state restoration back in.

Give It a Try! — I’m fond of the TidBITS News app. It’s how I read TidBITS! Just as important, I use it as a teaching tool, because it illustrates a number of fundamental aspects of standard iOS app architecture. So I wanted to keep it going, and I’ve used the threat of extinction under the new 64-bit regime as an excuse to do so.

If the old TidBITS News app was too crusty for you, I hope you’ll give the new version a try. It’s free, and will remain so as long as I maintain it.


Source link

About admin

Check Also

Apple Claims iOS 11 Update Stops Hacking Tool That Can Easily Brute Force iPhone 7 Passcodes – Hot Hardware

Yesterday, a video hit YouTube that could have been alarming to any Apple users anyone …

Leave a Reply

Your email address will not be published. Required fields are marked *