This is one of those "it's obvious in hindsight" problems I ran into recently.
At the day job, we have been migrating all of our logging code from Aspen to Apple's new Unified Logging System. This has been a win for the most part: we got to terminate a third-party dependency, while also getting some advanced features such as log filtering based on a category or subsystem.
The problem I ran into last week was trying to debug a background session issue on my iOS device. We use the different logging levels provided by os_log to help keep users logs a bit less chatty than just spitting out print or NSLog statements everywhere. By default, the new Console app in macOS Sierra only shows logs that match the error level (or have no level at all). I needed to see our debug and info log information.
If you watch the WWDC video on the new logging system they show you a few Terminal commands you can run to adjust your logging level on the Mac. It doesn't really show you how to adjust that for an iOS device plugged into your Mac, however.
Long story short, there's no Terminal command. There's two options in the "Action" menu on the Console. Just select "Include Debug Messages" or "Include Info Messages" and you are good to go.
I sure felt dumb once I figured that out. You win this round, Apple.
There is zero point to this post. I’m only writing it in case someone else runs into this issue. Hopefully they don’t have to spend as many hours as I did to debug this. Maybe someone can also explain why this was an issue in the first place.
For the last six months or so I have been unable to use Netflix on any iOS or tvOS device (version 10.x at the time of this writing). I could sometimes get my list of content to load, but any attempt at playback failed with generic Netflix errors. Even signing into my Netflix account would be a chore. If you search the Netflix support site they offer the basic unhelpful support information: have you tried restarting your device or router?
I have a CenturyLink Gigabit fiber line, so hearing that it might be an issue with my connection seemed wrong, especially when you consider that I use a variety of other streaming services without issue. The other questionable thing is that Netflix does work on any non-iOS device such as my Xbox One, TiVo Bolt, and (gasp) Android phone. Any device with a fruit logo, however, was a no-go.
My home network setup isn’t super complex, but it’s also not a stock setup either.
CenturyLink’s fiber line comes into the house and is routed through a Technicolor C2000T modem. This is in bridge mode so it merely acts as a passthrough.
For routing and WiFi I have a Netgear AC5300 Nighthawk X8. You might be wondering why I don’t take the C2000T out of the equation and just use PPPoE with this. I tried, but there is something with that C2000T that enables full speed. I couldn’t get above 500/500 speed with just the Nighthawk in play.
iOS and tvOS devices are all connected via WiFi. iMac and random Internet of Things devices are plugged into the router via Ethernet.
What I tried and What Actually Worked
My first thought was maybe it was some sort of Quality of Service (QoS) issue with the router. I checked and I didn’t have any QoS settings enabled. Just as an experiment I tried turning them on. Still no Netflix on iOS or tvOS.
My next experiment involved trying to put my tvOS devices as the DMZ host so they had a straight passthrough from the router to the open Internet. My hope was that maybe whatever is going on in the router that was filtering the Netflix connection would just be bypassed. Hopes dashed. Still nothing.
My last idea was based off a random guess, but turned out to actually work: I disabled IPv6 on the Nighthawk. Success!
I have no idea what issue is with the chemistry between Netflix, Apple’s network stack, my router, and IPv6. All I know is that I can now watch Black Mirror.
I am mostly retired from the public speaking circuit. I do still make a point to try and do 360iDev in Denver each year, considering the proprietor is a friend and I can sleep in my bed every night of the conference. This year I did a talk that was a departure from my last few years of Auto Layout talks. Instead, I did a walkthrough of how I architect modern iOS apps. If you attended the conference and saw the talk, I hope you enjoyed it. If you didn’t attend, it’s already online and ready to watch.
I had a fun Friday evening. I received a Slack notification sent to everyone in our group stating that the iOS app was crashing on launch. This came as a surprise to me, because our most recent release had been out for several weeks at this point. It also was the most stable release in terms of number of crashes we’ve ever released. This was a good point release.
After a few minor heart palpitations, I grab a few iOS devices and try launching the App Store version of the app. Success. No crashes for me. A few other team members launch the app successfully as well. At this point, I make a suggestion straight out of Microsoft’s 1990’s playbook: restart your phone. No more crashing on launch.
My theory was correct. I’ve seen a few times in the last few months where an app will randomly begin crashing on launch for no rhyme or reason. I’ve never really tried debugging it because it wasn’t my app crashing, but now I was annoyed. I made a point to check the iOS device console next time I saw one of my apps doing this weird crash on launch behavior.
Fast forward to yesterday when I wanted to check a few things in the Major League Baseball app. I tapped the MLB icon and . . . crash. Rinse. Repeat. I decided to go on a round-robin through my apps and see if any others are crashing. Turns out Medium, United Airlines, and Pocket are also crashing. The odds of four of these major apps all shipping at-launch crashers at once are good enough to make you rich in Vegas. At this point, I am pretty confident what’s going on but I’m not at home so I can’t easily plug my phone in and see what’s happening. I’ll just have to forgo three of my most used apps because I’m not restarting my phone yet.
Once I get home, I plugged my iPhone into my Mac, popped open device console in Xcode and tried launching the failing apps again. Here’s what spit out:
Apr 30 11:17:55 iPhone kernel <Notice>: AppleFairplayTextCrypterSession::fairplayOpen() failed, error -42028
Apr 30 11:17:55 iPhone assertiond <Warning>: Unable to obtain a task name port right for pid 14063: (os/kern) failure (5)
Apr 30 11:17:55 iPhone SpringBoard <Warning>: Unable to register for exec notifications: No such process
Apr 30 11:17:55 iPhone SpringBoard <Warning>: Unable to obtain a task name port right for pid 14063: (os/kern) failure (5)
Apr 30 11:17:55 iPhone SpringBoard <Warning>: Unable to obtain a task name port right for <FBApplicationProcess: 0x13facbcf0; com.medium.reader; pid: 14063>
Apr 30 11:17:55 iPhone com.apple.xpc.launchd (UIKitApplication:com.medium.reader[0x7257]) <Notice>: Service exited due to signal: Killed: 9
Apr 30 11:17:55 iPhone SpringBoard <Warning>: Application 'UIKitApplication:com.medium.reader[0x7257]' exited abnormally via signal.
Apr 30 11:17:56 iPhone SpringBoard <Warning>: Application '(null)' exited for an unknown reason.
Apr 30 11:17:56 iPhone kernel <Notice>: IOAccessoryManager::configureAllowedFeatures: tristar: revoking mask=0xffff
Apr 30 11:17:56 iPhone iaptransportd <Warning>: CIapPortAppleIDBus: Auth timer timeout completed on pAIDBPort:0x15cd06f70, portID:01 downstream port
Apr 30 11:17:58 iPhone kernel <Notice>: AppleFairplayTextCrypterSession::fairplayOpen() failed, error -42028
Apr 30 11:17:58 iPhone com.apple.xpc.launchd (UIKitApplication:com.ideashower.ReadItLaterPro[0x33c1]) <Notice>: Service exited due to signal: Killed: 9
Apr 30 11:17:58 iPhone assertiond <Warning>: Unable to obtain a task name port right for pid 14064: (os/kern) failure (5)
Apr 30 11:17:58 iPhone SpringBoard <Warning>: Unable to register for exec notifications: No such process
Apr 30 11:17:58 iPhone SpringBoard <Warning>: Unable to obtain a task name port right for pid 14064: (os/kern) failure (5)
Apr 30 11:17:58 iPhone SpringBoard <Warning>: Unable to obtain a task name port right for <FBApplicationProcess: 0x13fed4190; com.ideashower.ReadItLaterPro; pid: 14064>
Apr 30 11:17:58 iPhone SpringBoard <Warning>: Application 'UIKitApplication:com.ideashower.ReadItLaterPro[0x33c1]' exited abnormally via signal.
Apr 30 11:17:59 iPhone SpringBoard <Warning>: Application '(null)' exited for an unknown reason.
Apr 30 11:18:03 iPhone kernel <Notice>: AppleFairplayTextCrypterSession::fairplayOpen() failed, error -42028
Apr 30 11:18:03 iPhone com.apple.xpc.launchd (UIKitApplication:com.united.UnitedCustomerFacingIPhone[0x620b]) <Notice>: Service exited due to signal: Killed: 9
Apr 30 11:18:03 iPhone assertiond <Warning>: Unable to obtain a task name port right for pid 14065: (os/kern) failure (5)
Apr 30 11:18:03 iPhone SpringBoard <Warning>: Unable to register for exec notifications: No such process
Apr 30 11:18:03 iPhone SpringBoard <Warning>: Unable to obtain a task name port right for pid 14065: (os/kern) failure (5)
Apr 30 11:18:03 iPhone SpringBoard <Warning>: Unable to obtain a task name port right for <FBApplicationProcess: 0x13fa60dc0; com.united.UnitedCustomerFacingIPhone; pid: 14065>
Apr 30 11:18:03 iPhone SpringBoard <Warning>: Application 'UIKitApplication:com.united.UnitedCustomerFacingIPhone[0x620b]' exited abnormally via signal.
Apr 30 11:18:03 iPhone SpringBoard <Warning>: Application '(null)' exited for an unknown reason.
Apr 30 11:18:07 iPhone syslogd <Notice>: ASL Sender Statistics
Apr 30 11:18:07 iPhone kernel <Notice>: xpcproxy Container: /private/var/mobile/Containers/Data/Application/C1AEAFEE-6FDD-46F1-BBAB-F3E345D35EB9 (sandbox)
Apr 30 11:18:07 iPhone kernel <Notice>: AppleFairplayTextCrypterSession::fairplayOpen() failed, error -42028
Apr 30 11:18:07 iPhone com.apple.xpc.launchd (UIKitApplication:com.mlb.AtBatUniversal[0x37dc]) <Notice>: Service exited due to signal: Trace/BPT trap: 5
Apr 30 11:18:07 iPhone ReportCrash <Notice>: Formulating report for corpse AtBat.Full
Apr 30 11:18:07 iPhone SpringBoard <Warning>: Application 'UIKitApplication:com.mlb.AtBatUniversal[0x37dc]' crashed.
Apr 30 11:18:07 iPhone ReportCrash <Warning>: Saved type '109(109_AtBat.Full)' report (3 of max 25) at /var/mobile/Library/Logs/CrashReporter/AtBat.Full-2016-04-30-111807.ips
Fairplay is the DRM Apple uses for App Store (and iTunes purchases in general). Something is going wrong with the DRM on these apps causing them to fail to launch. Confidence inspiring!
This is as far as my investigation has taken me at this point. I don’t really have a theory what is causing this. My first thought was it was caused by an app being updated, but the United app hadn’t been updated in a while and it was crashing for no reason. I am mostly writing this up because when I was trying to defend that this was an iOS issue and not a bug in our code, I really didn’t have much of a source to cite other than the few tweets I remembered seeing from other folks running into the same issue. I’d love to know more if you have any theories.
For the longest time I have been using Meslo as my monospaced font of choice in Xcode, Atom, and Terminal. I couldn’t resist the urge to give Hoefler & Co’s Operator release as a replacement. I don’t really have issue spending money on tools that make me more productive in my day to day work. I never truly considered buying a font for development work though. For $179, I could have spent that money on at least 150 iOS apps!
After rolling my eyes at the absurdity of that thought, I transferred $179 from my bank account to Mr Hoefler’s, installed the font, and updated my Xcode theme to use it at 16pt universally.
My quick verdict? I like it. I don’t starch my plaid shirts nearly enough to offer a critique on the baselines and kerning of a font. I’ll leave that to the designers. But, it’s pleasant on my eyes and I can easily tell the difference between a capital O and a zero.
Is a new font going to make you more productive? Doubtful, unless you’re using something like Papyrus. I like it though, and you might too.
If you surveyed me annually, you’d likely find that my toolkit for building Mac and iOS applications changes a bit year over year. This year, however, the changes seem to be even bigger than before. With Swift 2’s release, I made the full transition from Objective-C to Apple’s new language du jour.
The transition has not been without growing pains (hello, constantly crashing debugger!), but overall I am writing better, more idiomatic code. And this is coming from someone who spent the last decade happily writing Objective-C. Since I’m making the transition, I’ve also used it as an opportunity to re-evaluate the third-party libraries I am using in my client applications.
I tend to have a fairly reserved stance on third-party dependencies. I am not vehemently against them like some, but I also don’t want to turn my app into a Lego set where I’m merely piecing together library after library that I don’t fully understand. The tools below are things I have used and successfully deployed to production.
In the Dependency Wars, I have tried them all. I started with vanilla Git submodules, and did a brief tour of duty with Cocoapods. Submodules didn’t offer nearly enough wins for the management overhead I seem to have. Cocoapods worked for the most part, but I have fundamental disagreements with how they package and build their products.
Carthage seemed like a happy medium for me. I get the wins of using some sort of dependency management system, and it sticks with using the shared Xcode schemes that are bundled with the project itself.
This is the most recent addition to my list, but it’s one I’m growing to enjoy most. Functional programming is what all the hipster developers are doing these days, so I am trying to wrap my head around it. I may not understand why they wear wood framed glasses, tight jeans, and so much flannel, but I am starting to come around to the idea of building things functionally.
RxSwift is from the same folks who do Rx.net, RxJava, and a host of other implementations, which may or may not be appealing to you. When learning something new, documentation is important and I’ve found the docs for RxSwift to be pretty well done. There’s still cases where the generic ReactiveX documents are “TBD” in terms of RxSwift, but having the header docs fills in many of those gaps.
My biggest complaint with RxSwift isn’t so much a complaint with the library as it is with the idea of functional programming. It is a major change in how you think, so I spent most of my first few weeks re-reading docs, cursing and trying to understand what was actually happening. Eventually it will click, and when it does it’s a really nice way to build iOS libraries.
RxSwift includes a library for making UIKit more reactive, but I’m shying away from it presently. Right now I have limited RxSwift mostly to integration with network modules I build. I reserve the right to change my mind about this in the future, but right now delegates and data sources don’t bother me that much.
It is a toss-up whether there are more Swift JSON parsing libraries or Republican presidential candidates in the US. I don’t really have anything negative to say about SwiftyJSON. It works and saves me from writing JSON parsing code over and over again.
You can likely choose one of the other 107 libraries and it will do pretty much the same thing: just like a Republican presidential candidate!
I have used Core Data since it was introduced way back in OS X 10.4. I have never loved Core Data, but it has always gotten the job done and proved better than raw SQLite queries (I’m that much of a masochist).
I interviewed the Realm folks way back when on my CocoaRadio podcast and found it to be an interesting project. I just didn’t have anything to implement it in since I was already successfully deploying Core Data in my existing client projects. With a new project that ramped up early last year, I decided to give it a shot.
I’m having a hard time convincing myself to go back to Core Data for anything right now. Core Data has always felt bloated to me, especially when trying to bring up the stack in an application. I also have many battle wounds to show for Core Data threading issues over the years. All things of the past with Realm. I can query the same Realm from any thread and bringing up a new one is at most three lines of code.
Apple is working to improve Core Data each year, but I’m starting to believe they should just reboot the framework like a comic book movie and start over. Or keep it as is, and I’ll keep using Realm.
I was a longtime user of CocoaLumberjack, but was running into a issues when starting to migrate an existing client application to use Swift in some places. I also started having issues where there updates to the library would just fail to work in the application without me spending a few hours each release debugging things.
I decided to use that as a chance to write my own clean room logging implementation that does everything I need: which isn’t that much. I call it Aspen, and you probably shouldn’t use it.
It works for me and is deployed on millions of iOS devices, but it’s also something that I don’t really see growing beyond the scope of the project as is. I’d like to add log rolling and ASL support, but after that there’s not much else I need in a logging framework. If your needs are greater, any other solution will probably work better for you.
The newest piece of my kit is Fastlane, a suite of Ruby scripts from Twitter’s development folks. I am using Fastlane to help run unit tests from the command line, build releases and automatically upload them to TestFlight. The suite can do a lot more, but my needs are fairly simple.
The next piece to my Fastlane puzzle will be getting some sort of continuous integration component. Maybe next year.
Plain Old NSURLSession
You’ll notice that I’m not using a networking library like AlamoFire or similar. For most of the projects I am working on, I don’t need the extra overhead those libraries offer me. I tend to put each network request in its own Swift class and make them return an RxSwift Observable. I then have a parent class that will vend those request classes out. I may write about this more in the future, if enough people ask nicely.
Let’s imagine there is someone out there who watched last week’s WWDC keynote and thought to themselves, “This is it! Now! Now is the time for me to learn to program and build an iOS app!”
Nevermind that they are about 6 years late to gold rush, it’s an exciting proposition. Programming is fun! I come from a family of builders. The only difference between my father and grandfathers is they built homes with hammers. I sit in front of a keyboard all day typing and looking at cat GIFs.
I digress. You want to learn to be an iOS developer. What are you supposed to do? Aaron Hillegass (whose books I credit with teaching me this stuff way back when he was the only person writing about Cocoa development) says you should learn Objective-C. Ash Furrow and a few others say you should learn Swift because Objective-C is too hard.
Guess what? It doesn’t matter what language you want to learn.
If you want to be an iOS developer you realistically have four options:
Objective-C: old faithful.
Swift: New hotness.
Xamarin: The crazy kids in the corner who want to use C#.
RubyMotion: Know Ruby? Tired of arguing with DHH about whether tests are dead? You too can build an iOS app.
I’d lean towards choosing one of the first two options because they are first-party solutions provided directly by Apple, but the language you choose to learn matters little compared to learning the frameworks. The Cocoa Touch frameworks have always been the secret sauce. Whether you’re using Objective-C, Swift, C#, or Ruby you’re still going to have to learn how to use a UIButton and a UITableView.
Will you be more of an iOS developer because you took the time to learn Objective-C and it’s 20+ years of history versus Swift and its eleven days? Nope. Your customers care about what’s on the surface of your app: does it look, interact, and feel like an iOS app. If you can do that, the language doesn’t matter.
There is no right answer to this question. Choose what the language that speaks to you and then go build something awesome.