Posts tagged #xcode 6

14 Xcode Keyboard Shortcuts Cheat Sheet PDF

Download the . 

Further reading: Read more about the keyboard shortcuts in my previous blog post.

Click the image to view and download the 14 Xcode Keyboard Shortcuts PDF

Download

Download the and save time making your next app.

Connect

  • Follow me on Twitter: 
  • Subscribe to start learning Swift iPhone app programming with my Swift Primer video course.


Swift iPhone App Courses

Signup for a beginner . Learn from daily lessons and code exercises with instructor support.

Posted on September 25, 2014 and filed under Programming, Tips .

Swift 2 - How to get started with Xcode 6 on Mac

Have you used Powerpoint, Pages, Keynote or Word?

Each of these apps helps you create media rich content, and that’s exactly what Xcode does. It’s an Integrated Development Environment (IDE) that organizes all your code, interface files, and image resources.

Xcode is the tool that you will use to create your iPhone and iPad apps. Along with Xcode you will use the iOS Simulator to test your first iPhone app on your Mac computer.

Learning how to use Xcode is your first goal. You don’t need to know how to do everything, but you should become familiar with the interface and the common buttons and panels.

Learn how to open Xcode

After downloading Xcode following the previous Swift 1 - Download Xcode and start your first iPhone app tutorial, you are ready to open up Xcode.

Welcome to Xcode 6

You will use Xcode to organize, create, and debug your iPhone apps. It provides a staging ground for you to design and test your code and resource files.

1. Open Xcode

You can open Xcode by clicking on it in your Applications folder, or by searching with Spotlight (Command + Spacebar) in the top right corner. 

Xcode 6 has a new look for the icon

Xcode 6 has a new look for the icon

2. Start a new Xcode project

You can create a new Xcode project from the Welcome to Xcode screen by clicking on the Create a new Xcode project button.

Start your first iPhone app from the Xcode welcome screen.

Start your first iPhone app from the Xcode welcome screen.

(Optional) Create a new Xcode project from the menu bar

In the menu bar click on File > New > Project…

The menu bar is the easiest place to create a new file or Xcode project

The menu bar is the easiest place to create a new file or Xcode project

3 Create a Single View iOS Application

The easiest place to start is with the existing project templates that Apple provides in Xcode. Your first app will be a single screen. To get started on the top left corner of the dialog select iOS > Applications > Single View Application

Create a Single View Application

Create a Single View Application

4. Edit your Xcode project options

When you create a new Xcode project you’ll have to pick a few settings. If this is your first iPhone app, these settings aren’t super important. You can change any of these settings later on, or on your next Xcode project.

During the learning process, you’re going to create a lot of Xcode projects. Think of each project as a separate learning experience, start a new one when ever you want to try something out.

  • Product Name: The name of your app
  • Organization Name: The name of your company (or just your name)
  • Organization Identifier: A unique text string, you can set it to anything. Apple has recommended reverse DNS, which means website name in reverse. I use PaulSolt.com and flip it to create com.paulsolt
  • Note: If your an iOS Developer, this text needs to match what you register with Apple to run the app on your iPhone. 
  • Bundle Identifier: A unique identifier for the app itself. This text is made from your Organizational Identifier and your Product Name. It’s a setting you can also change later.
  • Language: You can make apps with Swift or Objective-C.
  • Devices: Choose iPhone to start, or iPad if you want to target a bigger screen. Universal is the third option, which allows you target both iPhone and iPad devices. 
  • Note: With iOS 8 and Xcode 6 it will be easier to create apps for both devices without as much device specific coding.
  • Core Data: Turn this option if you want to use the local database that Apple created called Core Data. For your first set of iPhone apps, I recommend you leave this option off, unless you understand how to use a database.

Note: Core Data is important if your app is going to maintain a lot of local data about users or information. However, simple calculator style apps probably won’t need it.

Setup your Xcode project options

Setup your Xcode project options

5. Save your Xcode project

The last step is to save your project folder on your Mac. I recommend that you create a Projects folder on your Desktop.

Navigate to your Desktop > Click New Folder > Type Projects > Create

You’ll create a lot of small Xcode project folders. Keeping them in one place will help you organize your work.

Create Git repository: If this is your first Xcode project, leave option unchecked. This option is for version control (git) and it’s used to keep different versions of your code. It’s an important part of software development. To learn more, visit GitHub.com

You can see my code on Github at

Save your Xcode project in a folder on your Desktop

Save your Xcode project in a folder on your Desktop

Your first Xcode project

When you first open Xcode you will see a lot of panels and the project settings in the center. The area on the left will show code, image, and user interface files.

  • .swift files are your code files
  • .storyboard and .xib files are your user interface files
  • Images.xcassets contains images like your app icon

In the center of Xcode you’ll find the project settings. There is a button in the top left corner which shows and hides an inner panel, and there are tabs along the top.

The project settings contains information like the supported orientations (i.e. portrait or landscape or both). There are also build settings, which you can ignore for now.

The first screen of a new Xcode project

The first screen of a new Xcode project

Xcode’s Panels

The buttons on the top right corner of show and hide the various panels in Xcode. Here’s what Xcode looks like with all of the panels open. 

Along the top of each panel there are additional tab bar items, which will change the contents of a panel.

You will need to hide panels on a small monitor, like on the Macbook Air. If you want to keep everything open, get an external monitor or an iMac.

I love my

There are 4 main panels in Xcode

There are 4 main panels in Xcode

  • Navigator Panel: The navigator panel includes the following tabs: Project Navigator, Find Navigator (search), and Issue Navigator
  • Standard Editor: This is the code text editor, which can be a single code file or multiple code and user interface files (Assistant Editor).
  • Utilities Panel: Context sensitive options will appear in the Utilities Panel. If you have a code file open, you’ll see different options than a user interface file.
  • Debug Panel: When you run your app with the Play button, you’ll see the bottom panel appear if there is a crash, or if your app logs any text out from a print command. There are two buttons in the bottom right corner to toggle the Variables view or the Console view.
  • Toolbar: The top toolbar contains the most common used functions such as starting and stopping your app or choosing what device to run it on (iPhone 6 Plus vs iPad vs iOS Simulator). The buttons on the right side control the visible panels.

Press Play

You can run your first iPhone app right out of the box. Press the play button in the top left corner of the Xcode toolbar.

The Play and Stop buttons look like music playback buttons

The Play and Stop buttons look like music playback buttons

When you run the app it should work and you’ll see a message in the center of Xcode. It should say Build Succeeded. If you didn’t do something correct it might say Build Failed.

Success

Success

Something's wrong

Something's wrong

Navigate Xcode Efficiently with Keyboard Shortcuts

You will become much more proficient with Xcode if you learn some of the Keyboard shortcuts. Try to incorporate one or two of the top 14 keyboard shortcuts for Xcode into your workflow.

Watch the Xcode Introduction Video

\n","url":"https://www.youtube.com/watch?v=RkjFYlh3Qdw&list=PLLYKjb-Uo9cy3tVE8_7fyxv1aaeN_zTxi&index=3&utm_source=iPhoneDevtv&utm_medium=blog&utm_term=Swift&utm_campaign=Swift2","width":854,"height":480,"providerName":"YouTube","thumbnailUrl":"http://i.ytimg.com/vi/RkjFYlh3Qdw/hqdefault.jpg","resolvedBy":"youtube"}" data-block-type="32" id="block-yui_3_17_2_1_1411056027966_173759">

Connect

Subscribe to learn more about Swift programming and iOS app development.

Swift iPhone App Courses

Signup for a beginner . Learn from daily lessons and code exercises with instructor support.

Absolutely fantastic. It’s about time there was a high quality class available online to learn about iPhone app development. Definitely would recommend!
— Dot Fuz
Posted on September 18, 2014 and filed under Programming .

14 Xcode Time Saving Keyboard Shortcuts - Memorize and Improve Your Productivity

Xcode 6 Keyboard Shortcuts

Update 9/25/14: Download the PDF version of the 14 Xcode keyboard shortcuts

Update 9/18/14: I added reader keyboard shortcut suggestions below (thanks!)

There are many keyboard shortcuts in Xcode 6 that can make yourself a more efficient programmer. They can help you quickly navigate around your code files to find and fix bugs, or to add new features to your apps.

When you’re in the zone, you want to be able to access the code files quickly, or the adjust Xcode’s panels to fit your small laptop screen.

The following keyboard shortcuts for Xcode 6 are the best ones to learn first. You will probably use them every day after you learn them.

Xcode Navigation Keyboard Shortcuts

1. Project Navigator: Command + 1

Quickly view all your code, images, and user interface files.

The Project Navigator is your central hub for all code, interface, and image files

The Project Navigator is your central hub for all code, interface, and image files

2. Show/Hide Navigator Panel: Command + 0

When you’re short on screen space, you’ll want to close anything that gets in the way. The happens a lot if you use the Assistant Editor (tuxedo) or when you design the user interface and connect it to code.

Show and hide the Navigator Panel

Show and hide the Navigator Panel

3. Show/Hide Utilities Panel: Command + Option + 0

The Utilities Panel is primarily used when you’re editing your user interface files. If you are only writing code, you can hide it.

 

Show and hide the Utilities Panel

Show and hide the Utilities Panel

4. Open file in Assistant Editor: Option + Left-click on file in Project Navigator

A quick way to open the Assistant Editor (Tuxedo button top right) is to Option click on a file you want to open side by side with the currently opened file.

Show multiple code or interface files with the Assistant Editor

Show multiple code or interface files with the Assistant Editor

Xcode Search Keyboard Shortcuts

When you are editing code, adding new code, or trying to fix a bug, searching is the fastest way to find something. Instead of scrolling through hundreds of lines of code you can find all occurrences of a variable, or jump to a specific line of text.

5. Find Navigator (ie. Search): Command + Shift + F

Find all the times you mentioned a variable or method name with the project search. You can match based on case, or ignore upper and lower case letters. 

You can also replace all occurrences of a variable name with a new variable name.

Search for text or symbols in your Xcode project

Search for text or symbols in your Xcode project

6. File Jump Bar: Control + 6 (Type the method/variable name + enter to jump)

Jump to a line of code within your current code file. If you have hundreds or thousands of lines of code, you can quickly narrow down where you need to insert code to support a new app feature.

Jump bar allows quick access to methods or variables within a code file

Jump bar allows quick access to methods or variables within a code file

7. Open Quickly: Command + Shift + O

If you prefer to only use the keyboard and not the mouse, you’re going to enjoy Open Quickly. It let’s you just type and jump to a method definition or a specific code file.

Open a file quickly or jump to specific method using Open Quickly

Open a file quickly or jump to specific method using Open Quickly

8. Jump Bar and Open Quickly Search Typing Shortcut

You can type the first letter of each word, which allows you to quickly switch to a file or find a particular line of code.

Example, in ViewController.Swift press Command + Shift + O and then type vDL. The first result will be the function with the name viewDidLoad()  

Type less and search more with using starting letters for method names: i.e. vDL for viewDidLoad

Type less and search more with using starting letters for method names: i.e. vDL for viewDidLoad

9. (Objective-C or C++) Switch between .h and .m files: Control + Command + Up Arrow

If you are writing Objective-C, C++, or using Open Source code written in either language, you might need to lookup existing code.

You can quickly switch between two related code files, like the header and implementation files in Objective-C using this Control + Command + Up Arrow shortcut.

If you’re writing code in Swift, you won’t need to worry about this shortcut, since Swift uses a single code file.

App Building and Cleanup

To try out your new app you have to run it, and occasionally Xcode doesn’t feel well, so you may have to clean it up.

These shortcuts will keep you writing code without stopping to use the mouse as much.

10. Run the app: Command + R

When I write code, I routinely use this command to make sure the app is running bug free. The more often you test your app the better, since you can find and fix bugs early, before they become big problems.

Run your first iPhone app - Press Play!

Run your first iPhone app - Press Play!

11. Clean the project: Command + Shift + K

Occasionally Xcode will freeze, or something in your app becomes unresponsive or unpredictable. When that happens you’ll first want to clean and then re-run the Xcode project.

If that still doesn’t fix the problem, close Xcode and re-open it again. 

Try to run the app, and if that doesn’t work, you need to see if there’s an error message that you can Google for more help.

You shouldn’t have to do this too often, since it’ll make building your app slower. It removes all the intermediary files and recreates them which takes more time to complete.

Clean up Xcode when it fails to work

Clean up Xcode when it fails to work

12. Build the app: Command + B

Checking to make sure the code you write is in working order is something you’ll want to do often.

Even though Xcode checks it shortly after writing, it can sometimes be delayed, or give false errors. Building your app project allows you to make sure it’s in working order before you go to code the next feature.

You don’t always have to run the app, if you are making minor changes, and that’s where building can help you do a quick check, so that you can get back to adding the next line of code.

Build your code to make sure you don't have any errors - quickly double check your work

Build your code to make sure you don't have any errors - quickly double check your work

Documentation and Help

Learning how to help yourself is equally important. If you haven't already taken a look at the Xcode documentation, use these shortcuts to lookup related code reference. 

Read or skim some of the reference guides to get better acquainted with the code that Apple provides, which you can use to make more robust iPhone apps.

13. Documentation and Reference: Command + Shift + 0 (Zero)

After you install all the documentation with Xcode, which it should do in the background after installing it. You can search the documentation offline, which is great when you’re traveling and you’re trying to figure out how to add a new screen or feature to your app.

Open the Documentation and Reference and search for a keyword that you’ve seen in code. You should be able to find some additional resources and sample projects through the Xcode documentation.

Find out how to use code with Documentation and reference guides

Find out how to use code with Documentation and reference guides

14. Quick Help: Option + Left-click on class or method name

Inline help can make it easier to learn what a class or piece of code is actually doing. There’s a lot of code that’s already written, which you can leverage with the help of Quick Help.

Hold Option and Left-click on a variable, class, or method name to get more details. You can quickly jump to the documentation, if you click on the reference link in the bottom of the popup.

Pro Tip: Jump directly to the reference guide by double-clicking the left mouse button while holding Option over a class name.

Get Quick Help to reference while you write code

Get Quick Help to reference while you write code

What Shortcuts do you use?

Share what hotkeys make you faster or more effective.

Reader Tips

One of my new favorites I learned just recently and use it often is Command + Shift + J, which reveals the file you currently have open in the project navigator. I spent my days in a very large codebase, so this is a very fast way to jump around.
— weendex
I’m a big fan of CTRL + 1 which opens the “Show Related Items” popup. If you have the cursor in any method and hit CTRL + 1 you can easily access all the callers and callees of the current method via this popup. I am constantly navigating up through the callers of a method to see how it’s used.
— skoll
Cmd + . to stop the iOS Simulator is generally pretty handy as well.
— weendex
One that isn’t in the article that I use all the time is Command + Option + Shift + Left-click a file. This presents you with a little popover and you can say where you want it opened in, an assistant editor, a tab, a window, etc.
— Cheezybob
Or if you really want to get serious about developing stuff get AppCode! http://www.jetbrains.com/objc/
— martinni39

Connect

Subscribe to start the Swift Primer course. Learn how to make your first iPhone app in Swift.

Complete Course Bundle - Swift iPhone App Courses

Signup for 4+ courses on making . Learn from daily lessons and code exercises with instructor support.



Posted on September 15, 2014 and filed under Tips .