Archive for May 10, 2016

Tuesday, May 10, 2016 [Tweets] [Favorites]

Some Static Analyzer Warnings Off by Default

Peter Steinberger:

The Static Analyzer in Xcode 7.3 learned a few new tricks that are off by default.

I added the following to my xcconfig file:

CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES
CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES
CLANG_ANALYZER_NONNULL = YES
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES

Nicolas Bouilleaud:

I thought “Missing localizability” was about missing translations, which would be super useful.

Instead, it warns when using raw, unlocalized NSStrings into UI methods. Which is cool, but less useful.

Now how does clang know which API is “UI”? Behold

It’s pretty impressive in that it can even find an NSString that’s used to create an NSAttributedString that’s used for a menu title. However, it also finds some false positives because it assumes that every string needs to be localized. For some that doesn’t make sense. And others, such as my alert help anchors, may not need to be based on your specific situation.

Clang:

If your project deliberately uses unlocalized user-facing strings (for example, in a debugging UI that is never shown to users), you can suppress the analyzer warnings (and document your intent) with a function that just returns its input but is annotated to return a localized string.

[…]

There is currently no solid mechanism for suppressing an analyzer warning, although this is currently being investigated.

However:

When the static analyzer is using clang to parse source files, it implicitly defines the preprocessor macro __clang_analyzer__. One can use this macro to selectively exclude code the analyzer examines.

I’m using that because the analyzer complains about an AuthorizationItem.value being NULL even though the documentation says it can be.

Update (2016-05-11): Note that the analyzer warnings don’t work for Swift code.

PSPDFKit Framework Size

PSPDFKit:

The PSPDFKit SDK covers most of the PDF specification, which contains thousands of pages, and thus is quite complex. PSPDFKit includes a complete PDF renderer, cryptography and many UI components. This results in a lot of code and thus a sizable binary, although there are certain factors that make it appear larger than it actually is. We’re working hard to ensure the framework size stays as low as possible.

[…]

The PDF specification requires us to embed a sizeable list of character maps that add a few megabytes per architecture to ensure that text in PDF form can be converted to Unicode to make search and text selection work as expected.

[…]

PDF has been around since 1993 and evolved a lot since then. This also means that there is a lot of legacy baggage in the specification - and one of the main promises of PDF is that even your 20-year old documents will still render as they were, pixel-perfect. The specification, currently at version 1.7, has 756 pages.

[…]

Next to the official specification, there’s also “real world” PDF which often has bugs based on misunderstandings or bugs in creation software that need specific workarounds and hacks. Adobe Acrobat is very forgiving in terms of invalid references, duplicate entries, typos and allows various drawing command variations that are nowhere documented - these are things that have to be found out via trial and error and also add to the complexity of a rendering engine.

Tweetbot 4.3 Introduces “Topics” for Easier Tweetstorm Creation

Federico Viticci:

Here’s how Tapbots turned a hacky workaround into an elegant option: you don’t have to actually reply to yourself, remove your username, or chain tweets every time. You can just tweet by opening the compose screen and assigning a topic. Under the hood, Tweetbot will find existing tweets belonging to a topic, it’ll fetch the latest tweet from that group, and it’ll send the new tweet as a reply to it. It even takes care of automatically stripping your username at the beginning of the tweet. Everything happens behind the scenes. You don’t have to manage any of it, and you’ll end up with a series of threaded tweets that’s really a string of messages in reply to each other. It’s much simpler and faster than creating a tweetstorm by replying to yourself. It feels like a native Twitter feature.

It gets better if you decide to publish a topic as a collection. Until today, Tweetbot had no way to display Twitter Collections, let alone create new ones. Twitter itself doesn’t support adding tweets to collections on its iOS app – you’ll have to use Tweetdeck. With Tweetbot 4.3, Tapbots added support for the Collection API to add tweets from a topic into a collection. Ironically, Tweetbot has a better chance at making collections more widely used than Twitter’s own iOS apps.

Dropbox API v2

Alexandra Feldman (via Max Seelemann):

Developers, it’s time to start migrating your apps to API v2. To help with this transition, today we’ve published a migration guide that will take you through all of the changes you’ll need to make to get your app running on API v2. […] Remember, any new functionality in the Dropbox API will only be added to API v2. So, upgrade your apps to v2 now, and make sure your users are getting the most out of your app’s Dropbox integration.

Tim Johnsen:

In a bold move, Dropbox’s client library for iOS was written in Swift instead of Objective-C like their v1 library was. Furthermore, their Swift client library was written in a way that’s actually incompatible with Objective-C, making it challenging for a lot of existing apps using the v1 library to adopt.

Many developers are unhappy with this decision, as there’s not a clear path to upgrade from v1 to v2 that doesn’t involve rewriting an app in Swift or adding a Swift-to-Obj-C compatibility layer.

[…]

A couple weeks back I decided to start writing an Objective-C Dropbox v2 client library to use in Close-up, and I’m proud to announce today that I’m open sourcing that library. It’s named TJDropbox, you can check it out here!

Previously: Dropbox API v2 Drops Objective-C SDK.

Update (2016-06-29): Alexandra Feldman:

As of today, Dropbox API v1 is deprecated. This includes both the user endpoints (a.k.a. the Core API), and the team endpoints (a.k.a. the Business API). In order to provide our developers with the most up-to-date features and support a single, consistent platform, we’ll be turning off API v1 a year from now, on 6/28/2017.

Dropbox:

We are working on an Objective-C SDK for API v2, and expect to release it in August.

Ole Zorn:

Good to hear, but announcing a shutdown date before having an SDK for >90% of existing iOS apps seems insane.

No More Mac Accelerometers

Avi Drissman:

Apple stopped putting accelerometers into MacBooks. Never in the new MacBooks, not since 2009 in the Air line, not since 2013 in the Pros.

He was using it to implement the deviceorientation property in Google Chrome.

Apple:

All Intel-based Mac notebooks have Sudden Motion Sensor technology. […] Computers with Solid State Drives (SSD) or Flash Storage do not use SMS as the drives have no moving parts.

Lost Calendar Events, Change Notifications, and iCloud

Google Calendar initially did not seem to be fully reliable with iOS, so I’ve been using iCloud’s calendar pretty much from the beginning. It worked great until about a month ago. Since then, I’ve lost at least four calendar events, in a strange way. I would edit an event’s title or note and see this reflected on the calendar. Then, within a day or so, the event would disappear from all my devices. The only reason I noticed this is that, because of the recent edit, it was fresh in my mind that I had an upcoming appointment.

My first thought was that maybe I had deleted the events by mistake. The events were on a shared calendar, and my wife had subscribed to receive e-mail notifications of any changes that I made. She had an e-mail for each edit, but there were no records of the deletions. So it doesn’t seem like I deleted them. She wouldn’t intentionally delete my events, and if she had done so by accident I should have received notification e-mails, which I didn’t.

Could it be due to a client bug or error? I don’t think so, based on my rough understanding of how CalDAV works. Plus, an accidental delete command should have generated a notification e-mail from iCloud, anyway. I use Fantastical on all my devices, so I contacted Flexibits Support. I got an immediate reply, but they had not heard of problems like this and agreed that it didn’t seem like Fantastical was responsible. Calendar clients don’t directly add and delete shared files; they send streams of commands to the server. So even if the wrong command were sent, the server should still have sent a notification.

Step two was that I wanted to make sure I wasn’t missing any other calendar events, ones that were not fresh in my mind. I archive my old calendars to PDF, so I know I have a safe copy of everything from prior years. But I certainly don’t want to miss something that’s coming up.

Apple’s tools don’t seem to provide a good way to answer this question. Calendar does not support browsing using Time Machine. The Web version of iCloud did recently add a way to restore previous calendar versions, but this is not a good fit for several reasons. First, there is no way to download or browse your calendar backups, much less compare them to find the differences. You have to overwrite your current calendar—actually all of your current calendars, and reminders. Second, restoring a backup is problematic. It warns you that “all sharing information will be removed” and that “scheduled events will be cancelled and recreated, and invitations reissued.” Plus, it wasn’t clear to me what to do. How far back should I restore? How exactly would I find deleted events? Reapplying all the changes from the backup to now would be practically impossible, so I would actually need to restore again, from the most recent backup, and then try to recreate just the deleted events. If there were a problem with the backup or restore I could end up in a much worse situation. I didn’t like this approach.

A better idea seemed to be to dig into the files myself. I had backups from my Mac and could compare the files if needed. But, even better, I have been making regular Git archives of my local Calendar store, which is essentially a folder of .ics files, one per event. I was able to look through the Git logs and see which files had been deleted. They were all ones that I had edited recently. I recreated the events manually in Fantastical.

Step three was to try to set up better logging for the future. If I could easily see a log of the changes that I had made, it would help me to notice anything missing, and I would also have a backup, of sorts, that could be used for easier manual reconstruction. iCloud’s e-mail change notifications would make a pretty good log, but they only notify you of changes that other people make. To get a complete log of changes, I needed to create a separate Apple ID that would only be used to receive notifications. It turns out that doing this from the iCloud Web site doesn’t work because you won’t have access to Calendar, only to the iWork apps. I had to sign into the iCloud account from a Mac OS X installation in VMware in order to activate the Calendar features. Then I could access Calendar from the Web. (The e-mail notification option is only in the Web version, anyway.)

At this point, I thought I was done except that, a day or so later, the notification e-mails stopped. I had not touched that iCloud account since enabling the notifications, so I know that I didn’t change anything. However, when I logged in again I found that “Email me shared calendar updates” was mysteriously unchecked. I checked it again and since then the notifications have worked as desired. Fingers crossed that this continues.

In conclusion, iCloud Calendar is not as reliable as I thought it was. This is probably not the type of reliability problem that would show up in Apple’s statistics. Indeed, I did not report it to Apple because I did not know how to do so in a useful way. Contacting Apple’s support didn’t seem like a productive avenue, and since my Mac is more than three years old it’s no longer covered by Apple Care, anyway. So I’m hoping this was just a fluke that won’t happen again. More generally, Apple seems to be trying to get rid of the notion of files, but the tools for dealing with non-file-based data are few and crude. And this all becomes more complicated when the data is shared among multiple users.

Tim Schmitz:

The details have shifted over the years, but the basic form remains the same: [Notes] Changes made on one device sometimes don’t show up on others. The situation improved somewhat since Apple introduced CloudKit and started migrating apps to it, but problems still occur. It happened to me just recently: I added a note to the Apple Notes app on my iPhone, then switched to my Mac, where Notes was already running. No note.

[…]

I get where Apple’s coming from: They want sync to feel seamless and effortless, something that happens without the user having to think about it. But the fact of the matter is, it doesn’t work that way. Sync rarely does, because it’s a very hard problem to solve. Apple isn’t alone in having trouble with it by any measure. But by not giving users a way out when problems do happen, they increase the perception that Apple services don’t work well.

Tom Harrington:

iCloud backups from iOS are broken. Again.

If you think your phone is backing up to iCloud, you should check. When it fails, it often fails silently, and for weeks at a time.
Don’t trust iCloud backups on your iOS devices.

See also: Siracusa’s Pages lament.

Ben Thompson:

Cloud services, meanwhile, are still less reliable than Apple’s competition, and the integration — Apple’s supposed strength! — with Apple’s software is at best a source of irritation and at worst very worrisome from a security perspective: little things like constantly being prompted to enter one’s password are not only annoying but also corrosive when it comes to what should be a healthy skepticism about sharing the keys to your life.

The problem in all these cases is that Apple simply isn’t set up organizationally to excel in these areas[…] The root problem in all these cases is the lack of accountability: as long as the iPhone keeps the money flowing and the captive customers coming, it doesn’t really matter if Apple’s services are as good as they could be. People will still use the App Store, Apple Music, and iCloud, simply because the iPhone is so good.

Update (2016-05-10): Russell Ivanovic:

Tried to sync a desktop background over iCloud Drive. On the other side: “Can’t open Document (null)”. Can’t copy the file either.

Deleted the PNG, added it again, same thing. Gave up and put it in DropBox, works fine.

Update (2016-05-11): John Chaffee informed me that BusyCal’s log of changes from the server could help spot deletions. BusyCal also has an automatic backup feature that can restore a single calendar and does not have to overwrite existing calendars.

Update (2016-05-12): Hwee-Boon Yar:

I have had events that were around for a while mysteriously duplicated. When I delete one of them, both disappeared.

Update (2018-05-01): I’m continuing to have problems with iCloud Calendar not consistently sending e-mail change notifications.