55

Im playing around with the soundcloud api, in its instructions it says to

  • drag SoundCloudAPI.xcodeproj into your project
  • add it as a build dependency

I can drag the project in pretty easily, but how does one accomplish the next step?

JAL
  • 41,701
  • 23
  • 172
  • 300
Aran Mulholland
  • 23,555
  • 29
  • 141
  • 228
  • 7
    Does this work as of the latest version of xCode? I am having problems that I never had before with this, it simply adds the file, not the project. – Richard J. Ross III Oct 20 '11 at 17:18
  • You should ask this as a separate question. I have not looked at this in a while, however, in the latest version of xCode you have the concept of a workspace which can consist of multiple projects, look into that. – Aran Mulholland Oct 20 '11 at 21:12
  • 2
    **[Here](http://stackoverflow.com/questions/9726000/xcode-4-2-and-using-a-static-library-causing-problems?answertab=votes#tab-top)** are some great step-by-step instructions on how to add static library dependencies in more recent versions of Xcode. – filitchp Oct 18 '12 at 22:28
  • @RichardJ.RossIII I met the same problem. Then I found the reason for my problem is that the lib project is already added into some other workspace. So I copied the lib project folder, and added the copied project into the workspace I want to work on. Hope it helps somebody. – Xiaoqi Jun 05 '17 at 09:39
  • 1
    @RichardJ.RossIII make sure the project you're trying to add is not open in XCode. If it's open in XCode, it will only add the .xcodeproj file, not the whole project. – Dog Sep 11 '17 at 09:16
  • @Wonder Dog: Correct!, this solved my problem – user18853 Jul 26 '18 at 08:16
  • Does this answer your question? [Xcode 4.2 how include one project into another one?](https://stackoverflow.com/questions/9370518/xcode-4-2-how-include-one-project-into-another-one) – Top-Master May 17 '21 at 16:12

7 Answers7

29

To add it as a dependency do the following:

  • Highlight the added project in your file explorer within xcode. In the directory browser window to the right it should show a file with a .a extension. There is a checkbox under the target column (target icon), check it.
  • Right-Click on your Target (under the targets item in the file explorer) and choose Get Info
  • On the general tab is a Direct Dependencies section. Hit the plus button
  • Choose the project and click Add Target
theChrisKent
  • 15,029
  • 3
  • 61
  • 62
  • What is the 1st step for? As I can still do the following three steps without doing it. – Aran Mulholland Nov 21 '10 at 21:44
  • any idea what that first step does? – Aran Mulholland Dec 02 '10 at 03:54
  • This links the project(s) to yours. This tells the linker where symbols that are only defined in that project exist and prevents you from getting "undefined symbol" linker errors. – theChrisKent Dec 02 '10 at 14:23
  • 1
    That's weird. Xcode does not let me add a Direct Dependency. What should I do? – Herberth Amaral May 09 '11 at 14:15
  • 2
    I've tried this but it doesn't work. The frameworks I need are still in red as if they are missing. – Eric Brotto May 30 '11 at 16:51
  • 4
    These instructions confuse me, as I'm pretty sure they're for an older Xcode version. See @filitchp's answer for a link to instructions that work with Xcode 5. – Liron Yahdav Apr 07 '14 at 20:04
  • 3
    Remember to close the .xcodeproj you're trying to add if you had it open in Xcode already. You cannot drill down into the file structure nor add the .framework of the nested project if the same project is already open in another screen. If you close both instances of Xcode and only reopen one project it'll work. – Lucas van Dongen Nov 22 '17 at 12:44
  • Just realised the value of the quote "A picture is worth thousand words" - After staring at the answer and Xcode back to back for 30 mins. :( – Vigneshwaran Murugesan Nov 20 '19 at 14:17
13
  1. Select your project in the navigator on left.
  2. Open up the drawer in the middle pane and select your target.
  3. Select Build Phases
  4. Target Dependencies is an option at that point.
theprojectabot
  • 1,163
  • 12
  • 19
13

Tough one for a newbie like me - here is a screenshot that describes it.
Xcode 10.2.1

enter image description here

chenop
  • 4,743
  • 4
  • 41
  • 65
  • Nice, same for `Xcode 12`!! just drag your `*.xcodeproj` file, deselect copy option, and add it as dependency with `+` button (which can be found with steps the screen-shot shows). – Top-Master May 17 '21 at 15:23
4

Under TARGETS in your project, right-click on your project target (should be the same name as your project) and choose GET INFO, then on GENERAL tab you will see DIRECT DEPENDENCIES, simply click the [+] and select SoundCloudAPI.

WrightsCS
  • 50,551
  • 22
  • 134
  • 186
3

Just close the Project you want to add , then drag and drop the file .

Alok
  • 266
  • 2
  • 11
3

Xcode add a project as a dependency

Xcode 10

  1. drag-n-drop a project into another project - is called cross-project references[About]
  2. add the added project as a build dependency - is called Explicit dependency[About]
//Xcode 10
Build Phases -> Target Dependencies -> + Add items 

//Xcode 11
Build Phases -> Dependencies -> + Add items 

In Choose items to add: dialog you will see only targets from your project and the sub-project

enter image description here

yoAlex5
  • 29,217
  • 8
  • 193
  • 205
  • 2
    Cannot find Build Phases -> Target Dependencies but instead i can see Build Phases -> Dependencies in xcode 11.3 – krithi k Apr 01 '20 at 10:21
0

Today I faced with the same problem. As the result of the first run I got next error:

Lexical or Preprocessor Issue: 'SDKProjectName*/*SDKProjectName.h' file not found.

But before running, I, obviously, added my SDK into the demo project, just drag&drop .xcodeproj file into my test project's source tree. After that, I moved into Build Phases tab in setting of the main xcodeproj file (of the demo) and added my SDK as target dependency and embed framework into corresponding tabs.

But at the result, I got an error above!

So, the problem was into empty line on the Header Search Paths option. I just wrote "../**" as value for this key and project compiled successfully. So, after that, you can add #include <SDKName/SDKName.h> into any project, which includes this SDK.

ps. My test app was created into root SDK folder.

hamsternik
  • 1,376
  • 3
  • 18
  • 26