If you blog it they will come?

Monday, March 12, 2012

error: unknown warning group

I try and write about really frustrating issues that I manage to figure out or interesting problems that I solve in hopes that it will help other poor developer souls who would otherwise be without a guiding light. Here's an Xcode-inspired episode of the former.

I decided to see what would happen if we moved our iOS project to Xcode 4.3 and it nearly went without a hitch except that I spent several hours trying to figure out why our rake scripts weren't working.

...actually let me back up a step and describe a couple of tools we use.

We use Cedar to run automated tests ("Specs" to follow the parlance of rspec), and one Cool Thing is that they can be run in Xcode or from the command line using rake.

Another Cool Thing, or at least a Thing That Used To Be Cool Before Upgrading Xcode, was our use of PivotalCoreKit to make spec writing more convenient.

PivotalCoreKit uses (abuses?) the dynamic-ness of Objective-C categories to override existing class behavior and suppress NSUrl from making an actual network connection, for example. The advent of 4.3 discourages this sort of flippancy and will issue a warning/error by default, which the newest commit of PivotalCoreKit suppresses with pragma preprocessor macros.

Now is where the wonkiness really starts. Running our specs from Xcode went swimmingly after updating PivotalCoreKit, but building the same spec target from the command line would fail with errors such as:


Externals/PivotalCoreKit/SpecHelperLib/Extensions/UIWebView+Spec.m:4:34: error: unknown warning group '-Wobjc-protocol-method-implementation', ignored [-Werror,-Wunknown-pragmas,2]
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"


What the heck??? They are the same target!

But after comparing the build outputs of Xcode 4.3 and the command line spec script, they were drastically different. For one, I could not get the command line to compile with SDK 5.1. Despite my various environment variable tweaks, the -isysroot parameter pointed firmly at yesterday's SDK.

Here's how I (eventually) fixed it:

  • I ran
    xcodebuild -version
    and found out I was *still* on Xcode 4.2 (I had decided not to delete it yet)!

  • I warily installed the latest command line tools (Apple: "The command-line tools are not bundled with Xcode 4.3 by default. Instead, they can be installed optionally using the Components tab of the Downloads preferences panel")

  • After installing the latest command line tools I was still on 4.2. After digging in /usr/bin/ to ensure that xcodebuild had in fact been updated, I serendipitously discovered
    xcode-select
    ...

  • sudo xcode-select -switch /Applications/Xcode.app/

  • xcodebuild -version
    is now 4.3!!

  • All is well is command line specs land



So here I am 4 hours later to administer the following advice:
--Delete old versions of Xcode when installing the latest if possible
--Otherwise, remember always: xcode-select -version

No comments: