Xcode 4.3 / 4.4, Archive Build, Strip Static Library Bug

Sometimes it can be quite useful to hide a static library inside another one to hide the details of the inner static library from an application. We successfully did this with the Urban Airship library, but were having problems in a specific situation where the application would crash on first access of a method defined in the inner static library.

  1. Create an application that links against a static library (A), which in turn links against an already compiled static library (B)
  2. In the main application, write code that invokes a method defined in library (B)
  3. Archive the application
  4. Export the application into an IPA
  5. Run this IPA on a device
  6. Witness an EXC_CRASH (SIGSYS) in the crash log

I found the solution, which describes a bug in Xcode 4.3+. This still happens in Xcode 4.4.

“When performing an Archive action, Xcode uses the *project-level* build setting for STRIP_INSTALLED_PRODUCT rather than the target-level setting.”

More info here:

[Bug] Xcode Wrongly Applies Project Settings during Target Archive



Strict Date Parsing Gotcha (12 Hour Clock Example)

Be careful when parsing dates from strings. According to Technical Q&A QA1480, dates are parsed depending on a user’s
particular setup, e.g. locale viagra pas cher buy cheap viagra online from india. This happens even though the date format is specified strictly.
To ensure reliable parsing for all users, you need to explicitly set a NSDateFormatter’s locale property.

Example follows for a user that has their clock set to 12 hour:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"HH";
// Prints "(null)"
NSLog(@"%@", [dateFormatter dateFromString:@"13"]);    
dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
// Prints "1970-01-01 12:00:00 PM +0000" on my device
NSLog(@"%@", [dateFormatter dateFromString:@"13"]);

iOS Development – sizeToFit:

Jérémy Chatard explains the intricacies of UIView’s sizeToFit: with a concrete example of how it should be used to lay out a bunch of subviews stacked vertically. He makes use of recursion in his solution to solve the problem of “If you want to lay out a parent view, you first need to lay out its children”

If, like me, you always wondered what sizeToFit: should be used for, I recommend you read this. Cheers Jérémy.