Keep It Simple Stupid

Removing ClearcutUploader errors when using GMaps iOS SDK

| comments

I worked on an iOS application that used the Google Maps SDK and noticed a bunch of logging when I backgrounded the application complaining that it couldn’t connect to some server:

2021-04-17 00:42:48.543716+0300 MyApp[73170:12130630] [connection] nw_socket_connect [C7.1:3] connect failed (fd 23) [64: Host is down]
2021-04-17 00:42:48.543851+0300 MyApp[73170:12130630] [] nw_socket_connect connect failed [64: Host is down]
2021-04-17 00:42:48.545236+0300 MyApp[73170:12130630] Connection 7: received failure notification
2021-04-17 00:42:48.545564+0300 MyApp[73170:12130630] Connection 7: failed to connect 1:64, reason -1
2021-04-17 00:42:48.545708+0300 MyApp[73170:12130630] Connection 7: encountered error(1:64)
2021-04-17 00:42:48.548091+0300 MyApp[73170:12130630] Task <170493E8-F704-4578-AB47-7B9CE76064B1>.<1> HTTP load failed, 0/0 bytes (error code: -1004 [1:64])
2021-04-17 00:42:48.951902+0300 MyApp[73170:12128623] Task <170493E8-F704-4578-AB47-7B9CE76064B1>.<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=64, NSUnderlyingError=0x600003ccb360 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=64, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <170493E8-F704-4578-AB47-7B9CE76064B1>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <170493E8-F704-4578-AB47-7B9CE76064B1>.<1>"
), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=, NSErrorFailingURLKey=, _kCFStreamErrorDomainKey=1}

And this is just one instance of it; typically it would be repeated a dozen times.

/sdcard “Permission denied” on Android

| comments

I’ve found some old notes about rooting a Motorola G4 Android phone and a puzzling issue I stumbled upon then. It may be useful to someone even though I couldn’t reproduce it now and don’t remember all the details.

I had a Moto G4 phone and it’s possible to officially unlock its bootloader in order to root it, remove some preinstalled (goog’s) crap and possibly install another firmware (Android is notoriously bad with software updates, Motorola was not very bad, they had occasional security updates). I followed one of the unlocking and rooting guides online: backed up as much stuff as I could (which is not much on a non-rooted phone), unlocked the bootloader by getting a code from Motorola, replaced the boot image, flashed TWRP, installed SuperSU, and replaced the kernel with ElementalX G4 because something didn’t work with the stock one.

Then I installed ABBYY Lingvo in the new system, but it was crashing on startup. I discovered that its directory on the internal storage (which I believe was in /sdcard/Android/) was empty and was trying to adb push it from the backup, but got “permission denied”. In fact, I couldn’t create any directory on /sdcard/. The permissions and owner on the directory were correct. Searching online didn’t find a solution, I tried a number of things, even editing platform.xml to change a setting. However when I booted into TWRP, I could write files to SD card fine.

Segregating useless built-in OS X applications

| comments

OS X is a nice and (mostly) stable operating system overall. However Apple puts so much crap and junk that may not be for everyone and that cannot be officially uninstalled. There is a bunch of standard applications and there is also a lot of standard daemons, some of which are trying to get network access to contact Apple (keyboardservicesd, studentd, seriously?!).

I don’t like having unnecessary stuff in my system and would prefer to get rid of it. I’m not sure about removing built-in applications completely, unfortunately that may have bad consequences to the stability of the system. But at least when I open the /Applications/ directory, I don’t want to see them. So a simple solution is to move them to /Applications/junk/.

The set of applications that are useless (junk) for you is your personal choice. For example: FaceTime, Home, Messages, News, Photo Booth, Siri, Stickies, Stocks. This post is how to move them away.

A few tips about Xcode’s Instruments

| comments

Time Profiler in Instruments (along with other instruments) is a great tool for profiling iOS application. It has a number of options, which are not described anywhere. The official documentation only touches the surface of Instruments; there is more information in WWDC videos, but it’s not quickly accessible in that form. Here’s a short list of findings that I inferred myself:

Xcode’s Instruments doesn’t show symbolicated stacktraces

| comments

Xcode’s Instruments is a very useful tool to profile and analyze iOS applications. For example, you can use the Time Profiler instrument to figure out which functions use the most CPU time: you see all the captured stacktraces with the number of samples for each function in the bottom half of the Instruments window. The list is supposed to show symbolicated stacktraces, that is actual function names like UIViewController.viewDidLoad() instead of their addresses in memory like 0x10c100f87, and this works most of the time until you change something and it breaks.

Keyboards on the iOS lock screen

| comments

Apple’s iOS is definitely a user-centric mobile operation system (for regular users, not so much for geeks and hackers). Its thoughtfulness also goes beyond the UI as I’ve discovered an interesting feature about the keyboards on the lock screen.

Replacing iOS application container in terminal

| comments

Xcode has the “Devices and Simulators” window (Cmd+Shift+2) where you can see the applications installed on your iOS device and more importantly can download and upload a data container for an application that you’re developing. That container contains all the data generated by that application, so that for example you can get it into a certain state where you see a bug, save it and then restore it back to device as many times as necessary. The only official way to do that is via this Xcode’s window, however I find it clumsy because you need to open the window, select the application, click the gear icon, select “Download container…” in the popup menu, select where to save it, wait and after a while a new Finder window will be helpfully open, but stealing the focus of course. This whole process is much easier with the iOS Simulator, but sometimes you just need to use the app on a real device.

As alternative, there is this great program called ios-deploy, which can almost replace a container on the device. There are a few questions on StackOverflow, like this one, about programmatically uploading/downloading an app container, however none of the answers provide a complete guide. Here I describe my recent experience with replacing an application container in the command-line using ios-deploy.

fixtags is deprecated

| comments

My fixtags script is an extension for gPodder to automatically fix the MP3 tags (of the known podcasts) so that the Sandisk Sansa Clip+’s official firmware would properly recognize them. More information about this is in my old post. There are no new firmware versions anymore and the player seems to be discontinued.

I’ve started using Rockbox on my player a few years ago and it’s better and has many more features than the stock firmware. Here are some of the ones I’m using: