Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode won't add "Embedded binary" after deleting "DerivedData"

Alternative titles to aid search:

  • Adding Embedded Binaries fails in Xcode
  • Xcode won't link framework from separate project
  • App crashes on device because of missing framework, works in simulator

Overview

After deleting the "DerivedData" folder (or performing a "Product > Clean") in xcode6, I cannot add CocoaTouch frameworks from another project to the "Embedded Binary" section (under General tab).

Or, Xcode hits a linker error because it cannot find a framework that if previously could.

Other symptoms

Clicking on the + under "Embedded Binaries" shows the Framework selector but selecting a framework in different project in the workspace does nothing.

like image 643
Richard Stelling Avatar asked Jan 05 '15 15:01

Richard Stelling


2 Answers

When you add the framework to the Embedded Binaries, there will be a reference added to your project for it. If you select that reference after your steps above, you will probably find that it has an Absolute Path reference to the framework rather than a relative one, which we'd like. Change the location to Relative to Build Products and the reference should always be discoverable if do a "hard" clean or use another computer etc.

I have made a video which describes how best to add a built framework from one project to an app target in another sibling project.

like image 141
Daniel Tull Avatar answered Sep 23 '22 08:09

Daniel Tull


This it the only way i have discovered to restore the embedded binaries, please leave comments if you find some steps are not required.

Prerequisites: Read Daniel Tull's answer.

  1. Remove all framework projects from the workspace
  2. Perform a "clean build" and/or remove the "DerivedData"
  3. Add project back into the workspace
  4. Build the project (possibly optional)
  5. In the General tab of the app target click the + under "Linked Frameworks and Libraries", select the framework.
  6. Build and run in the Simulator (there should be no issues building or running)
  7. Build and run for device (this might cause a crash due to the framework not being correctly linked, ignore this crash)
  8. Click the + under "Embedded Binaries", select the framework. This should add it to the project (possible duplicate under "Linked Frameworks and Libraries")
  9. Repeat for all required frameworks
  10. Once building and running (on device) is confirmed you can remove any duplicate (and/or red) frameworks in the Project Navigator or target General tab
like image 32
Richard Stelling Avatar answered Sep 23 '22 08:09

Richard Stelling