forcedotcom/SalesforceMobileSDK-iOS — pull request #220 by khawkins (2013-01-29 01:29:30+00:00)
Title: Updating SalesforceSDK project, unit tests

The changes to native/SalesforceSDK/SalesforceSDK.xcodeproj/project.pbxproj are going to be indecipherable to the naked eye (as it's essentially rewritten), so here's a breakdown of what's going on with this request.

- I created a new "Cocoa Touch Static Library" with Unit Test bundle for SalesforceSDK (and SalesforceSDKTests), from scratch, and re-imported all of the existing code back into it, deleting a few things that were orphaned or otherwise unused in the project. This was to basically get an Xcode project in a newer format than we had; I figured since I was doing heart surgery, I may as well do some housecleaning too.

- Xcode has two kinds of unit tests: Logic Tests and Application Tests. There are certain kinds of calls/references that are not supposed to be used in Logic Tests, such as calls to UIKit functionality, and seemingly calls to the app's documents directory (where our sqlcipher databases are stored and tested). I believe this is what was causing the instability in our unit tests (which were Logic Tests). Making them into Application Tests simply required the creation of a 'dummy' application (see the new **SalesforceSDKUnitTestApp**), linking the unit test target with that instead of the static library, and all the tests stayed the same. The new application does absolutely nothing, and I didn't even edit the boilerplate code that was generated.

- There were a couple of miscellaneous clean-up items that came as part of this change:
- I took the conditional `#ifdef UNIT_TESTS` out of the user agent check in `SFRestAPI`, as with Application Tests, this code will work in test and production.
- I realized that libSalesforceSDK.a was not being built with with sqlcipher-enabled compile flags, and as such native apps could not make use of sqlcipher as a secure store, without fixing and recompiling the native SDK.
- Along with this change came the need to update RestAPIExplorer to use sqlcipher, instead of sqlite. This was a previous oversight.

**Noteworthy:**
While Application Tests solve some of the stability issues with our previous set of tests, a notable drawback is that **they cannot run in Continuous Integration environments**. After deliberation, I consider this still to be a stability improvement worthy of making, since it had basically gotten to a point that you couldn't work with the unit tests locally anymore. We will re-visit our CI testing support in 2.0, after gathering recommendations on alternatives.

As such, please make sure that, when you're making changes to the native SDK project, run the unit tests locally, before moving into the review phase.