iOS 4.2 update and the Base SDK Missing error

If after updating to iOS 4.2 SDK you get a “Base SDK Missing” error:

  1. open Project settings and choose “Latest iOS” under Base SDK for All Configurations
  2. open your target and make sure the settings applies to it (in case you overrode it)
  3. (yes, somehow the “Base SDK Missing” error seems to stick)
  4. shutdown Xcode and reopen.

The SDK now is set.

Updating your Apple Push Notification Service certificates

Just a quick checklist to get up to speed when your APN certificates expire.

  1. Login into the Provisioning Portal, click “App IDs” on the left side column
  2. Click “Configure” on the App ID of your app
  3. Click Revoke for the expired Push SSL certificate
  4. Open Keychain Access on your Mac. Click the “My Certificates”, find the expired cert and just delete it.
  5. From the Provisioning Portal, start creating a brand new Push SSL certificate. Just follow the instructions.
  6. Don’t forget to download the signed cert and double-click it to install it (aps_developer_identity.cer) in your default keychain.
  7. Select My Certificates, find the newly created cert, click the disclose triangle. Then:
    • Right-click on the private key entry without selecting the parent, and select Export. A .p12 file will be saved.
    • Right-click on the actual certificate without selecting the child key, and select Export. Another .p12 file will be saved. UPDATE 2017: it looks like you don’t need to do this anymore. The cert file includes a bag with both cert and key, so deploying that should work.
  8. If your server requires .pem style certificates, run this:
    $ openssl pkcs12 -in apn_cert.p12 -out apn_cert.pem -nodes
    $ openssl pkcs12 -in apn_key.p12 -out apn_key.pem -nodes
  9. Deploy the .pem files in the right location accessible by your application server that will be sending the Push notifications.
  10. UPDATE (2015): it seems like each exported files contains both key and certificate now and therefore are identical. I don’t recall that being the case at the time of this writing.

Now push notifications should be up and running once again.

Changing a UIButton title and dealing with button States

If you are changing the title of a UIButton programmatically, you will naturally use the method setTitle:forState:. Easy enough… well, sort of. What do you put in the state parameter?

My first reaction was “I’m going to put all possible states since I just want the button title to change no matter what.” So I blindly bit-OR‘ed all the possible values defined in the docs.

[myButton setTitle:@"New Title" 
          forState:UIControlStateNormal | UIControlStateHighlighted | UIControlStateDisabled | UIControlStateSelected];

Sound reasonable right? Wrong. If you do that here, your button title is probably not going to change at all. The problem is that the “normal” state (per Apple docs that’s “enabled, not selected, not highlighted”) is defined as such:

enum {
    UIControlStateNormal   = 0,
    UIControlStateHighlighted  = 1 << 0,
    UIControlStateDisabled     = 1 << 1,
    UIControlStateSelected     = 1 << 2,

so if you bit-OR all of them you are actually going to set the title for ALL states EXCEPT the “normal” (most common) state!