In this first section we re going to create our Hello World project. This is going to be a very simple project.

Similar documents
Introducing Xcode Source Control

Using GitHub for Rally Apps (Mac Version)

How to set up SQL Source Control. The short guide for evaluators

Work. MATLAB Source Control Using Git

ios Team Administration Guide (Legacy)

ios App for Mobile Website! Documentation!

MATLAB & Git Versioning: The Very Basics

Git - Working with Remote Repositories

Version control. with git and GitHub. Karl Broman. Biostatistics & Medical Informatics, UW Madison

Your First App Store Submission

App Distribution Guide

How do I Install and Configure MS Remote Desktop for the Haas Terminal Server on my Mac?

Setting up a local working copy with SVN, MAMP and rsync. Agentic

MOOSE-Based Application Development on GitLab

Version Control with Subversion and Xcode

MEAP Edition Manning Early Access Program Hello! ios Development version 14

Version Control with Git. Dylan Nugent

Create an ios App using Adobe Flash Side by Side Training, And without using a Mac

What you should know about: Windows 7. What s changed? Why does it matter to me? Do I have to upgrade? Tim Wakeling

How do I Install and Configure MS Remote Desktop for the Haas Terminal Server on my Mac?

Flumes Short User Guide to Subversion

Developing for the App Store. (Legacy)

Source Code Management for Continuous Integration and Deployment. Version 1.0 DO NOT DISTRIBUTE

ACADEMIC TECHNOLOGY SUPPORT

FEEG Applied Programming 3 - Version Control and Git II

Getting Started with WebSite Tonight

Version Control with. Ben Morgan

Version Control Systems (Part 2)

Managing Online and Offline Archives in Outlook

Hypercosm. Studio.

Version control. HEAD is the name of the latest revision in the repository. It can be used in subversion rather than the latest revision number.

Gitflow process. Adapt Learning: Gitflow process. Document control

Clickfree C6 Easy Imaging October 24, 2011

Lab Exercise Part II: Git: A distributed version control system

White Label ios Application Installation and Customization Guide

Using the Push Notifications Extension Part 1: Certificates and Setup

Version control systems. Lecture 2

Xcode Application note

Chapter 28: Expanding Web Studio

RingCentral for Desktop. UK User Guide

Version Control! Scenarios, Working with Git!

Git Basics. Christopher Simpkins Chris Simpkins (Georgia Tech) CS 2340 Objects and Design CS / 22

Table of Contents. Page 3

VERSION 3.0 MAC USER GUIDE

TortoiseGIT / GIT Tutorial: Hosting a dedicated server with auto commit periodically on Windows 7 and Windows 8

Git, GitHub & Web Hosting Workshop

Version Control with Svn, Git and git-svn. Kate Hedstrom ARSC, UAF

Google Drive: Access and organize your files

WINDOWS 7 & HOMEGROUP

RingCentral from AT&T Desktop App for Windows & Mac. User Guide

Hosting Users Guide 2011

Version Control using Git and Github. Joseph Rivera

Avaya one-x Mobile User Guide for iphone

Introduction to Version Control with Git

Putting It All Together. Vagrant Drush Version Control

Hello Purr. What You ll Learn

Adobe Dreamweaver CC 14 Tutorial

Apple OS / ios Installation Guide Includes MAC OSx and ios based devices

How To Build An Intranet In Sensesnet.Com

Using Git for Project Management with µvision

Using Microsoft Azure for Students

Page 18. Using Software To Make More Money With Surveys. Visit us on the web at:

Backups User Guide. for Webroot SecureAnywhere Essentials Webroot SecureAnywhere Complete

ASUS WebStorage Client-based for Windows [Advanced] User Manual

ios App Development for Everyone

Cloud Backup Express

Help. F-Secure Online Backup

Site Administrator User Guide. show, tell, share

Finding and Opening Documents

CREATING YOUR OWN PROFESSIONAL WEBSITE

Google Analytics Guide

Knappsack ios Build and Deployment Guide

BIGPOND ONLINE STORAGE USER GUIDE Issue August 2005

Introduction. POP and IMAP Servers. MAC1028 June 2007

NJCU WEBSITE TRAINING MANUAL

Android: Setup Hello, World: Android Edition. due by noon ET on Wed 2/22. Ingredients.

CheckBook Pro 2 Help

Fundamentals of Great Plains & Reporting Tools

How to create PDF maps, pdf layer maps and pdf maps with attributes using ArcGIS. Lynne W Fielding, GISP Town of Westwood

How to read Temperature and Humidity from Am2302 sensor using Thingworx Edge java SKD for Raspberry Pi

NS DISCOVER 4.0 ADMINISTRATOR S GUIDE. July, Version 4.0

Automating client deployment

ISVforce Guide. Version 35.0, Winter

Samsung Xchange for Mac User Guide. Winter 2013 v2.3

OneDrive for Business User Guide

Unity Version Control

Frequently Asked Questions

VoIP Quick Start Guide

How to output SpoolFlex files directly to your Windows server

Mac System Setup Guide (Pre-Class)

IBI Group FTP: Usage Instructions

Editing Locally and Using SFTP: the FileZilla-Sublime-Terminal Flow

BarTender Version Upgrades. Best practices for updating your BarTender installation WHITE PAPER

How To Use Sharepoint Online On A Pc Or Macbook Or Macsoft Office 365 On A Laptop Or Ipad Or Ipa Or Ipo On A Macbook (For A Laptop) On A Desktop Or Ipro (For An Ipro

Business Portal for Microsoft Dynamics GP User s Guide Release 5.1

Xythos on Demand Quick Start Guide For Xythos Drive

Introduction to Source Control ---

Avaya one-x Mobile User Guide for iphone

Many home and small office networks exist for no

Save and Share Files in the Cloud with OneDrive for Business

Transcription:

To Begin: Setup In this first section we re going to create our Hello World project. This is going to be a very simple project. Learning Goals: Get a working version of Git on your Mac configured with your personal settings Have a basic understanding of Git commands: init, clone, branch, add, commit, pull and push Understand how to use GitHub to work alone and with others Download Xcode and install Download Xcode from the Mac App Store. You may have already done this in your attempt to learn ios programming in the past. You can visit the store here (https://itunes.apple.com/us/app/xcode/id497799835?mt=12) to pick up the app, or just type xcode into the search field at the top of the Mac App Store app. It takes a while to download, so you may end up going on to the next couple steps while you wait. If you don t have the latest version, go get it Apple consistently fixes bugs and crashes. Once Xcode is downloaded, you ll need to use your password to install the command line tools. This will give you Git as well as other important tools. Git Git: the ultimate tool to protect yourself from yourself. I once heard a developer say, the only tool that never loses data is Git. Git is the software that manages changes to your files. By tracking these changes, you will be able to recall specific versions of those files later. Using a version control system means that if you break your app, you can hopefully recover easily by reverting to previous versions of the code. Git is a free and open source distributed version control system. Distributed means that the change tracking is decentralized so you can continue working and editing a project even without maintaining connection to a common network. There are some upsides and downsides to a distributed tracking system, but you ll find with ios development that Git works very well. Git can handle small projects with one developer and large projects with hundreds of developers. You ll likely want to use git for every project. I can assure you that any employer will expect it. Go ahead and download and install git now. Follow this link (http://sourceforge.net/projects/git osx installer/) to download the git installer.

Get started with Terminal When we use the term command line, we re talking about giving instructions to your computer with keyboard typed commands. Think about common tasks you do on your computer with the filesystem: move folders, copy and paste files, create directories, and so on. You can actually do any of these actions using the command line; that is, you can tell your computer with text commands to do things like copy files or create directories. Each Mac computer comes pre installed with a powerful command line program, Terminal. You can find and open terminal by going to Applications>Utilities. Upon first open, you ll likely see a white window open with some text in it, something like this: The line in the above image that has the dollar sign ($) in it (TiBook:~/Desktop taylor$) is the prompt line. As prompt sort of implies, the system is waiting for your input. It s waiting to be told what to do. It s also important to note that the command line (Terminal) operates in a specific place on your file system. For example, if you wanted to copy a file, you d want to make sure that you tell the system the location of the file you want to copy. Each time you start Terminal, you are taken to a default location in the file system. It s very important to remember where you are at (or check) in the file system to ensure that you re actually doing what you think you re doing. Practice typing in a couple of basic commands: ls (this will list the contents of the current directory you are in) pwd (this will tell you where you are in the file system)

Sometimes commands require that you send more information. For example, cd is the command to change directories, or move your command line session to a different location. Simply typing in cd won t do much for you it s required that you tell the system where you re wanting to go. cd /Users/myname/Documents (this will take us to your Documents directory (assuming your username is myname ) cd../ (this will move up a directory,../ is the symbol for up one directory ) cd ~ (this will take you to your home directory. This usually looks like /Users/myname) Before going on, try using some of these commands: mkdir (makes a new directory) rm (deletes a file, be careful!) You can also search for more help on basic command line usage on the web. This video (https://www.youtube.com/watch?v=ms5snyyejew) is a pretty good resource. Learning the git commands Now, use the command cd to go to a place where you ll create your first git repository. This could be in your home directory, or in a new directory you ve created called DevMountain, or anywhere you d like. It should probably not be in a directory where there are already lots of other files and other directories, let s go to an empty directory (or create one using mkdir). Now that we re in the directory we want to create a Git repository in, let s get going: git init This initializes a Git repository in the folder to which you ve navigated. git add. This stages all of the files. "Staging" the process of preparing a file for a commit. You can actually specify the files you d like to stage for a commit on an individual basis; just change the. into the name of the file you want to stage. The '.' means you're staging all changed files for a commit. Now let's perform an actual commit:

git commit m "message" The commit message is important. The time you spend detailing what changed in each commit will be invaluable to you at some point very soon. When you write the message for your commit you could use the imperative, present tense: "change", not "changed" or "changes". You could instead use past tense. It s a matter of preference, but git itself does tell you to use imperative tense. Let's talk about how to link your repository to a remote source. git remote add origin url.git The above code will add a new remote source, in this case "origin" to your project. You also specify a url (in the above example it's "url.git") that the remote points to. Setting up remotes will allow you to synchronize your project among multiple computers or developers. It also ensures that if your computer crashes, the code and the repository are still safe somewhere else. (Remember "distributed?") When you create a new repository on GitHub or any other server side hosting solution, they ll give you a link to the repo like this one: https://github.com/jkhowland/shiny ninja.git. You ll want to find that link and add it to your local repo as the remote origin. git pull origin master This command pulls or retrieves information from the remote source, in this case the "origin" source and the "master" branch. You would do this anytime you want to update your local repository with changes or commits that have been "pushed" to the remote source. These are only the most basic git commands. You could actually get away with those few commands and have the backup and version control you need. But as you go on working and using git you ll discover other very important commands like: git branch tableview git checkout tableview This creates a separate branch for you to work on (called tableview). You can checkout master again and you can merge the two together. git checkout master git merge tableview If you ve made changes in tableview it will add them in to the local master codebase. Branching using git allows you to move back and forth between different features and bug fixes maintaining

the code for each of them separately. You can merge them into the master codebase when they re ready to rock. git push origin master This command will push your local commits to the specified remote. Remember, "master" is a branch, and it's generally the branch from which all of the release able code is deployed. So it's an important place to push updates to or pull updates from. If you've created more branches either remotely or locally, you can pull from or push to those branches by substituting "master" with the branch name you're referring to. If you re ready to try a few more things, you can try out Code School s trygit tutorial (it s pretty snazzy). DevMountain students will use Git on all of their class projects, and using Git should become second nature. Also, for further reading on a very handy Github feature called Pull Requests, here is (yet another) simple guide. Create a GitHub account You install git on your computer and it handles versioning for you locally. GitHub is a website that hosts code; think of GitHub as a tool for backup and distribution. It's a super fancy network built on top of the git system. It's important to recognize the difference between git and GitHub. You should not get confused and call git GitHub or vice versa. This article by Andrew McWilliams is pretty spot on: At it's core, it's just a place to store your identical working directories aka repositories, or repo's for short. That's the service that Github provides it's literally a hub for Git repositories. [sic] Visit GitHub and create a free account. While you re there, you could also download the GitHub Mac app. The Mac app is very useful for a lot of little features of GitHub (like opening up a pull request in code on your Mac). Other more powerful programs like Tower are available, but also cost money. The free GitHub account will allow you to create public repositories, fork public repositories, and fork private repositories to which you are granted access. Think of forking as making a copy of someone else's repository so you can make changes and improvements without messing them up. You can even submit pull requests if you find and fix bugs on other developer s projects. In order to create private repositories on GitHub, you ll need to pay for a subscription.

Create a public repository on GitHub Once you re logged in to GitHub, you can create your first public repository. Click on the plus button at the top of the GitHub homepage and select New repository. You ll want to give your repo (short for repository) a name. You can edit the description later, and the name doesn t have to be the name of your actual product. For example, at quite a few of the companies with which I ve worked we ve named the products based on Marvel characters, Street Fighters, or (so embarrassing) Lord of the Rings characters. The actual products had branding names, but the repositories were named something fun. Once you ve created the project, GitHub will give you the command line snippets you ll need to get a new repo set up locally. You ll even notice a green button that lets you use GitHub for Mac to set up the repo with the GitHub Mac app I mentioned earlier. We re going to create the local repo via Xcode, so we ll use the second example a bit later.

Create an Xcode Project Hopefully by now you have Xcode installed. It can take a while if you don t have a speedy internet connection. Open it up and click on the Create a new Xcode project on the left: Eventually, we ll create most of the project templates they give you here. For now, we ll start with a simple Single View Application. I m going to explain a couple of things in this new project window:

Give the project a product name like pre course git. I try to keep the Product Name something command line friendly. That means no spaces, and all lowercase. This isn t the display name for your app anywhere. It s just how your project file will be referenced. Spaces and capitalization can get in your way quickly. Feel free to leave the Organization blank if you re not building the project for an organization. The Organization Name will be used every time you create a file. It will show: // Copyright (c) 2014 <Organization Name>. All rights reserved. The Bundle Identifier is a mystery to most new developers. Apple suggests you use reverse DNS format. For example: if you company s domain is LearnStack.com and you create an app named Word Search, you could assign the string com.learnstack.word search as your app s Bundle ID. Note: Bundle IDs are case sensitive. They are used in Xcode, itunesconnect (app submission), icloud (sandbox names) and as the app ID in your member center for provisioning profiles (so you can install the app on test devices). The Class Prefix can be very useful if you use it wisely. You ll notice that Apple uses class prefixes to show which library the code comes from: UI (UIKit), NS (Foundation), GK (GameKit),

SK (StoreKit). You can make it obvious to anyone using your project what files are third party, or Apple libraries and which files are the code for your app specifically. We ll go into this in more depth in the first week of the course. Hit next and you ll select the location of the project: I will explain how I organize my projects, but you can honestly do whatever you want everyone has their own organizational style. All code on my Mac resides in one folder called "Code." Within that folder, there are a few types of repositories: project code, banked code, and archived code. Any projects that I m actively working on are in the project folder. Any code I ve written, or a third party library I want to save for other projects is put in the Code Bank folder. Projects I m not actively working on are in the archive folder. One of the options is to create the repo on My Mac or to create it on a server. Just select My Mac for now and hit Create.

Add the remote to Xcode s project Adding the GitHub remote to your existing project is relatively simple. You need to navigate to the project in the command line: cd code/pre course git (or wherever you stored it) Then use the commands from the repo s homepage on GitHub: git remote add origin https://github.com/jkhowland/shiny ninja.git git push u origin master Push to GitHub Now it s all easy. From the command line you can push: git push origin master Now your initial commit that was generated by Xcode is up on GitHub Edit the project s storyboard Let s add a UILabel to the app s single view. In Xcode, select the Main.storyboard file on the left and make sure that View is selected. On the top toolbar make sure the right most button is selected (blue) which will open the inspector on the right. In the bottom section of the inspector you ll want to have the cube selected. Then in the search field at the very bottom type in UILabel. You can click and drag the UILabel from the list onto the UIView, and edit all of the attributes of the label including the text and size.

Commit your changes Before you commit you ll always want to build and run to make sure everything is working as you expected when you wrote the code (or changed the interface file). If you have tests you ll want to run your tests as well. Go back to the Terminal app, and stage all of the changes you just made: git add. Then you ll want to commit the changes so that you can push them up to GitHub. git commit m "Adds a label to the main view" You ll always want to keep your commits small and modular. When you run into bugs you ll want to roll back to older commits. If each commit is small then it will be easier to peel back the layers until you can find the cause of the problem. If your commits are small and modular (meaning they apply only to a specific unit of the app) you can read what a commit does: Oh! This one adds a label to the main view. So it couldn t possibly be causing any network problems.

Push to GitHub Now get your code up on the remote server. git push This is the most simple git process: code, stage, commit, push. You re really going to want to get deeper into Git. Learn how to create and use branches. Learn how to review the change history and checkout a specific commit. Learn how to rebase your code with the latest on a remote repository. Learn how to submit a pull request on GitHub. And then learn even more. If you re going to be a professional developer take some time to get to know Git really well. In 1 4 hours you could really nail down a foundation that will help you for many years. Here are a few resources that are awesome: Git Immersion: http://gitimmersion.com/ The Git Book: http://git scm.com/book Git Real: http://www.codeschool.com/courses/git real