How to recreate a deleted target?
Asked Answered
J

3

3

I have deleted my application target and now all my Build option are gone. I cannot run my project because I am missing a target. How can I regenerate it?

Jorrie answered 4/6, 2011 at 13:29 Comment(3)
Do you have a version control system like SVN, Mercurial, Git ? If so, just revert to a revision where the project is still intact. If not, now you know why you should use one, even for small private projects :-)Pacian
Your question was very hard to understand. Please take care to write more clearly.Swound
maybe expand your project tree to show your targets / products and drop down the build menu, then take a screenshot.Richela
S
6

You have two options.

The first is DarkDust's suggestion: restore from a backup or an SCM repository if you have them. If you have neither, you must admit you were begging for trouble.

The second is unfortunate but comes with a message of hope. Recreate the target from scratch. Select File > New > New Target from the main menu and select the appropriate target type (a Cocoa Mac OS X application, doc-based, or whatever). With the new target selected, click the Build Phases tab, expand the Compile Sources phase, and drag all your implementation files - .m (and .c and .mm if you have them) - into the list so they're compiled as part of this target. Expand the Link Binary with Libraries phase and add in any frameworks you use. Expand the Copy Bundle Resources phase and drag in your resources (including xibs, credits, InfoPlist.strings, your app icon, etc.). Don't forget to recreate any Copy Files build phases you might have set up manually (if you did, you'll already know how). That should do it. The message of hope I mentioned is that you're now familiar with what a target is and all it needs to build your product. It's actually a lot simpler than it appears.

Swound answered 4/6, 2011 at 15:22 Comment(0)
S
2

If restoring from a backup or a repository is not an option, and your bundle has many resources, I'd recommend starting a new XCode project from scratch and importing the source files and resources into it.

  1. Create a new Xcode project of the same type and info as your project.
  2. Delete this new project's ViewController and AppDelegate source files, copy your source files into the new project's folder, then import them into the Xcode project.
  3. Add any frameworks you've used.
  4. Import the resources (images, sounds, plists, etc) into the project.

It might take longer than recreating a target and adding things to it, but you're less likely to make mistakes along the way, and you'll ensure that everything is properly added to the target.

Strobilaceous answered 19/3, 2012 at 14:14 Comment(0)
T
0

If you have version control then the following method works. I used another method to revert my changes if there are not much, executing "Git checkout ." on terminal. Changes will be reverted and Your target will be restored.

Twitter answered 28/7, 2022 at 11:25 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Basra

© 2022 - 2024 — McMap. All rights reserved.