xcode tutorial for gatb · xcode tutorial for gatb patrick durand, inria - june 27th, 2017

37
XCODE TUTORIAL FOR GATB Patrick Durand, Inria - June 27th, 2017

Upload: lycong

Post on 25-May-2018

226 views

Category:

Documents


1 download

TRANSCRIPT

XCODE TUTORIAL FOR GATBPatrick Durand, Inria - June 27th, 2017

XCODE ?

Integrated Development Environment (IDE)

Graphical tool; kind of “swiss knife” for software developers: code editing, symbol navigation, auto-code compiling, debugger, code instrumentation, etc.

native IDE for OS X

Very well suited tool for c++ developments on OS X

XCODE & CMAKE ?

Actually, there is a perfect integration !

Command-line use with GATB-CORE/TOOL projects:

Using Xcode would imply: cmake -G "Xcode" -D CMAKE_BUILD_TYPE=Debug .. # do NOT run make !

cmake .. make -j

XCODE & CMAKE ?

Actually, there is a perfect integration !

Command-line use with GATB-CORE/TOOL projects:

Using Xcode would imply: cmake -G "Xcode" -D CMAKE_BUILD_TYPE=Debug .. # do NOT run make !

cmake .. make -j

Required !

PREPARING GATB-CORE

Note : what we are going to do on GATB-CORE is fine with GATB-TOOLS too !

Basic steps :

1 - prepare a working directory

2 - “git clone” the project (Github or Forge Inria) there

3 - run “cmake -G `Xcode’…”

4 - import project “xcodeproj” (created by CMake) into Xcode

read-only read-write

PRACTICAL STEPS# enter your home cd ~

# create the working directory mkdir gatb-xcode

# enter that directory cd gatb-xcode

# clone gatb-core; git clone https://github.com/GATB/gatb-core.git or git clone git+ssh://<login>@scm.gforge.inria.fr/gitroot/gatb-core/gatb-core.git

# make a build directory (to be used by cmake) mkdir build

# little ‘check', you should have this: pdurand@prg:~/gatb-xcode$ l-l drwxr-xr-x 2 pdurand staff 68B Jun 27 09:26 build/ drwxr-xr-x 5 pdurand staff 170B Jun 27 09:25 gatb-core/

# run cmake cd build cmake -G "Xcode" -D CMAKE_BUILD_TYPE=Debug ../gatb-core/gatb-core

IMPORTANT

Unlike usual procedure, we do not create the “build” directory inside GATB-CORE source project…

… so that we do not interfere with the classical approach relying on the use of “cmake/make” within “gatb-core/gatb-core/build”

RESULT FROM CMAKE-XCODEpdurand@prg:~/gatb-xcode/build$ ll total 128 drwxr-xr-x 17 pdurand staff 578B Jun 27 10:05 ./ drwxr-xr-x 4 pdurand staff 136B Jun 27 09:26 ../ -rw-r--r-- 1 pdurand staff 42K Jun 27 10:05 CMakeCache.txt drwxr-xr-x 13 pdurand staff 442B Jun 27 10:05 CMakeFiles/ drwxr-xr-x 31 pdurand staff 1.0K Jun 27 10:05 CMakeScripts/ -rw-r--r-- 1 pdurand staff 3.8K Jun 27 10:05 CPackConfig.cmake -rw-r--r-- 1 pdurand staff 4.3K Jun 27 10:05 CPackSourceConfig.cmake -rw-r--r-- 1 pdurand staff 3.0K Jun 27 10:05 README.txt -rw-r--r-- 1 pdurand staff 2.8K Jun 27 10:05 cmake_install.cmake drwxr-xr-x 5 pdurand staff 170B Jun 27 10:05 doc/ drwxr-xr-x 4 pdurand staff 136B Jun 27 10:05 examples/ drwxr-xr-x 3 pdurand staff 102B Jun 27 10:05 gatb-core.xcodeproj/ drwxr-xr-x 3 pdurand staff 102B Jun 27 10:03 include/ drwxr-xr-x 5 pdurand staff 170B Jun 27 10:05 src/ drwxr-xr-x 6 pdurand staff 204B Jun 27 10:05 test/ drwxr-xr-x 6 pdurand staff 204B Jun 27 10:05 thirdparty/ drwxr-xr-x 4 pdurand staff 136B Jun 27 10:05 tools/

Directory to import in Xcode

STARTING XCODE

Via Spotlight Search : enter “xcode”

Via Finder : xcode should be located in “Applications” folder

STARTING XCODE

Via Spotlight Search : enter “xcode”

Via Finder : xcode should be located in “Applications” folder

STARTING XCODE

Via Spotlight Search : enter “xcode”

Via Finder : xcode should be located in “Applications” folder

click! …or… [cmd]+o…or… File/Open

IMPORTING THE CMAKE PROJECT

XCODE PREPARING THE PROJECT

UI ELEMENTS1

2

3

45

1. Target selection + compiling

2. Navigators3. Navigator display4. Editor5. Utilities

(can be hidden: not used with GATB projects)

NAVIGATORS

1. Code2. Symbols3. Search4. Messages5. Tests6. Debug session7. Breakpoints8. Reports

SOURCE CODE NAVIGATOR 1/2

• single click: open in current editor • double click: open in new frame

single click : open in current editor

Sour

ce o

rgan

ised

by

targ

ets

SOURCE CODE NAVIGATOR 2/2

On every symbol:[alt]+click = help[cmd]+click = jump to definition

WORKING SESSION: LEONChecking build settings for a Target

12 3

4

WORKING SESSION: LEONCompiling

12

WORKING SESSION: LEONAdding parameters (i.e. ‘Leon’ command-line arguments)

12

WORKING SESSION: LEONAdding parameters

-c -file /Users/pdurand/gatb-xcode/gatb-core/gatb-core/test/db/leon1.fastq

1

23

WORKING SESSION: LEONTool execution: success!

1 2

3 : stdout is here !

WORKING SESSION: LEONDebugging the tool !

1: click on line number!

2

3

WORKING SESSION: LEONDebugging the tool !

2 3

1

4 5

6

1. Call stack2. Local variables3. lldb command-line4. Debugger commands

(step over, step in, …)5. Current scope6. Debugger is stopped here

WORKING SESSION: LEONLocating our changes in the project

ADVANCED OPTIONS

RELEASE VS. DEBUG CONFIGURATION

2

1

…/…

RELEASE VS. DEBUG CONFIGURATION

2

1

GIT HISTORY, ETC.

2

1

…/…

GIT HISTORY, ETC.

…/…

SOURCE CONTROL USING XCODE

SOURCE CONTROL USING CMD-LINE

GIT STATUS

# enter gatb-core source folder cd ~/gatb-xcode/gatb-core

# any changes ? git status

# from here: git add, git commit, git push

pdurand@prg:~/gatb-xcode/gatb-core$ git status HEAD detached at f902ef3 Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)

modified: gatb-core/tools/leon.cpp

no changes added to commit (use "git add" and/or "git commit -a")

GIT PULL

# enter gatb-core source folder cd ~/gatb-xcode/gatb-core

# update project from remote git pull

# back to cmake/xcode build folder cd ../build

# rerun cmake cmake .

# go back to Xcode: she will apply any changes automatically

Caution : sometimes, you have to reset “build settings” of your targets.

GIT CHECKOUT

# go to gatb-core source folder cd ~/gatb-xcode/gatb-core

# for instence, get release v1.3.0 git checkout v1.3.0

# back to cmake/xcode build folder cd ../build

# rerun cmake cmake .

# go back to Xcode: she will apply any changes automatically

Caution : sometimes, you have to reset “build settings” of your targets.

USEFUL LINKS

Using Xcode debugger : https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/debugging_tools.html

Xcode help : http://help.apple.com/xcode/mac/8.3/