Showing posts with label Xcode4. Show all posts
Showing posts with label Xcode4. Show all posts

Wednesday, March 14, 2012

Rebuilding Code Sense and Syntax Highlighting on Xcode 4

Sometimes syntax highlighting does not work on Xcode 4. Syntax highlighting is an important feature to developers. But there is no "Rebuild Code Sense" menu on Xcode 4. We can do it with following steps:

1. Xcode menu: Window->Organizer

2. Go to Projects tab

3. Choose your project on the left panel.

4. Click "Delete…" button after the Derived Data on the right panel.

Xcode will start to rebuild code sense of your project.

Sunday, October 09, 2011

Xcode 4 and Git

I am new to Git. I used Perforce (P4) before, so I thought it is easy to use Git. Actually I was wrong. Git is not complex, but it has different concept.

In P4, we just check out and check in files. In Git, checking in has a new name Commit. When I committed my first change, I was surprised to see it does not appear in the server. Actually, Git did not really submit my code to the server. It was stored locally. I have to run this command in the command line:

git push origin master

So you must Push the local Commits to the server.

The problem is Xcode 4 can Pull, Commit, Compare, but does not provide Push functionality. How stupid the designer is. You can modify but cannot submit! Actually Pull, Commit and Compare are the only functionalities Xcode 4 provides. You cannot even revert!

Xcode 4 is free, but Apple should not make it suck.

Update on Nov 30, 2011:

SourceTree on Mac App Store is an excellent Git client. It is much better than GitX. And it is FREE!

Friday, August 19, 2011

Add Tool Tip to Controls with Xcode4

Like many Apple developers, I was a developer on Windows platform before. It is very easy to add tool tip to a control (e.g. a button) in Visual Studio. But I don't know how to do it in Xcode. When I am working on iPhone apps, it is not a problem because iPhone apps need not tool tip. But it is a problem when I am working on Mac apps.

Actually it is easy to add tool tip in Xcode 4. Looks like Apple put it in a wrong place. You need to add tool tip in Identity Inspector.

Add ToolTip in Xcode

Monday, July 18, 2011

Adding a framework in Xcode 4

The steps of adding a framework in Xcode 4:

1. Click current project in Project navigator.

2. Click a target in Project editor.

3. Choose Build Phases tab.

4. Expand Link Binary With Libraries

5. Click + button, add a framework.

6. Go back to Project navigator. You will see the new framework added. You can drag it into Framework group. If you have more than one target, you need not repeat the steps for other target. Just choose this framework in Project navigator, and make selection in Target Membership in File Inspector on the right Utility window of Xcode.

Monday, April 11, 2011

Add an existing framework in Xcode 4

Steps to add an existing framework in Xcode 4:

1. Click the project in the project navigator.

2. In the project editor, click a target.

3. Select 'Build Phases' tab

4. Expand 'Link Binary With Libraries'

5. Click '+' button to add a framework.

6. Go back to the project navigator, you will see the new framework. You can drag it to 'Frameworks' group.

Wednesday, April 06, 2011

WWDC2010 Session313 LLVM Technologies in Depth

This session covers: Clang in Xcode 4 (Code completion, Fix-it, Indexing and Edit-all-in-scope), Clients of LLVM(LLDB, Integrated assembler).

Using Clang Inside Xcode 4

Many contents have been covered in Session 312. Just more examples.

Benefits of LLDB Design

Higher fidelity expression parsing and evaluation

Support all language constructs

     Inline function, template instantiation   

     Debugger gets new language features

Less platform specific knowledge in the debugger

Can pull in other compiler features: Fix-it, code completion

Assembler

LLVM Compiler 2.0 have an integrated assembler. We need not generate .s file and parse big text files. It saves much time.

LLVM assembler

Benefits of LLVM Integrated Assembler:

10% f aster builds (for debug builds of many applications)

Better error messages for inline assembly

More useful assembly dumps

WWDC2010 Session313 LLVM Technologies in Depth

Author: Ted Kremenek - Manager, Compiler Frontend Team

Tuesday, April 05, 2011

WWDC2010 Session312 What's New in the LLVM Compiler

LLVM stands for Low Level Virtual Machine which is a compiler infrastructure, written in C++. The LLVM project started in 2000 at the University of Illinois at Urbana-Champaign, under the direction of Vikram Adve and Chris Lattner. In late 2000, Lattner joined the University of Illinois at Urbana-Champaign as a research assistant and M.Sc. student. Lattner was hired by Apple in 2005.

Compiler Landscape

Three compilers

3 compilers

LLVM Compiler in Xcode 3.2.3 does not support C++. You have to use LLVM-GCC for C++ in Xcode 3.2.3. Now LLVM Compiler 2.0 in Xcode 4 supports C++. That is why the default compiler of Xcode 4 is LLVM Compiler. GCC 4.2 is not recommended because Apple will not fix bugs any more.

WebKit, JavaScriptCore, OpenSSL are built with LLVM in iOS 4. Performance improvement: Open SSL 28%, JavaScriptCore 11%.

LLVM Compiler:

1. Fast compile times - Almost 3x faster debug builds

2. Great user features

3. Beautiful error messages

4. compatible with GCC

Clang Frontend is a parser for C family of languages including C, Objective-C, C++.

Clang is part of many great new tools: LLVM Compiler, Xcode Static Analyzer, Xcode 4, LLDB Debugger, OpenCL. Clang is integrated into Xcode 4 for source code indexing, syntax highlighting, code completion, live warnings and Fix-its.

Xcode Static Analyzer
Automatically find bugs by analyzing your code.

WWDC2010 Session315 Using Interface Builder in Xcode 4

Interface Builder is integrated into Xcode 4.

XcodeI4 Interface Builder

All the window or views in a xib file will show in the design canvas not in a separate window any more.

There is a media library in the interface builder. You can preview and add a picture to your UI directly.

Select a control, press Option key, and move your mouse, you will see some useful annotations.

In Identity Inspector, there is a small arrow at the right side of the class. You can click it to browse the definition of this class.

When you select a control, the Quick Help will show some useful info including sample code.

Connection

Ctrl-drag or right-button drag to make connection, insert IBOutlet, IBAction.

Xcode Assistant content: Top-level objects, custom classes, classes with connections.

It is convenient to use Interface Builder in Xcode 4, though there is no more new about Interface Builder.

WWDC2010 Session315 Using Interface Builder in Xcode 4

Author: Kevin Cathey - Interface Builder Engineer

WWDC2010 Session314 Building and Distributing Your App with Xcode 4

This session covers: How to use the Xcode 4 interface to construct and edit projects and targets. How to construct schemes to build, launch, and archive apps, How to build workspaces to relate multiple projects and share schemes with others.

Editing project settings

When you click the project in the project navigator, you will see the project settings in the editor. It is well organized. If you don't know the meaning of an option, you can click 'Quick help for selected item' in the Help menu. If you have enabled Quick Help tab on the right panel, you will see the quick help there. Very convenient. I notice that the default compiler of a new project is set to LLVM Compiler 2.0.

Editing target settings

Editing target settings is similar to editing project settings. Good news is if you have several targets, you can select some of them to see the differences. In Combined view, the different option shows <Multiple values>. In Levels view, you can see the different value for each target. This is an awesome feature I like.

The editor of 'Run Script' build phase of a target setting now support color-highlighting.

Scheme

Covered by Session307.

Workspace

Covered by Session307.

WWDC2010 Session314 Building and Distributing Your App with Xcode 4

Author: Chris Espinosa - Manager, Xcode Core Tools

Monday, April 04, 2011

WWDC2010 Session308 Developing Your App with Xcode 4

This session covers source control, source editor, find an replace and version editor.

Source control

When you create a new project, you have an option to create a local git repository. You can copy a git link from github.com, create a repository in Organizer, and clone it.

Source editor

Assistant editor - the secondary editor to show related file. For example, if you select .h file, the .m file will show in the assistant editor. You can press Option key and click a file to show it in the assistant editor. Option key works for all items. You can right click an item, press Option key and click 'Jump to definition'. Then the definition shows in the secondary editor.

Auto completion

When you want to implement a method declared in .h file, you need not copy that declaration. You just need to type in a couple of letters of that function name, Xcode will show all unimplemented methods automatically. You can use ctrl-space to invoke it manually. However, looks like Xcode 4 indexes a little bit slow, it does not show my method. I closed my xcode, and restarted it. Then my method showed up. Another problem is the shortcut 'Ctrl-space' conflicts with Spotlight of the OS X.

Code Snippet Library

You can create your code snippet by dragging some lines of code into Code Snippet Library.

Example:

static dispatch_once_t once;

dispatch_once(&once, ^{

});

You can give it a name and the shortcut (key word). And you can also add a token. After you used this code snippet, you just press Tab to move the cursor to that token.

Example:

static dispatch_once_t once;

dispatch_once(&once, ^{

<#code#>

});

WWDC2010 Session307 Introducing Xcode 4

Xcode 4 is an all-in-1IDE just like Visual Studio (I have used Visual Studio for more than 10 years. Comparing to Visual Studio, Xcode 3 is not convenient. Fortunately, Xcode 4 changed it). Interface builder is no longer a separate application. You can write code, design UI, debug in Xcode 4. This session covers workspaces, navigation, editing, organizer, version editor, debugging and schemes.

Xcode4

Workspaces

The workspace is similar to Visual Studio's solution. A workspace works as a container(actually it just references files). You can add several projects into a workspace. Visual Studio 2001 supported the solution. Xcode supported the similar thing 10 years later. The difference is Xcode 4 does not force you to create a workspace. You can open a project directly in Xcode4. But you have to create a solution in Visual Studio even if it contains only one project.

Projects can be shared between workspaces. Every workspace has its own index, build folder.

Navigation

The left panel of Xcode 4 contains several navigators.

1. Project navigator - shows all projects and files

2. Symbol navigator - shows class hierarchies, members, functions

3. Search navigator - find and replace

4. Issue navigator - shows warnings and errors

5. Debug navigator

6. Breakpoint navigator - shows breakpoints

7. Log navigator