2

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?

Stefan Kendall
  • 61,898
  • 63
  • 233
  • 391

3 Answers3

2

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.

Community
  • 1
  • 1
michal.ciurus
  • 3,482
  • 14
  • 30
  • I mean there are hundreds of classes across different groups that I would need to manually add. Basically the entire object graph is interdependent. ...I didn't do it. – Stefan Kendall Mar 06 '15 at 12:17
  • Can't you just use a file explorer, use a search option and search for all *.h files and drag&drop them to XCode ? And then do the same with *.m ? That should work fine. – michal.ciurus Mar 06 '15 at 12:52
  • Over 1000 files, actually. I don't trust a by hand operation here. – Stefan Kendall Mar 06 '15 at 13:51
  • I dont see any problem with that. If you define a good search function it will return all relevant files. If you dont want to do it manually you have to edit the project file manually using some script in bash/python/whatever which will be tiresome, because the project file is.. well.. in a specific format. – michal.ciurus Mar 06 '15 at 13:53
1

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.

Mert Buran
  • 2,828
  • 2
  • 18
  • 32
  • The app has several projects as dependencies itself and is only runnable as a workspace. Can I have a workspace dependency? – Stefan Kendall Mar 06 '15 at 12:17
0

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

Stefan Kendall
  • 61,898
  • 63
  • 233
  • 391