App Store review and rule-of-law

The App Store review time is a contentious issue for iOS developers. As a user of iOS, I like it, because it means that I never fear downloading an app, knowing it has at least been vetted for the worst offenses. As a developer, the biggest obstruction to making iOS development as responsive to change as Web development is undoubtedly App Store review times. Here’s Dave Verwer from iOS Dev Weekly:

So, is App Store review still providing a useful service? Did it ever? My opinion is that at the very start it definitely set a tone and stopped the immediate flooding of the store with crap. However at this point, I’m not sure it’s really providing many benefits. Half finished and completely useless apps still get through all the time so it’s definitely not providing the quality control that was promised. More importantly, it continues to stifle innovation through fear of (and the reality of) rejection as we’ve seen time and time again.

I don’t think his points make the case to remove App Store review, but rather that there should be rule of law with regards to App Store review. Inconsistent enforcement is what’s stifling innovation through fear of rejection: multiple times in my career, an app has been rejected for something that had not changed since the last version, pointlessly slowing down development. These should have been cases of “approved, but make these changes for next submission.” Furthermore, I think that organizations in good standing should get approved-by-default status with periodic audits.

GovtOS and resignation as civil disobedience

In the debate between Apple and the FBI, the software giant has filed an appeal to dismiss the the court order. On page 13, there’s a very interesting section discussing what it would take to develop the custom version of iOS that would allow the government to brute force passwords on someone’s phone (which has come to be known as “GovtOS”):

The compromised operating system that the government demands would require significant resources and effort to develop. Although it is difficult to estimate, because it has never been done before, the design, creation, validation, and deployment of the software likely would necessitate six to ten Apple engineers and employees dedicating a very substantial portion of their time for a minimum of two weeks, and likely as many as four weeks.

Up to ten engineers for up to four weeks, Apple believe GovtOS will take. I have to wonder what I would do if I were given this assignment. I consider it similar in some respects to what must have gone through the heads of Volkswagen engineers that were asked to create a way to fake emission reports: it’s immoral and it’s my job. Unique to the Apple case, however, is the addendum that it might be illegal to not do it. I do not envy the engineers that get this assignment should Apple be compelled to create GovtOS, and I imagine that it would be given to their most trusted and senior members.

I’d like to say that I’d resign in that position, but the fact is, with a court order, if someone chooses not to do it, they will be replaced with someone that will. And a project of this fragility deserves to be in the most trustworthy and capable hands. Having said that, resignation as civil disobedience would weigh heavily on my conscience.

When a word or phrase regularly finds its way into how we talk, I encourage finding another purely because it becomes cliche. E.g. "lessons learned" (or worse, learnings), "deep dive", and "considered harmful."

When a word or phrase regularly finds its way into how we talk, I encourage finding another purely because it becomes cliche. E.g. “lessons learned” (or worse, learnings), “deep dive”, and “considered harmful.”

Android and iOS development side-by-side

Mobile platforms are polarizing, and it doesn’t help that’s there’s effectively only two. To that effect, I thought it’d be instructional to complete the same simple tutorial on both platforms to get an appreciation of what each does well and what each does differently. This tutorial will read something like “beginning Android for iOS developers.” The Android portion of this tutorial is inspired by “Android Programming: The Big Nerd Ranch Guide” by Bill Phillips, Christ Stewart, Brian Hardy, and Kristin Marsicano (if you want a more rigorous look at how to do this on Android rather than a compare and contrast, it’s a good book). The goal is to make an app which presents the user with a single question and informs them if it’s correct or incorrect.

Let’s start with Android. Some preliminaries: install Android Studio and the SDK installed on your computer and start a project. Now, navigate to your custom activity XML file (app/src/main/res/layout/activity_my.xml) and create a RelativeLayoutTextView, and two Button objects.

Note that the visual editor gives you the option to either input the text into the text views and buttons directly or create a new “value” for it, and either is fine. The new value option is quite interesting, however, as it works by placing the string in an XML file of your choosing and referencing it with a key-value pair. I imagine this is hugely useful when reviewing copy or localizing, but it does add a level of indirection for smaller projects where it’s not needed. String management is a pain-point I experience on iOS, so I definitely appreciate this feature.

You should also be sure to look at the properties of your button objects and give them IDs. The IDs are used to generate a file called R.java that maps this IDs to constants so you can access them at runtime. This is the same file that the strings get entered in to. I find this cumbersome compared to IBActions and IBOutlets on iOS, which allow you to drag and drop actions and references to files as you see fit, without needed to go through a generated file.

Now you should have something that looks roughly like this:

ih

The experience of setting this up in Android Studio is much better than it was in Eclipse. The IDE has a feature to hide a lot of the configuration files that you don’t need to worry about all the time and the visual preview works pretty well. Admittedly, the drag-and-drop visual editor functionality does not work so well, as it’s difficult to get your UI element into the view collection you want it to go in. Just like in Xcode with XML for UI, you have to open up the source file and modify it manually, however I get the impression that as I learn more Android there will be a lot more time spent manually writing XML than I ever spend on iOS, which is almost exclusively to resolve conflicts.

To perform the same path on iOS, download Xcode and start a new project. Go to the storyboard file and drop your UI elements into the square view. I recommend trying out stack views to do this, as they are a new feature with iOS 9 and they’re supposed to solve some of the pains with Auto Layout. Here’s what it ends up looking like:

Screen Shot 2016-02-26 at 6.42.46 AM

Android and iOS’s visual UI editors are in many respects equals. They both are XML editors and they both have quirks. I find the layout engine in iOS, Auto Layout, to be very powerful, but many people complain that it is difficult to use so I may just be experiencing Stockholm Syndrome.

Now that we have our UI finished, let’s write some code. The next step is to hook up our buttons to fire off a UI element which indicates to the user whether or not the answer they chose is correct. On Android, you get a reference to a view object from XML by asking your activity to find the view with an ID you set in the XML file. Like so:

this.mTrueButton = (Button) this.findViewById(R.id.true_button);
this.mFalseButton = (Button) this.findViewById(R.id.false_button);

While I like that generated resource file for the images and strings, I must say, I find this a very convoluted way of getting an association between a serialized view and an activity. If this were iOS and you wanted to get a view in your view controller, you could just directly map over a reference. But this isn’t so bad. Now that we have the buttons, it’s time to give them behaviors by setting their on click listeners:

this.mTrueButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Toast.makeText(QuizActivity.this,
                R.string.correct_toast_text,
                Toast.LENGTH_SHORT).show();
    }
});

this.mFalseButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Toast.makeText(QuizActivity.this,
                R.string.incorrect_toast_text,
                Toast.LENGTH_SHORT).show();
    }
});

Note that the on click listeners are a property on the button which you define the behavior of by creating an anonymous inner class. This is a cool way of getting block-like behavior and syntax out of Java. Also, a “toast” is an Android UI element which shows up briefly towards the bottom of the screen and contains some text.

To perform this same operation on iOS, open up your storyboard and view controller side-by-side by Alt-clicking in Xcode. Then, control-click-and-drag from the UI element you want a reference to from the storyboard into the view controller file, and select that you want an IBAction, which is like an on-click listener. You can make one for each button, or if you want to get clever you can make multiple buttons to the same IBAction and determine what to do at runtime. While iOS has no native notion of toast, I’ve hacked together one using UIAlertController and Grand Central Dispatch for sake of parity.

class ViewController: UIViewController {
    @IBAction func buttonTouchUpInside(sender: AnyObject) {
        guard let sender = sender as? UIButton else { return }
        let title = sender.titleLabel?.text == "True" ? "Correct!" : "Incorrect!"
        let alert = UIAlertController(title: title, message: "", preferredStyle: .Alert)
        self.presentViewController(alert, animated: true) { () -> Void in
            let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(1 * Double(NSEC_PER_SEC)))
            dispatch_after(delayTime, dispatch_get_main_queue()) {
                alert.dismissViewControllerAnimated(true, completion: nil)
            }
        }
    }
}

This code conditionally unwraps the sender into a button, and if it is a button, checks to see if it’s title is “True” to build the “Correct!” or “Incorrect!” text to display to the user. To do this, it uses a UIAlertController with that title, presents it, and when presentation is complete it waits 1 send to subsequently dismiss this alert controller.

Swift is truly magnificent. That code block above is not a snippet, that’s the whole view controller. In Android and Java and an Activity, the whole thing becomes quite long and nested fairly quickly. It does seems that if you’re going to use anonymous inner classes and getting views by IDs, however, you have to place it in a non-top-level function somewhere.

This is just a very thin top-to-bottom slice of the development for both Android and iOS. Admittedly, I prefer iOS development on account of its new language Swift and less cumbersome SDK, but this comes at the cost of not supporting older platforms and less ubiquitous third party libraries and community discussion (which Java has plenty of). Although perhaps soon they’ll be the best of both worlds, as it was recently proposed that Swift should get Android support!

Swift ported to Android

There has been a great disturbance in the Swift community: Brian Gesiak has done the work necessary to get Swift up-and-running on Android and opened a pull request on GitHub.

This adds an Android target for the stdlib. It is also the first example of cross-compiling outside of Darwin: a Linux host machine builds for an Android target.

If this draws the ire of higher-ups at Apple, this could get … interesting. Apple have clearly acknowledged Android more than they have historically with 2 native Android apps. Further, they stand to benefit from Swift’s wider adoption. But there is a sense in which Apple loses by improving the development environment of Android with the clearly delightful Swift. On my view, Java has yet to catch up to Objective-C considering the lack of blocks, never mind Swift and its tuples.

Google have a neural network that takes a photo and returns a location

Google have trained a neural network that can determine with better accuracy than humans the geographical location given an arbitrary image; from the MIT Technology Review:

That’s impressive work that shows deep neural nets flexing their muscles once again. Perhaps more impressive still is that the model uses a relatively small amount of memory unlike other approaches that use gigabytes of the stuff. “Our model uses only 377 MB, which even fits into the memory of a smartphone,” say Weyand and co.

That’s a tantalizing idea—the power of a superhuman neural network on a smartphone. It surely won’t be long now!

That is indeed tantalizing, and while this trick is in some ways a gimmick, it’s a great part of an intelligent system. The hard part about this is to compose these skills into a system than can use the right skill at the right time, analyzing an image for location when needed, finding the shortest path when needed, seeing the trend in data structures when needed, etc.

Microsoft support Apple in the right to privacy

After the Microsoft CEO and founder expressed at best lukewarm support for Apple’ defense of the right to privacy, Bloomberg report that they’re going to stand with Apple on encryption in a big way:

Microsoft Corp. will file an amicus brief next week to support Apple Inc. in its fight with the U.S. government over unlocking a terrorist’s iPhone, President and Chief Legal Officer Brad Smith said at a congressional hearing Thursday to discuss the need for new legislation to govern privacy.

Good for them. This puts them on the right side of history, in my opinion, and I hope it’s enough to sway our government. The US government should be a leader here, because other nations will consider what happens here when making their policy.

Microsoft Acquires Xamarin

Xamarin is a cross-platform development tool that’s built on Microsoft-sponsored technologies, here’s the announcement:

As part of this commitment I am pleased to announce today that Microsoft has signed an agreement to acquire Xamarin, a leading platform provider for mobile app development.

In conjunction with Visual Studio, Xamarin provides a rich mobile development offering that enables developers to build mobile apps using C# and deliver fully native mobile app experiences to all major devices – including iOS, Android, and Windows.

This is a massive power grab from Microsoft, and could be leveraged to put them back on top. Consider that Microsoft have a way for developers to take iOS and Android codebases and ship it on Windows 10 using a compatibility-layer approach. If you look at their offerings on competitor’s platforms, you might think they’ve taken a “if you can’t beat them join them” approach, but it’s becoming more and more “if you can’t beat them become them.”

Apple introduces Podcasts Connect

A couple days ago, I received an email from Apple regarding podcasts, which announced a number of new features that the iTunes service has for podcasters, including:

Introducing Podcasts Connect
Podcasts Connect is the primary place to manage your podcasts on the iTunes Store. Here you will be able to validate and submit podcasts to iTunes. You will also be able to manage availablity once your podcast has been approved.

Get started using Podcasts Connect.

Right now it just lets you manage your shows, and it is much better than the older webforms I had to use to set up my podcast. An exciting development for anyone that wants to get into podcasting, because it’s now easier than ever. I hope this includes analytics one day, it could be a huge boon for podcasters that want to attract advertisers.

The March 2016 issue of Hacker Bits published with yours truly

A couple weeks ago, Ray Li of Hacker Bits reached out to me asking to reprint some of my writing in the periodical. I clicked around the site and found that it’s a beautifully typeset publication, check it out. Here’s a synopsis:

Wow! What a month! We just put the finishing touches on the March 2016 issue of Hacker Bits.

The issue line-up is a great mix of startups, programming bits, opinion pieces topped off with a DIY camera article!

The Walking Dead S06E10: "The Next World" Review

Spoilers ahead. After the madness and gore of the mid-season premier, The Walking Dead picks it up a couple weeks later when things have quieted down a little bit: it’s safe to rebuild walls, take care of the baby, and begin thinking of getting some more food. I have a hard time watching The Walking Dead, admittedly, because when things are going badly for our ragtag team of zombie killers, I feel sad about it. And when things are going well for our protagonists, I don’t get comfortable because I know it’s coming.

Such was the case with the first major plot point: Rick and Daryl leave together to go scavenging. It was an entertaining vignette, full of snappy dialogue and interesting developments, but before we get to that why the hell did they leave as a pair. Seems to me with the impending threat of “Negan”, which Daryl knows about and has presumably told Rick about, deserve a little more precaution. Certainly a level of precaution above and beyond blasting music while revving the engine, as Daryl rightly objected to. Further, when your hauling what is perhaps the single greatest find left around due to the “law of averages”, you do not use it to tow a soda machine, especially when you’re being hunted.

This brings us to the next plot point: Jesus. Rick and Daryl have seen some terrible things, they’ve done some terrible things, and well, it’s gotten to them. I’d have to imagine that if The Walking Dead were real, which I seem intent on treating it like it is, that they’d have killed Jesus on the spot, no questions asked. Perhaps it shocked them, perhaps they’re still hesitant to kill strangers, and perhaps either of these possibilities will turn out for the best, but the fact remains that Rick and Daryl colossally messed up in letting Jesus do what he did. Having said that, he’s a terrifically interesting character and I look forward to the content of his talk with Rick in the nude.

Much of the other vignettes of the show were built around the theme of family: where Maggie tried to convince Enid to be a part of the gang, where Carl and Enid try have fun in the wilderness like the good old days, Spencer having to confront his undead family to join a new living one, and Michonne becomes closer to the Grimes than she’s ever been. While I found the pacing of these parts a little prolonged, I enjoyed just hanging out with the bunch without too much fear that all was going to go awry.

“The Next World” was a balanced episode which leaves me excited for the future: Jesus the scoundrel fascinates me in much the same way the lead of “Negan’s people” in last episode did, #Richonne feels totally right and I caution them against getting too happy because I want neither of them to die, and the worry of Negan hangs over all of this.

I've found that Apple's backup solutions have been too confusing to be reliable in the past, TJ Luoma at MacStories is having a similar experience. I recommend a hybrid approach of cloud storage and redundant HDDs.

I’ve found that Apple’s backup solutions have been too confusing to be reliable in the past, TJ Luoma at MacStories is having a similar experience. I recommend a hybrid approach of cloud storage and redundant HDDs.

Bill Gates on Apple v. FBI

Bill Gates weighs in on what he thinks about the Apple v. FBI showdown with regards to the San Bernardino massacre:

“This is a specific case where the government is asking for access to information. They are not asking for some general thing, they are asking for a particular case,” Gates tells the Financial Times, disagreeing with Apple CEO Tim Cook that the FBI’s request would create an iPhone backdoor.

How shamefully wrong. If this were in fact just a singular request for information, the FBI would not have done it so publicly, they would not have invoked the All Writs Acts, and if I’m to speculate a bit, they would not have purposefully sabotaged their chances at legal access to the phone’s information. What more, but the Wall Street Journal is reporting that the FBI already have twelve iPhones they would want Apple to compromise.

Certification of apps for Apple platforms

An app which allows users to pirate apps snuck onto the App Store by changing the UI based on a user’s locale, location, IP, or something akin. Macworld:

A Chinese iOS application recently found on Apple’s official store contained hidden features that allow users to install pirated apps on non-jailbroken devices. Its creators took advantage of a relatively new feature that lets iOS developers obtain free code-signing certificates for limited app deployment and testing.

Coincidentally, Apple have released some news a couple days ago of an upcoming certification renewal:

How will customers be affected by the certificate renewal?
Customers who have purchased and installed iOS apps, tvOS apps, or Safari Extensions will not be affected by the certificate renewal. Users running OS X El Capitan (v10.11 or v10.11.1) may receive a notification that your Mac app is damaged if it utilizes receipt validation to request a new receipt from Apple. They can resolve this issue by restarting their Mac or updating to OS X El Capitan (v10.11.2) or later.

It seem I’m not the only one that finds certification, provisioning, and code signing confusing …

As a side note, I ran into this bug this weekend.