سؤال

I'm playing around with lots of little C files whilst going through a book. Eg:

  • defs.h
  • chapter01
    • pointers.c
    • structPointers.c
    • vectorOps.c
    • defsTest.c
  • chapter02
    • selectionSort.c
    • recursion.c
    • bubbleSort.c
  • etc…

I'm currently using a great little app called CodeRunner, but I do miss the debugging and intellisense features in Xcode.

Is there a way to set it up the project so I can run each file individually from within the one project? I know I could always make a single workspace with a project for every single file, but that seems very cumbersome – there's gotta be a better way.

هل كانت مفيدة؟

المحلول

1)

Yep. Using the command line (you have to install the "Command Line Additions" that you can download from the "Looking for additional developer tools" link on this page building can be as easy as:

gcc -o selectionSort selectionSort.c

(provided you have a "main" function in your .c file).

Or:

2)

To build from within the Xcode IDE, you'd have to create a new product (or target) for each little app you want to build and add the appropriate .c file you want to build to that new product. The type of app you'd be building would be called a "Command Line Tool".

When you create a new project or select "New Target", this is what you would see and select:

enter image description here

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top