How to have multiple iTunes Connect accounts, and submit apps

iTunes Connect is a bag of hurt sometimes, especially if you have clients that you work with. One of the biggest frustrations that I have (and hopefully this will be changing in the future) is when you need to submit builds and you cannot use an email for an Apple ID in iTunes Connect to manage your client’s Apps, TestFlight, Users, etc.

While there is no easy way to accomplish this yet, at least there is this post by mokagio that helps ease some of the pain…

How to have multiple iTunes Connect accounts, and submit apps

TL;DR You can’t! There is no Apple way to do it, and this is yet another frustration of working in this platform. The steps described below are just a workaround to handle multiple iTunes Connect accounts in a sane-ish way.

While I don’t love using the Application Loader, at least it works. Also, creating email addresses for Apple IDs with the “+clientname” trick works great if you use a Gmail-based email system, and I’m fine with having my clients use this method when they add me to their iTunes Connect accounts.

Customize the background color and title of a UINavigationBar and the status bar

Here’s an example of how to customize the background and title color of a UINavigationBar without having to use an image (in this case, a blue background with a white title AND white status bar):

    // Set the navigation bar to blue
    [[UINavigationBar appearance] setBarTintColor:[UIColor blueColor]];
    [[UINavigationBar appearance] setTranslucent:NO];

    // Set the navigation bar's title text to white
    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];

    // Here's where it gets a little weird: we set the barStyle property to *UIBarStyleBlack* to achieve a *white* status bar.
    [[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];

Strange Case of the non-scrolling-to-top UITableView

Earlier today I had a situation in which the gesture to scroll a UITableView to the top by tapping on the iPhone status bar was not working.

Strange and annoying.

On doing some investigation, I found a clue on StackOverflow which pointed me in the right direction. It turns out that if you have a nested scroll view whose scrollToTop property is set to YES (the default), it will prevent the containing UIScrollView (or in this case a descendent thereof, UITableView) from recognizing and responding to that gesture.

In fact, in the documentation for UIScrollView, it says the following under “Special Considerations”:

Special Considerations
On iPhone, the scroll-to-top gesture has no effect if there is more than one scroll view on-screen that has scrollsToTop set to YES.

In my case I have a UIScrollView inside each UITableViewCell, which was defaulting to YES for scrollsToTop. Once I programmatically set that property to NO, the UITableView began responding to that gesture again!

Case Closed!

 

Xcode Tip: Open multiple projects at once

I discovered this one accidentally since I really did want to open three projects at the same time after opening Xcode.

It turns out that the “Open Project…” dialog in Xcode supports multi-select! So you can Shift-Down/Up to select more than one project, hit Return and all three projects will be opened simultaneously!

I pretty much stumbled on this one when I did an “I wonder if this works” kind of thing at that dialog, and sure enough, it opened all three.

Score!!!

 

 

Developing for Bluetooth Low Energy and iOS – Now at Cloud City Blog!

As you may or may not know, I currently work for the software development consulting company, Cloud City Development in San Francisco. They kindly asked me to write a blog post on the subject of Bluetooth Low Energy and iOS, and of course I jumped at the chance!

The great news is that the first part of the three-part series was published yesterday!

cc-zero-to-ble

Many thanks to the entire team at Cloud City Development for allowing me to work on this very interesting and informative series (and for publishing it!). I will post again when parts two and three are up. Look for them in the next few weeks!

Fixed Problem with Red Bear Labs BLE Shield and Arduino!

Yesterday, I was successfully running the “HelloWorld” demo from Red Bear Labs (using Arduino 1.6.3) and then when I attempted to compile and load the “SimpleChat” sketch, it started to freak out and I was getting ‘EEPROM.h not found’ errors and general mayhem — until this morning.

I’m not sure if this is helpful but I did a couple of things, and now I can see the BLE Shield in LightBlue for iOS and subsequently in the BLEChat iOS app from Red Bear…

For starters, I’m running Mac OS X 10.10.2, and my iPhone 6 is running iOS 8.2, and here’s what I did…

  1. Installed Arduino 1.6.1 instead of 1.6.3 (I find it strange that this would matter, but maybe it does?)
  2. Compiled and loaded the “ble_A_Hello_World_Program” from the Nordic SDK — LightBlue started to see the “BLE Shield” peripheral at this point.
  3. Compiled and loaded the RBL SDK “HelloWorld” sketch and LightBlue still sees it.
  4. Attempted to connect to the BLE Shield via LightBlue and it failed and I didn’t capture the message… sorry.
  5. Killed LightBlue
  6. Task-switched to Xcode and ran the BLEChat project.
  7. “Connect” button successfully connected to the BLE Shield peripheral and I’m receiving “Hello World!” messages.

Hopefully I can get started again and it will be smoother sailing from here on out.

I hope my feedback helps future adventurers!

 

 

Syntax highlighting for Swift in BBEdit and TextWrangler

Big thanks to Curt Clifton (https://github.com/curtclifton – his bio indicates that he’s with the Omni Group!) for creating this codeless Language Module for Swift that can be used in BBEdit and in TextWrangler.

A BBEdit Codeless Language Module for Swift

Curt indicates there are some limitations to codeless language modules:

Keyword, comment, and string highlighting work. Top-level classes, structs, enums, functions, and extensions are indexed and can be folded. Because of limitations in the matching power of codeless language modules, nested declarations are not indexed and are not fold-able.

However, it works great if you want to do some Average Joe coding in Swift in TextWrangler or just see your .swift files highlighted outside of Xcode.

Installation is super easy:

BBEdit

  1. Copy the file swift.plist to ~/Library/Application Support/BBEdit/Language Modules. You may have to create the Langauge Modules folder if it doesn’t exist.
  2. Quit and relaunch BBEdit.

…and for TextWrangler it’s just as simple:

TextWrangler

  1. Copy the file swift.plist to ~/Library/Application Support/TextWrangler/Language Modules. You may have to create the Langauge Modules folder if it doesn’t exist.
  2. Quit and relaunch TextWrangler.

Smoother transitions when showing a View Controller with a UINavigationBar in Swift

Here’s the scenario. You want to display a modal view controller without a navigation bar, and then from that view controller you want to navigate to another view controller that displays a navigation bar.

First to get things set up, in the Storyboard we set up the view controller that would be displayed modally. We create a view controller, perform the Editor -> Embed in -> Navigation Controller. Then, in the viewWillAppear method, we hide the navigation bar programmatically.

It turns out that there are two ways to do this and, at least in my case, one way turned out to be better than the other. The first way I tried worked, but the animation for the transition from one view controller to the next looked a little odd.

The first way is the more obvious of the two, because you can simply just set the hidden property of the navigationBar like in the following example:

self.navigationController?.navigationBar.hidden = true

There is also another way to do the hiding and showing of the UINavigationBar, and the second way is do do it via the UINavigationController, as in the second example:

self.navigationController?.setNavigationBarHidden(true, animated: true)

There are two advantages to doing it the second way. First, because you get a method to hide and show the navigation bar, you get the additional animated parameter that you can set.

The second advantage is that when you use it in this way with the animated parameter set to true, iOS performs a slightly more smooth transition.

Your mileage may vary, so try both ways and see which you personally like best.

How to create an Objective-C Bridging header

Super important to know during this time of Objective-C to Swift transition. I’ve had to use this technique and it will be good for all Swift developers to have in their kit-bag until we can finally be 100% Swift.

How to create an Objective-C Bridging header – iOS-Blog
So you want to use an Objective-C Library or SDK in your Swift application eh? Well do not fret. This quick tutorial will show You how you can create an Objective-C Bridging Header in your Swift application so you can use them both together and seamlessly.

UIView Animation with Swift

Here is a very simple way to do UIView Animations in Swift.

First, you create an IBOutlet for a constraint created in Interface Builder in Xcode – in my case, I had a constraint that anchored to the bottom of the containing view. In the code example, the constraint is named “constraintToAnimate”. You just control drag from the Storyboard to your code as you would when connecting a control, but in this case you connect a constraint. It will look something like this (the name of your constraint will hopefully be different):

    @IBOutlet weak var constraintToAnimate: NSLayoutConstraint!

The following snippet is basically a straight-up conversion of Apple’s own Objective-C example given in the documentation article Auto Layout by Example in the Animating Changes Made by Auto Layout section (you may need to scroll down to find that section).

    self.view.layoutIfNeeded()
    UIView.animateWithDuration(0.3, animations: {
        // make constraint changes here...
        self.constraintToAnimate.constant = 250 // your value here.
        self.view.layoutIfNeeded()
        }, completion: {
            (value: Bool) in
            // completion code here...
    })

Basically, in pre-Auto Layout days you would just animate the frame. Today you just animate the constraint. It works great and once you get your head wrapped around it, it’s pretty straightforward.