Xcode 4.2 how include one project into another one?

IosVersion Controlxcode4.2

Ios Problem Overview


I keep searching, but cannot find a clear and simple explanation on how to include one XCode project, along with all of it's sub-classes into another project. I routinely see stuff like that in sample projects that I download off the web, but do not know how to do this myself.

Within XCode, along with .h and .m files, and folders, there's a whole new project, starting with a blue xcode project icon, that is expandable to contain everything within the project.

Please, can someone explain to me step by step what do I need to do to add one XCode project into another one? I've seen a ton of one liners like "header search paths", but that does not tell me much.

UPDATE: After re-reading the documentation, I realized that the project to include must be dragged ONTO the BLUE project icon of the parent project. Regular sources can be dragged anywhere, but a project must be dragged onto a project.

Thank you!

Ios Solutions


Solution 1 - Ios

This makes a lot of sense when you are trying to add a static library to your xcode projects. There are a couple steps required for doing this. First, make sure that the static library project is not open in XCode.

Then start by dragging and dropping the static library xcodeproj file (from the Finder) onto your app's xcode project. StaticLib

After this you need to add this library to your app's build phases. Click on the main project, and select the BuildPhases tab of the target.

Build Phases

You're going to want to add the other project to the Target Dependencies and to your Link Binary With Libraries Section.

Finally, the app needs to be aware of your headers. Therefore, you need to add the path to your static libraries classes to your User Header Search Paths. Go to the Build Settings of the Main Target and search for Header Search Path.

Header Search Path

This will make your app aware of the new static library.

Sometimes you need to add a few Other Linker Flags. In the Build Settings search for Other Linker Flags and add -all_load and -ObjC

Other Linker Flags

Hope this helps, I know the first time I tried to do this I was banging my head against the wall for a while.

Solution 2 - Ios

Make sure the project you want to add as subproject it's not open, before you add it or drop it.

Solution 3 - Ios

You can just drag-and-drop any xcode-project file (*.xcodeproj) into the project navigation pane of your desired parent-project.

You then may need to add target dependencies, depending on your needs.

Is that what you mean?

Solution 4 - Ios

Make sure to choose "create groups" instead of "create folder references". If your folder is blue instead of yellow, then you have a folder reference. The folder should be yellow.

Solution 5 - Ios

drag and drop xcode file to another xcode file from finder. It will ask you for copy the file then check the check box and it will copy to your project.

Solution 6 - Ios

You have two variants to add source code into your project:

  1. Explicit dependency[About] via creating target dependency with a cross-project reference[About]
  2. Implicit dependency[About] if the source code is a part of the same Workspace[About]

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlex StoneView Question on Stackoverflow
Solution 1 - IosMobileOverlordView Answer on Stackoverflow
Solution 2 - IosJP IllanesView Answer on Stackoverflow
Solution 3 - IosJiaYowView Answer on Stackoverflow
Solution 4 - IosSandy D.View Answer on Stackoverflow
Solution 5 - IosSnehal TanawadeView Answer on Stackoverflow
Solution 6 - IosyoAlex5View Answer on Stackoverflow