3

Goodday!

  • ToDo: compile the files from a directory that is outside of my Xcode project. How to tell Xcode the path to look for source codes to compile (like the VPATH in a makefile)?

Note1: Right-click the target and it is easy to add the search path for header files or lib, but there I havent found any option to add a new source code directory.

Note2: I havnt found an answer in the xcode build documentation for this issue.

P.S.: I hope that I can do it without copying all the files to the xcode explicitly.

Thank you!

3 Answers 3

1

Drag the directory containing the files into your Xcode project. The only way Xcode knows it needs to compile the files is if they are contained in the project and a part of the target.

Sign up to request clarification or add additional context in comments.

3 Comments

In fact that is what I hope to avoid to do. Because I will use that directory in many projects and that directory contains many files. Is there another way?
The fact that you use it in many projects doesn't matter. Add the folder to the project and then delete any files you don't need. You can use the filter box at the bottom-left to make it easier to select just the set of files you want. For example, if I wanted to get rid of all .c files from a folder containing both c and cpp files, I'd drag the folder in, filter on .c delete the files (references only) and then remove the filter. Wash, rinse, repeat for whatever patterns you need to exclude. This only has to be done once, so it's not too painful.
Ok, i take that as the solution. Thanks!
1

You indicated that you wanted to use at least some of the source files in a project and intend on using some set of the same source files for other future projects.

Create a new static or dynamic library using the external collection of source files and then just link this project to it and future projects to it

The design of most build environments encourages the use of code in reusable libraries.

Davidli

Comments

1

By the way (for those who are still searching and have problems with this issue), i have Xcode 4.5.2 and when i drag the items they are not linked! It seems that xcode's getting worse with each new version.
In case of xcode 4.5.2 if i copied class files into the separate folder i had to do right click to the group and choose 'add files to ""'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.