Stefan Kendall
Stefan Kendall

Reputation: 67892

Use an entire app as a dependency?

Without going into the why, I need to use an entire app for various classes and libraries it has and includes.

Is there a way I can use the entire project as a dependency? When I choose "static library target" I lose all the hundreds of classes in the "compile" step. Effectively I would like to be able to package the project such that I can use it elsewhere.

Is there an easy way to do this aside from building my new app out of the old app and changing the app name/launch targets?

Upvotes: 2

Views: 101

Answers (3)

Stefan Kendall
Stefan Kendall

Reputation: 67892

The easiest and safest way to do this is to copy the whole workspace and change the initial view controller.

Upvotes: 0

michal.ciurus
michal.ciurus

Reputation: 3664

You have to find a way to transport every element into the new XCode project. iOS app consists of:

  • main.m file - You probably won't need to copy that, as it's usually just one line.
  • Source files and headers for: appDelegate, ViewControllers etc. - I don't understand why you would "lose all the hundreds of classes" during compile time. You're the one that chooses what is to be included in the static library. Add all the header files you need to "Copy headers" in the static library target "Build Phases". Add all the source files into "Compile sources". There are many tutorials and StackOverflow posts on how to do that. (example: How can I create static library and can add just .a file on any project in ios)

    enter image description here

  • Storyboards, xib files, *.plist files, images and other resources - you need to put these in a *.bundle file . Just create a new target (which is a bundle) and include all the needed resources in it. Then you'll have to find a way to use them in the new XCode project. For example setting the default *-info.plist or *.pch file: How to tell Xcode where my info.plist and .pch files are or setting the main storyboard.

So you end up with two files: one framework/static library and one bundle file. It shouldn't be that hard to configure new XCode project to use resources from the bundle and classes from the static library.

Upvotes: 2

Mert Buran
Mert Buran

Reputation: 3017

I'm not sure if I understood your question. You can add your old app as a project to your workspace and add it as a "target dependency" to use it.

Upvotes: 1

Related Questions