-1

I really need to use the debugger in Xcode but I can't get to make this work. I use the terminal on Mac, to compile a file, which I usually just change the directory and then I have .sh file and I write that down and everything compile, note this is what is in .sh file :

#!/bin/bash
clear

echo "cleaning directory"
rm mag_test.out

echo "Compiling mag_cal_driver.c"
g++ -o mag_test.out mag_cal_driver.c ../src/mag_utils.c

echo -e "Running magnetometer tests\n"
./mag_test.out

how can I achieve this in Xcode ???? note the code is in c! enter image description here

enter image description here

1 Answers1

0

For

rm mag_test.out

In MAC

make clean

Save the file as .c and type in the terminal:

gcc -o yourfilename yourfilename.c

or

 make yourfilename

Afterwards just run the executable like this:

./yourfilename

For debugging

You can use lldb

$ lldb yourfilename  

break point

$breakpoint set --file yourfilename .c --line 12

Best is xcode interface for debugging (IDE)

For Installing LLDB follow LLDB INSTALLATION

For Guide use LLDB GUIDE

IF you want to use xcode IDE follow the step 1.Start xcode

  1. Select Create new Xcode Project

  2. Select Command line tool

command line

4.Select the language

Language selection

5.Create and add File and breakpoint as you like(blue arrow marked is debug break point)

6.After that just play the execute button at top most left corner

debug

Hariom Singh
  • 3,512
  • 6
  • 28
  • 52
  • 1
    hey does any body actually read what i wrote , i know how to compile it , as you saw in .sh file it do that , exactly ! how i do it in xcode ??? i need to use the debugger ! – Hamidreza Rezai Aug 11 '17 at 03:23
  • mybe i wrote it bad , but i know how to compile it using the terminal , how to compile it in xcode ?, so i be able to use Xcode debugger ?? – Hamidreza Rezai Aug 11 '17 at 03:31
  • i just saw your new edit , i see i can see how to do LLDB but i really want to be able to do it in xcode since it has graphic interface which make my life much easier in the end ! – Hamidreza Rezai Aug 11 '17 at 03:35
  • @HamidrezaRezai added steps let me know if you are struck anywhere – Hariom Singh Aug 11 '17 at 03:39
  • the problem lies i knew how to do this , but that is if i write my code in here, my code is already written and is in a folder with many other .c file and it will use many other library and some other data file, when i use terminal and compile it it compile and everything works , but i cant make it work to add it somehow to xcode that it compile . also thanks for helping me ! – Hamidreza Rezai Aug 11 '17 at 04:02
  • @HamidrezaRezai was the old code is xcode project or some other file – Hariom Singh Aug 11 '17 at 04:10
  • no it was not a Xcode project, i used notepad++ to write it ! – Hamidreza Rezai Aug 11 '17 at 04:13
  • If you just want to add files use Add files to (your project) – Hariom Singh Aug 11 '17 at 04:13
  • i edited my original post and added a pic to it as you see thats the folder i have , i need to compile mag_cal_driver.c but what ever i do i cant be able to i deleted the main which does create automatically but weren't able to make that file the main! – Hamidreza Rezai Aug 11 '17 at 04:29
  • @HamidrezaRezai Your code is from git ..there is one more easy way .start xcode->checkout an existing project (place your git path) – Hariom Singh Aug 11 '17 at 04:32
  • i used that option , it only downloaded the files nothing else it didnt added it to any project or anything ! – Hamidreza Rezai Aug 11 '17 at 04:49