Archive September 2009
Using Subversion with Xcode, Part II
In my previous post, Using Subversion with Xcode, Part I, I covered how to create a repository and provided a set of scripts to use to automate these tasks. In this post I will demonstrate how to use the SCM client within Xcode to access your Subversion server.
SSH
Before you can use Xcode’s SCM client to connect to your Subversion server, you need to enable the SSH server on your Mac. SSH server is installed by default on OS X 10.5, to enable it open System Preferences.
From the Internet & Network section, select the Sharing icon, within the Sharing preferences check the box labeled Remote Login.
That’s it, at this point your SSH server is running.
Configuring SCM Repositories
After you launch Xcode, you can configure your SCM repositories by selecting SCM > Configure SCM Repositories… from the menu bar, this will open the Xcode SCM Preferences window.
Click the the plus sign ‘+’ to create your repository, it will prompt you for a name and ask you to select which SCM System you are using (Subversion in our case).
Now you need to build the URL to connect to the repository on your computer. Here you enter the Scheme, Host, Path, User and Password and have Xcode build the URL for you.
Scheme: svn+ssh
Host: either <computer name>.local or localhost
Path: the absolute path to your repository
Port: N/A
User: your login username
Password: your login password
If you entered everything correctly, you should see a green light indicator with the word Authenticated beneath the password box, click OK. If you are encountering errors, double-check that all information is entered correctly above. You can also try connecting to yourself through SSH via the Terminal: ssh username@localhost.
Configuring Projects
Before you import your projects in to Subversion, you may want to configure your project so that your build files are not located in the same directory as your project. It is normally not necessary to place these files under version control, as they can easy be regenerated by rebuilding your project.
Viewing SCM Repositories
Whenever you are ready to import into Subversion, you can add it through the Xcode SCM client by selecting SCM > Repositories from the menu bar, this will open the SCM client. If you ran my scripts from the previous post, you should see the following in each column:
Column 1: All of your configured Repositories.
Column 2: The Projects folder you specified when setting up your repository
Column 3: The Project you created
Column 4: The Subversion folders that were automatically created with the script
The horizontal window at the bottom will display the Subversion commands that are being run when you select an item from each column. This can be helpful troubleshooting tool if you are having access or permission problems.
Importing Projects
To add your project to Subversion, click the Trunk folder and then click the Import icon. This will display the directory import dialog, here you will want to select the folder of your local project and enter a meaningful comment.
Configuring Projects for SCM
Now that you’ve added your project to Subversion, you will want to configure it so you can start versioning any changes to your code. You may want to create a separate directory on your computer to store projects that are under version control. I recommend choosing a location that is separate from the directory where you initially imported from. Once you establish a location, select the Project folder under the Trunk folder and click the Checkout icon, here is where you will select the folder you created. After you click Checkout, you should receive a Checkout Complete dialog window where you are given the option to open the project. Congratulations! At this point your code should be under version control.
Part III will show you how to commit any changes that you make and will explore some of the SCM tools.
Using Subversion with Xcode, Part I
When you start learning new languages and work through different projects and problems, I find it helpful to have my code under version control (or SCM). Keeping on topic with my previous post about learning iPhone Application Development, it may be a good idea to version your code especially when working with the Stanford University projects. Currently Xcode supports three different SCM tools: CVS, Perforce and Subversion. You may choose to setup either tool, I have chosen Subversion because of its ability to integrate with a variety of development IDEs: Xcode, Visual Studio, Eclipse, NetBeans, etc.
The most detailed resource I have found on setting up Subversion within Xcode 3.1 is from the Apple Developer Connection. In this post I will keep it simple, as well as, provide shell scripts so you can avoid typing tedious commands to add new projects, branch, tag, etc.
This configuration will use svnserve, which is a lightweight Subversion server useful for individual developers, it is also installed by default on OS X. If you are looking to setup Subversion in a large development environment with multiple users, the Apple Developer Connection document will provide details for setting up Subversion with Apache.
This tutorial will cover the initial setup of configuring your Subversion repository and creating your first project via the command line.
Creating a Repository
A repository is the data store that will contain all of your projects. Because Xcode will only allow you to have one project folder at the root of the repository, I create a Projects folder that will contain all my individual projects. The following script will create your repository and a projects root folder:
# A script to create a new SVN repository
# Set this to the location where you want to store your repositories
reporoot=/Library/Subversion/Repository/
# This is the name of the projects root folder
projdir=Projects
# Create new repository
print -n "Enter new repository name:"
read repo
echo
echo Creating repository $repo
svnadmin create $reporoot/$repo
echo
echo Creating projects directory
svn mkdir -m "Directory for Projects" file://$reporoot/$repo/$projdir
echo
echo Repository Creation Complete!
echo Start adding new projects
echo
Creating a Project
The structure of a project in Subversion is setup with three sub-directories: branches, tags, and trunk. Each of these are used for the following:
Trunk
This is the location where you will import all your project files. The files contained in this folder will be the those that are checked-out and committed (checked-in).
Tags
This is the location where you will archive your releases of your project.
Branches
If you need to experiment with changes to your project and do not want to make changes to the files in the Trunk, the Branches folder is where you can store these project files.
This script will automate a lot of the work of creating the folders above. You can run this script each time that you need to add a new project to your repository.
# A script to create a new SVN project directory
# Replace this with the path of your Repository and Projects folder
reporoot=/Library/Subversion/Repository/YourRepositoryName
# Create new project
print -n "Enter new project name:"
read project
# Clean up local tmp directory
rm -rf /tmp/project
echo
echo Creating temporary directories
mkdir -p /tmp/project/$project/trunk /tmp/project/$project/branches /tmp/project/$project/tags
echo
echo Importing $project into Subversion
svn import /tmp/project/ file://$reporoot -m "Initial import"
echo
echo Cleaning up…
rm -rf /tmp/project
echo
echo "Directories Created!"
echo "Import your project through SCM in Xcode"
echo
Part II, will cover configuring Xcode to connect to add your project files to your Subversion repository.
How to Distinguish Between Being Bored and Unmotivated
We all get bored. In fact, just before I started writing this post I was pondering whether I should just browse the internet aimlessly or actually do something productive.
Although the differences between being bored and being unmotivated are subtle, the underlying cause may be significantly different.
What is being bored?
- Lacking something to do.
- Repeatedly doing something that it becomes unchallenging.
What is being unmotivated?
- Are you tired or exhausted from lack of sleep?
- Is there some other event going on in your life that distracts our focus?
- Do we have a lack of interest in something?
If you are finding yourself unmotivated, you need to look at what is going on in your life that could be causing you to feel this way.
- If you are physically tired or exhausted – Get some sleep! If you are running on limited sleep you may experience some delusional highs, but eventually you will crash. If you get plenty of sleep you might want to look at your diet. Some foods will give you a temporary pick-me-up, only to cause you to have no energy shortly after (Redbull).
- If you are having issues in your personal life, you will need resolve as soon as you can or else your focus will continue to be clouded. Most of us will have small issues that will always be on our minds (like a list of things that you need to do), but if you have issues that effect all aspects of your life you may want to seek professional help.
- Not everything that you do will interest you (this includes work, school and personal life). If you can direct your focus on something that motivates you. This won’t be possible in all scenarios such as if you need to do something work-related and you have a deadline. By focusing you attention on something more motivating it might put you a different state of mind so that when you need to complete uninteresting task, you will be able to overcome a mundane task.
Feeling unmotivated may not be something you can fix immediately, like leaving work in the middle of the day to take a nap, but you can gradually make adjustments to keep you motivated.
Boredom is an opportunity
Under ideal circumstances, we should never feel bored. There are literally dozens of remedies to combat boredom, but here are a few that you can try the next time that you feel bored :
1. Go somewhere, anywhere.
Don’t allow yourself to be trapped in the house. Don’t get stuck sitting on the couch, watching TV, feeling like there is nothing on. There are plenty of places that you can go to break from your boredom: bookstore, mall, the park, the beach, etc. Get some fresh air and wake up your mind.
2. Learn something new.
If you are like me, you have a list of things that you want to accomplish (particularly if you are a geek – you might want to learn a new technology). This is the time to do it. It’s useful if you go somewhere else then where you are feeling bored. If you are currently using the computer, you might want to take a laptop and go somewhere else.
3. Break Out of Routine.
If your work is becoming repetitive and uninteresting try approaching it differently. You may be able to do this by accomplishing tasks in a different order (or time of day). I know in the development world, trying to devise ways to automate your routine is a good way to eliminate boredom and allow you to have more time to focus on things that interest you.
How have you overcome boredom?
How to Get Started with iPhone Development
There does still appear to be a market for making money with iPhone apps (especially games), if you are still interested in creating an iPhone application there are plenty of resources available to help you along the way.
Prerequisite: You will need an Intel-based Mac with XCode for iPhone development.
When the iPhone development tools were initially released Apple had implemented a Non-Disclosure Agreement (NDA) that pretty much limited the amount of information that was available to developers in terms of sample code or tutorials. Apple has since removed the NDA and now there are plenty of resources available online, in books and classes. The resources that I provide below will allow you to develop iPhone applications that you can sell in the iTunes App Store, there are other resources online that I do not cover that will teach you how to develop applications for Jailbroken iPhones.
OS X Development Resources
If you are completely new to developing on a Mac, I would recommend the following books to get started:
Cocoa Programming for Mac OS X
Aaron Hillegass
This book primarily focuses OS X application development rather than iPhone development, but its is a good introduction to using XCode, Interface Builder and Instruments.
Programming in Objective-C 2.0
Stephan Kochan
Programming in Objective-C will introduce you the Objective-C programming language required for iPhone development. Most of the examples in this book are demonstrated using a Mac; however, Objective-C can be developed in Windows, Unix or Linux using gcc or a tool like MinGW.
iPhone Development Resources
Since Apple removed the NDA, there have been several books authored that contain tutorials and sample code for developing your own iPhone applications.
Beginning iPhone 3 Development: Exploring the iPhone SDK
Dave Mark & Jeff LaMarche
This book has many walkthroughs and tutorials to accomplish basic iPhone development tasks. You can move more quickly through this book if you are already familiar with the Xcode/Interface Builder environments (See Hillegass).
The iPhone Developer’s Cookbook: Building Applications with the iPhone 3.0 SDK
Erica Sadun
Containing many code samples, the iPhone Developer’s Cookbook is a good reference for quickly finding how to perform common iPhone development tasks.
Free Online Tutorials
Stanford University started offering a course on iPhone Application Programming and has made the course materials available online for free. As of early this month, you can download podcast lectures from the Standford University iTunes Store.
This course is one of the best resources available right now, it will get you ramped up quickly even if you have never developed on a Mac before.
If you have come across any good books or online tutorials, please feel free to share.
Update: Taranfx offers 5 ways to develop iPhone apps on Windows.
Update: Useful tutorial for building iOS applications from scratch.
How I Went From 4 Failed Blogs to RepeatGeek
A couple of years ago, I saw an article titled (Adsense Case Study: PVRBlog). I thought that it would be a good idea to start my own blog and make some money with Adsense.
If you think you can quit your job, start a blog and make money via Adsense … you may want to rethink the idea.
Blog Fail #1: Consumerist Rip-Off
The first blog that I started was to focus on the niche of Consumer Electronics stores. The plan was to post interesting things about Best Buy, Circuit City, CompUSA etc. Visitors to the site would most likely be interested in the stores and thus would click the Adsense ads. After a couple of months of posting a few blog-worthy stories, I got frustrated because my site traffic was low and was running out of ideas to blog about. I resorted to posting my own blogs to Digg, hoping they would reach the front page. Generating only minimal traffic, a few cents of Adsense revenue, and unknowingly realizing I was trying to re-create the Consumerist.com, I abandoned the blog.
Blog Fail #2: Mac Switcher Rip-Off
I’ve been a Mac user for almost 2 years. For the first couple months I thought it would be a good idea to create a blog for those switching from Windows to Mac. Because I didn’t do my research first – I didn’t realize that there are dozens of sites that provide tips and tricks for Windows users switching to Mac, including Apple. The problem I ended up facing was a lack of original content and a lack of motivation to continue the blog.
Blog Fail #3: App Store Rip-Off
After I bought a Wii, I stumbled upon this great website Virtual Console Mondays that listed the latest releases for the Virtual Console. What I liked about this site was it allowed me to see what was released without having to turn on the Wii and navigate to the Wii Shop Channel. The concept for the website seemed like a good idea and from a maintenance standpoint, the author would only need to post once a week and wouldn’t need produce that much original content. I thought I could capitalize on this concept with the release of the Apple App Store. It seemed like a good idea to start a blog where people could search and browse the latest Apps without needing iTunes. I started started copying/pasting App descriptions from the iTunes App Store into my blog (at the time the App Store was about 1000 apps). It took me about a week to enter about 100 Apps into my blog, then Apple released approx. 500 more apps into the App Store, I gave up shortly after realizing that I would never be able to maintain such a site.
Blog Fail #4: Featured Question of the Week
About 3 months ago I thought it would be a good idea to start an online training business. To drive traffic to my site I thought that I would have a blog where I offered a daily computer tip. Again, I should’ve researched my idea a little bit more because there are many sites that provide daily computer tips and I would be contributing very little original content. I wanted to get on the Twitter bandwagon and try to promote a “Featured Question of the Week†by allowing the winner to receive Adsense revenue, but I haven’t had any takers. I am currently reevaluating my business (Silverfish Technologies) to see what direction that I want to go.
Why another blog?
I’ve already failed at creating 4 blogs previous, why would this one be any different? I am realizing now that my posts need original content and a voice. All of my previous attempts were in posting known information. Well, it is my intention to share original thought and experiences in software development, provide insight into different technologies, and everything else.










