Sep 01

“How can we automate our build number in this project? Perhaps a python or AppleScript?”

I get this question a lot. I contract out my development services to companies who need Mac, iPhone, or iPad software designed and developed. Many of these companies have lots of Windows developers on board full-time and contract out their Mac work so I understand that all-things Mac are new to them.

But this question always comes up. Always.

While they’re already thinking about some elaborate scripts to automate this process, I hold up my hands and say, “It’s already covered.”

I decided to blog about it because most people don’t know the name of the tool and can’t “Google” for it without stumbling across scripts to accomplish this task.

Apple includes a command-line tool called agvtool which handles my versioning needs. It’s not perfect, but it does what it needs to do and when used in a corporate environment with a build system, it’s fantastic.

What is it? In a nut shell, it’s a very focused “Find and Replace in Files” command-line tool. It searches through your program’s Info.plist file as well as the project .pbxproj file and updates them. You can even have it commit it’s changes with version control if you’re using Subversion or CVS.

The real number that needs to be constantly updated is the build number. Normally, the marketing version only changes at the beginning of a new branch or feature set. agvtool will help you out with both tasks. First, let’s tackle getting your project setup so you can display the following string in your iPhone About screen:

Version: 1.0 (Build 1)

The agvtool refers to the “1.0″ part as the “marketing version” and “1″ in the Build parenthesis as the project version. To update the build number we simply issue the following command from the project’s root directory which contains the .pbxproj and Info.plist files

agvtool bump -all

This command will change all of the build numbers, or project versions in agvtool speak, to:

Version: 1.0 (Build 2)

Want to change the marketing version to 1.1?

agvtool new-marketing-version "1.1"

Now our About box says:

Version: 1.1 (Build 2)

Cool, huh? Okay, so here’s how you setup your project to take advantage of this nifty little tool. First, we have to tell Xcode that we want to use agvtool for our versioning needs. From the Project menu, select Edit Project Settings. Ensure Configuration is set to All Configurations and Show is set to All Settings. Navigate down to the Versioning section and make the following changes:

Project Versioning Settings

Lastly, we need to update the Info.plist file. You need to set two values in, your Marketing Version is the Bundle versions string, short. If you don’t have this option in your plist file, select an item in the list and click on the + off to the far right. You can then select it from the list. The Bundle version is the build number. Set this value to match the one you placed in the Project Settings option for Current Project Version.

Versioning Plist Settings

Now, whenever you’re ready to build an official release, just run:

agvtool -usesvn bump -all

The -usesvn parameter is optional. For an official build, you’ll want to commit the files that were changed by agvtool.

Then call xcodebuild.

Earlier in the article I mentioned that agvtool isn’t perfect. Here’s what I mean by that comment. For an automated build, having a command-line tool is fantastic. However, if you run agvtool while you have the project open in Xcode, you get this:

Project Has Changed. Read From Disk?

Since agvtool went and changed the .pbxproj file while you had it open in Xcode, you get this. Simply click on “Read From Disk” and you’re back in business. More of an annoyance than a show-stopper.

  • Twitter
  • Facebook
  • Delicious
  • Digg
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • Reddit
  • StumbleUpon
  • Technorati Favorites
  • Tumblr
  • Windows Live Favorites
  • Yahoo Bookmarks
  • Share/Bookmark

Written by Terry Blanchard \\ tags: , , ,

Jul 30

You can’t just open up your editor of choice to modify the /etc/hosts file on your Mac. You can open the file without any problem, you just can’t save it.

To do this you must have super user privileges. Just being an Administrator isn’t enough. Fortunately, there’s a way to temporarily get super user privileges using the SUDO command. So I fired up Terminal and typed in:

sudo textedit /etc/hosts

Ruh-roh. It wouldn’t let me save the file. Crap. I’m not a Unix guy and VI makes my skin crawl and head hurt, but I was able to use sudo vi /etc/hosts and save the file.

So why couldn’t I get any of the GUI apps to save it?

Turns out, that you need to sudo the actual executable which is inside the TextEdit.app bundle. So the command I issued is this:

sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts

Voila!!

If you happen to own TextMate, then you can save yourself a lot of typing and heartache. TextMate installs a Terminal command called “mate” that allows you to perform the above sudo command. Just type:

mate /etc/hosts

Voila, again!! When you go to save your file, you will be prompted for your password.

  • Twitter
  • Facebook
  • Delicious
  • Digg
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • Reddit
  • StumbleUpon
  • Technorati Favorites
  • Tumblr
  • Windows Live Favorites
  • Yahoo Bookmarks
  • Share/Bookmark

Written by Terry Blanchard \\ tags: , , , ,

Jun 21

I hit a really odd bug last night. I mean, really, really odd. One of those bugs that keeps you up until 4am and you go to bed defeated. I came into the office today and had another engineer sit with me as I went through my code explaining what I was doing hoping that a second set eyes and another brain could bring some clarity.

No luck.

Everything looked good, but this very odd crash was still occurring. We were both scratching our heads. The weird part was that the program ran perfectly on the iPhone and in the simulator, as long as I didn’t have the debugger attached. The other engineer tried the build on his machine and everything worked as it should and he was able to run the Xcode debugger.

I decided to completely remove and reinstall Xcode and the iPhone SDK. Normally, you just drag a Mac application to the Trash Can and you’re good. Xcode is a little different. There’s a ton of different folders, tools, SDKs, simulators, etc scattered around the Hard Drive.

So how do you remove everything?

Fire up Terminal and type:

sudo /Developer/Library/uninstall-devtools -mode=all

Type in your password and go grab a coffee. The Uninstall process takes quite a bit of time as it analyzes every package on your machine. However, it will find and remove all Xcode and iPhone SDK components. I highly recommend you to restart your Mac before re-installing Xcode.

  • Twitter
  • Facebook
  • Delicious
  • Digg
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • Reddit
  • StumbleUpon
  • Technorati Favorites
  • Tumblr
  • Windows Live Favorites
  • Yahoo Bookmarks
  • Share/Bookmark

Written by Terry Blanchard \\ tags: , , , ,

Jun 21

WordPress for iPhoneI use WordPress as my blogging platform and I absolutely love it. It’s so well done and makes blogging a joy. I’ve tried other platforms and spent more time fixing it, fretting over why the upgrade brought my site down, traversing database tables, and wishing it would do something that it doesn’t.

As most of you know, I’m also a Mac Boy. Me loves me the Apple products. WordPress has an iPhone application that allows me to write posts, upload photos, edit pages, and manage comments on my blog right from my iPhone. I use it for quick posts or to start a draft post with bullet points of high-level ideas so I can flush it out later. One of the coolest features I expected to use the iPhone application for was comments. What a perfect way to constantly monitor and reply to comments from my phone whenever I get a chance. I download the application and I like it. But it’s missing one major feature. Yup, the one I want the most. Replying to comments! I can delete comments, mark them as spam, but I can’t reply to them. Say, what!

I go to their website to request this feature and notice that this is an Open Source project with links to their development section. I’ve been developing software for close to 25 years and I have never participated in an Open Source project. As a professional software engineer, I’ve been very fortunate to work for some of the finest software companies around and their source code is fiercely guarded intellectual property kept under strict lock and key.

Open Source projects take a completely different approach. Instead of hiding the source code, they make it freely available. Anyone can download and build the source code. Anyone. The spirit behind this approach has a few key points. One in particular applied to me in this case. Opening up the source code and allowing anyone to work on it invites other with a desire to help and improve the product simply because you can, and you care. This described my situation to the letter and I decided to do something about it.

Why fill out a form asking the developers to add my reply to comments feature when I could contribute and make it happen myself? I’ve decided that I’m going to do exactly that. I’m not going to bitch and complain, I’m going to contribute.

I have lots of questions, lessons to learn, and I hope this turns out to be a great learning experience. I’m going to write about the contrast in experience as it happens. Things that immediately spring to mind:

  • In a corporate environment you typically have technical leads or architects that are responsible for the structure of the code. They understand all aspects of the code at the lowest level and as well as why it was designed the way it was at a high level. They typically do the code reviews before an engineer checks in their code. Who does this in an Open Source project? Who owns it? Does it just evolve organically?
  • How does the code/product get qualified or verified for integrity and quality? Who does this?
  • I can understand how bugs or defects are handled. The product is suppose to do X and it doesn’t or it crashes. That’s pretty defined so I can understand how this can happen in a community environment. How are new features defined and implemented?

If you use the WordPress for iPhone application and you’ve got a hankerin’ for the Reply to Comment feature, post a comment. I’m working on it.

  • Twitter
  • Facebook
  • Delicious
  • Digg
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • Reddit
  • StumbleUpon
  • Technorati Favorites
  • Tumblr
  • Windows Live Favorites
  • Yahoo Bookmarks
  • Share/Bookmark

Written by Terry Blanchard \\ tags: , , ,

May 03

Building and leading a successful team requires you, as the leader, to create and foster the right conditions. Just hiring the best talent and throwing a vision statement at them isn’t enough.

First, be crystal clear about the outcome that is expected from them. A lot of leaders fail by going too far with this and filling in all the details about how to achieve the desired outcome. This may be well intentioned and natural if the leader has a lot of previous experience in this particular area, but this has a few drastic side-effects. For one, you’re not providing an environment that is collaborative and open to improvement. Many people will remain silent when they have an idea to improve the plan because they have less experience than you, and you’re the boss. Allowing the team to devise their own plan for success may, and often will, open your eyes to newer and better ways of doing something. An effective leader knows when to use their experience and help guide the team, but also know when to recede into the background and let the team do what they do best.

Second, the team is no longer responsible for the outcome — you are. They’re just doing what you, the experienced leader, are telling them to. Who are they to question what you know is best. They will now fall into a role of “just tell me what to do.” If the project fails, it’s your fault. They were just following directions. Now you’ve lost credibility with your team as a leader and your team has lost credibility within the business.

Instead, be clear about the desired outcome. Paint the picture of the end result and let them decide how to get there. Let them own and possess the responsibility to achieve the outcome. You as the leader are there to help and provide guidance, course corrections, and focus. The team as a whole is working together to achieve the outcome. Everybody is responsible for the success, or failure, of the outcome.

Setting good direction for a team means being authoritative and insistent about desired outcomes, but being equally insistent about not specifying how the team should go about achieving those outcomes.

Another condition that I’ve seen have devastating effects on a team is failing to give your team enough ownership. I’ve seen managers and organizational leaders back off from taking on what they perceive as too much for their team. Their intentions are well-meaning, but it becomes a facade that is easy to hide behind each time it’s used. Teams are motivated when they are given clear and challenging problems that have a large impact. That’s also one of the key ingredients required for innovation. The well intentioned managers and leaders are doing more harm than good when they water down what the team is responsible for, typically because they are worried about how well the team will perform. So they assign the team a smaller, relatively inconsequential part of the overall task. These are catastrophic mistakes. Having vague or relatively unimportant chunks of the outcome actually compromises team performance and morale. They feel like their work isn’t as important and consequential.

Make sure that your teams have a clear picture about the what is expected from them, what the desired outcome looks like. They need to be able to picture what success and being “done” looks like so they can get there. Also ensure that the outcome they are working toward is important and has a consequential impact on the business or project.

  • Twitter
  • Facebook
  • Delicious
  • Digg
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • Reddit
  • StumbleUpon
  • Technorati Favorites
  • Tumblr
  • Windows Live Favorites
  • Yahoo Bookmarks
  • Share/Bookmark

Written by Terry Blanchard \\ tags: , , ,