OMG, Apple rejected my App!

After releasing my first RubyMotion app (FC St.Pauli chants), I’m currently working on another one for Freifunk Hamburg.

I am using Testflight with a group of 10+ beta testers, to verify that my app is working properly and has no issues whatsoever.

The Review Process

When I think that an app is close to be feature complete, I create a version that can be pushed to the AppStore. This process involves setting up a distribution certificate and other stuff in iTunes connect. It’s a little time consuming and the review-process usually takes some weeks, especially for new apps.

I was not totally surprised that the first revision got rejected by Apple, eventhough they stated, that the app crashed on startup, which none of my beta testers had experienced. I thought that this might be due to some iOS 7 related changes.

So I just submitted an updated version to the review process. Unfortunately that version also got rejected…

The Crash Report

The latest reject was also due to a crash on startup. In case of a crash, Apple provides a Crash Report in the Resolution Center (it’s super easy to find… NOT: iTunes Connect>Manage Your Apps>[The App Icon]>View Details>Links>Resolution Center).

There is a lot of info in such a crash report. It starts with some basic infos about the device and app environment:

Incident Identifier: 7B2A05A2-E9C3-47F8-90DC-3C37BA634D69
CrashReporter Key:   edb549cbc4b5919b7c8a04beb0db00da1ada7c41
Hardware Model:      xxx
Process:             freifunk [6726]
Path:                /var/mobile/Applications/44317BE9-04A0-4B3E-A3D8-24134AE1B06C/freifunk.app/freifunk
Identifier:          de.nofail.freifunk
Version:             0.0.1 (0.0.1)
Code Type:           ARM (Native)
Parent Process:      launchd [1]
 
Date/Time:           2013-09-13 08:06:36.406 -0700
OS Version:          iOS 7.0 (11A465)
Report Version:      104

then comes the root cause:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  0

followed by the backtrace when the crash occured:

Last Exception Backtrace:
(0x2fe08f4e 0x3a6156aa 0x2f85ac 0x2f86d8 0x2608f4 0x25df9c 0x2c78f8 0x2e887c 0x2e003a 0x2c81c4 0x232d50 0x2e8854 0x2e003a 0x22f9e8 0x22fc60 0x2302f0 0x325eacb2 0x325ea702 0x325e4d0e 0x3257f6a2 0x3257e9a4 0x325e44f8 0x34a38708 0x34a382f2 0x2fdd39e2 0x2fdd397e 0x2fdd2152 0x2fd3cce2 0x2fd3cac6 0x325e3794 0x325dea3c 0x42d9c 0x42860)

infos about the threads that were active during the crash:

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
[...]
9   CoreFoundation                	0x2fd3cd58 CFRunLoopRunSpecific + 636
10  CoreFoundation                	0x2fd3cac6 CFRunLoopRunInMode + 102
11  UIKit                         	0x325e3794 -[UIApplication _run] + 756
12  UIKit                         	0x325dea3c UIApplicationMain + 1132
13  freifunk                      	0x00042d9c 0x32000 + 69020
14  freifunk                      	0x00042860 0x32000 + 67680
 
Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib        	0x3abc183c kevent64 + 24
1   libdispatch.dylib             	0x3ab02220 _dispatch_mgr_invoke + 228
2   libdispatch.dylib             	0x3ab01fa6 _dispatch_mgr_thread$VARIANT$mp + 34
 
Thread 2:
0   libsystem_kernel.dylib        	0x3abd4c7c __workq_kernreturn + 8
1   libsystem_pthread.dylib       	0x3ac3adc6 _pthread_wqthread + 306
2   libsystem_pthread.dylib       	0x3ac3ac80 start_wqthread + 4
 
Thread 3 name:  WebThread
Thread 3:
[...]
6   WebCore                       	0x37ebebae RunWebThread(void*) + 414
7   libsystem_pthread.dylib       	0x3ac3cc1a _pthread_body + 138
8   libsystem_pthread.dylib       	0x3ac3cb8a _pthread_start + 98
9   libsystem_pthread.dylib       	0x3ac3ac8c thread_start + 4

Thread 4:
0   libsystem_kernel.dylib        	0x3abd4c7c __workq_kernreturn + 8
1   libsystem_pthread.dylib       	0x3ac3adc6 _pthread_wqthread + 306
2   libsystem_pthread.dylib       	0x3ac3ac80 start_wqthread + 4
 
Thread 0 crashed with ARM Thread State (32-bit):
    r0: 0x00000000    r1: 0x00000000      r2: 0x00000000      r3: 0x00002060
    r4: 0x00000006    r5: 0x3ca9318c      r6: 0x00000000      r7: 0x27dce594
    r8: 0x1450efa0    r9: 0x00000001     r10: 0x14569fb0     r11: 0x00000000
    ip: 0x00000148    sp: 0x27dce588      lr: 0x3ac3da33      pc: 0x3abd41fc
  cpsr: 0x00000010 

and the address space:

Binary Images:
0x32000 - 0x334ffb freifunk armv7  <3ae0aadc89773fe8a07f885fdaff2237> /var/mobile/Applications/44317BE9-04A0-4B3E-A3D8-24134AE1B06C/freifunk.app/freifunk
0x2bee8000 - 0x2bf0878a dyld armv7  <b37cba000c7d3f8ea414f060d45ce144> /usr/lib/dyld
0x2edd9000 - 0x2edd9fff Accelerate armv7  <8e17835efc9234da89e3080c47fad906> /System/Library/Frameworks/Accelerate.framework/Accelerate
[...]

Analyzing the Report

It’s not obvious what to do with such a report so Apple gives a Technical Note on this topic. You can also find some information in the Debugging Guide of the RubyMotion docs.

The big problem with the crash report are the missing identifiers. There is no hint for what might stand behind any of the memory addresses noted in the backtrace or whatever. That’s were Symbolication comes into play.

Symbolicating your RubyMotion Crash Report

Symbolication is the the process of converting the numeric addresses in the stacktrace to matching parts of the codebase. In order to get this working, you will have to keep the *.dSYM files that were generated with your release build. They are in the same folder as your .ipa file, that you are uploading to the AppStore (ie build/iPhoneOS-5.1-Release/freifunk.dSYM/).

It’s a good idea to backup those files! Otherwise you won’t have the possibility to ever know why a crash happened.

Symbolication is pretty easy once you know what to do. You can use the atos command line utility to “convert numeric addresses to symbols of binary images or processes”. Go to the release folder of your app and run the command with the exception backtrace, use the first address of the binary image as your base address and point to the executable binary:

cd build/iPhoneOS-5.1-Release
atos -o freifunk -l 0x32000 -arch armv7 0x2fe08f4e 0x3a6156aa 0x2f85ac 0x2f86d8 0x2608f4 0x25df9c 0x2c78f8 0x2e887c 0x2e003a 0x2c81c4 0x232d50 0x2e8854 0x2e003a 0x22f9e8 0x22fc60 0x2302f0 0x325eacb2 0x325ea702 0x325e4d0e 0x3257f6a2 0x3257e9a4 0x325e44f8 0x34a38708 0x34a382f2 0x2fdd39e2 0x2fdd397e 0x2fdd2152 0x2fd3cce2 0x2fd3cac6 0x325e3794 0x325dea3c 0x42d9c 0x42860

This produces a somewhat readable output:

0x2fe08f4e
0x3a6156aa
__vm_raise() (in freifunk) + 468
rb_vm_raise (in freifunk) + 280
rb_exc_raise (in freifunk) + 4
rb_name_error (in freifunk) + 92
rb_mod_const_missing (in freifunk) + 116
dispatch_rimp_caller(objc_object* (*)(objc_object*, objc_selector*, ...), unsigned long, objc_selector, int, unsigned long const*) (in freifunk) + 272
rb_vm_dispatch (in freifunk) + 4502
rb_const_get_0 (in freifunk) + 684
rb_scope__init_testflight__ (in freifunk) (app_delegate.rb:45)
dispatch_rimp_caller(objc_object* (*)(objc_object*, objc_selector*, ...), unsigned long, objc_selector, int, unsigned long const*) (in freifunk) + 232
rb_vm_dispatch (in freifunk) + 4502
vm_dispatch (in freifunk) + 504
rb_scope__application:didFinishLaunchingWithOptions:__ (in freifunk) (app_delegate.rb:3)
__unnamed_2 (in freifunk) + 316
0x325eacb2
0x325ea702
0x325e4d0e
0x3257f6a2
0x3257e9a4
0x325e44f8
0x34a38708
0x34a382f2
0x2fdd39e2
0x2fdd397e
0x2fdd2152
0x2fd3cce2
0x2fd3cac6
0x325e3794
0x325dea3c
main (in freifunk) (main.mm:15)
start (in freifunk) + 36

The interesting parts here in this stack are rb_scope__application:didFinishLaunchingWithOptions:__ (in freifunk) (app_delegate.rb:3) and rb_scope__init_testflight__ (in freifunk) (app_delegate.rb:45). They show that the app crashes during initialization in didFinishLaunchingWithOptions when calling the method init_testflight with the error const_missing. This is the matching code part:

  def init_testflight
    TestFlight.takeOff(NSBundle.mainBundle.objectForInfoDictionaryKey('testflight_apitoken'))
  end

So the problem seems to be that TestFlight was missing somehow. This was kind of weird, because I was using TestFlight for distributing my beta builds and all worked fine. Doing some grep in the compiled sources, I saw that the TestFlight SDK was not included in the distribution build. The underlying problem was, that the TestFlight source path was only set in an development block:

  app.development do
    app.testflight.sdk = 'vendor/TestFlightSDK'
    [...]
  end

Moving out of there fixed my crashing App version.

So the Freifunk App finally made it and you can get the in the AppStore!

DZone API and iPhone app

As I already mentioned, I am currently getting my hands dirty with Objective-C and iPhone application development.

The biggest problem with getting started was that I had no idea what application I could write for that device that could become somewhat usable. As I am a passionate tech reader, I consume a lot of articles posted on DZone. Usually I use a feed reader like NetNewsWire for that, which works very well for my MacBook but is nearly useless on the iPhone, because the DZone site is not very mobile friendly…

Problems

Since there was no DZone iPhone application on the marked I started working on it. Parsing DZone feeds was easy, even though the buildin XML support on iOS sucks. There were some nice libraries that made my life easier.

No deeplink

The DZone RSS feed does not provide a deeplink to the actual linked article, so one would still land on the DZone page… Since DZone does not provide an API currently, I started working on my own Rails application hosted on Heroku. Spidering the RSS, calling the page and extracting the link to the article is fragile, but it works (currently).

No voting

One of my goals was to let the iPhone user vote for the article while reading it. The lack of an API forced me to do some more fragile login and posting stuff to the DZone page, but it works too (currently)!

You can read more about the API I created on the actual page.

iPhone app

The first version of the “dzone mobile” app has passed the iTunes store review process and is available through the app store. A version with some minor bugfixes is currently beeing reviewed. Have a look at updates and documentation here or here.

voting

You have got to provide your DZone login credentials if you want to use the voting feature. Go to the iPhone Settings > DZone and add your username and password. I want you to know that there is NO SSL, so your credentials will be submitted UNSECURE!

more Features

If you are interested in pushing this further, you can add bug reports or feature requests on GitHub.

screenshots

DZone iPhone sugar!

Using blocks in Objective-C

One of my pious intentions for the year 2010 is to start writing some application for the Mac. Apart from the hype about iPhone development, I think that starting out in that area is especially appealing, as it reduces the size of the API one has to learn. Getting to know the iOS libraries is a lot easier than handling the endless amount of Cocoa frameworks.

One thing that I discovered recently is the support of blocks, that has been introduced with OSX 10.6 and iOS 4.0.

the environment matters

Consuming 3rd party data from the web is kind of a pain, especially compared to how easy it is in Ruby. So I was pleased to find Seriously, a framework for async calls and JSON/XML parsing. The Seriously examples made use of blocks:

NSString *url = @"http://api.twitter.com/1/users/show.json?screen_name=probablycorey";

[Seriously get:url handler:^(id body, NSHTTPURLResponse *response, NSError *error) {
    if (error) {
        NSLog(@"Error: %@", error);
    }
    else {
        NSLog(@"Look, JSON is parsed into a dictionary!");
        NSLog(@"%@", [body objectForKey:@"profile_background_image_url"]);
    }
}];

Executing this example in my app code raised an error, that I could not easily understand:

"__NSConcreteGlobalBlock", referenced from: ___block_holder_tmp_1.1207 in DZoneController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

The problem was, that XCode set my execution environment to OSX 10.5 which does not have support for blocks. To fix this, one has to update the MACOSX_DEPLOYMENT_TARGET build variable.

Right Clicking on the XCode project in the “Groups & Files” view will bring up a context menu with “Get Info” (or pressing CMD+I while project is selected). The info pane has a “General” tab that lets you select the “Base SDK for All Configurations”, which I set that to iOS 4.0.
An other option is to search for “MACOSX_DEPLOYMENT_TARGET” in the “Build” tab and changing that value accordingly. Make sure “Show” is set to “All Settings”.

At least some Objective-C sugar!