2

I have a project that will fork in 4 different apps for internal use on my company.

The main project core is the same. I first thought of creating a big app with 4 targets but I would like to keep the engine apart from the targets in a way that some team can work with just the engine and other programmers can work with each one of the targets.

Someone told me that I can embed a project inside a project and that would be useful if I can embed the engine part that is common to all targets, inside a bigger project where I will have the 4 targets.

Is it possible?

How do I do that? Is there any tutorial out there that explains how to do it?

thanks

asked Mar 16, 2013 at 19:06
1
  • Add as a git submodule or cocoa pod, then drop the project node (xcodeproj file) in your the Project Navigator of your main project, or add individual source files. Commented Mar 16, 2013 at 19:34

2 Answers 2

1

I think the existing answer and the comments mix several things together that should be distinct, hence my answer...

Note that I am purposely leaving out the multiple target-part of your app-project as you seem to have figured that out already. My answer concentrates on the usage of sub-projects that build libraries.

Someone told me that I can embed a project inside a project and that would be useful if I can embed the engine part that is common to all targets, inside a bigger project where I will have the 4 targets.

Correct, subprojects are a nice feature of Xcode. To get that done, you may want first want to create a project that is using the static library template.

enter image description here

Now add all the files that are needed to create your core engine to that new project. I will further refer to this as your engine-library-project.

Once that is done, create a new project that will create your app/s - you may certainly also just use the existing project, but make sure you remove all the engine implementation files from that one (to prevent linker errors).

I now assume that you have two projects created, your engine-library-project and your app-project.

Now comes the combinatory part. First, make sure the engine-library-project is closed and make sure the app-project is opened within Xcode.

Now drag the engine-library-project bundle (.xcodeproj) from your finder directly into the app-project.

enter image description here

Now all you need is to make sure that your app-project is linking against the engine-library. To get that done, you need to tap on the little plus symbol at the bottom of the Link Binary With Libraries tab.

enter image description here

The selection dialog that pops up should list your library as the first option.

enter image description here

Now make sure that all engine-library headers are visible to your app-project by adding them to the Header Search Paths.

enter image description here

If you did everything correctly and if I did not omit an important step (sorry if I did), then your app should now build perfectly fine using a library subproject.

Once all of these steps are properly done, you may also want to look into options for distributing your engine-library to other developers. You may use a git-submodule on the source-project but you may as well use a git-submodule on the resulting library only. That way no other developer would be able to fiddle around with your engine-library, which sometimes (often from my experience) is a good thing.

answered Mar 16, 2013 at 20:44
Sign up to request clarification or add additional context in comments.

2 Comments

wow, that's fantastic. Just one question. Suppose I am on one target outside and I want to access a class inside the engine. How do I do that? Normally I would simply import the header of that class on the one I am working and that's it. But now, with a project inside a project that seems unclear.
Check the last step on adding the Header Search Paths to your app-project. It really remains just as easy as it was before as long as you tell the compiler (via build-settings) that it is supposed to look for those headers at an additional place (which is inside your subproject - drafted as ../../engine/headers)
1

Yes It is possible . I have Created a project with 6 different targets. Well , here you can add the common classes to all the targets , while the classes performing distinct or unique functionalities pertaining to a specific target may be added to the corresponding targets.I don't understand the part where you say that engine should be common(Just add the common classes in all the targets). In iOS , by engine you mean , the AppDelegate class , i suppose.

You will have to add preprocessor directives by giving values into build settings for the Preprocessor flags & Other C flags to recognize the targets for the Engine(AppDelegate) and customize the function correspondingly.

But , it's wise to implement such notions when most of the things are common between each target and requires very little customization for other targets.

answered Mar 16, 2013 at 19:37

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.