How can I "add existing frameworks" in Xcode 4?
Asked Answered
F

10

1477

I can't find the good old "Add existing frameworks" option. How do I do this?

We're talking about Xcode 4 DP2 (in the context of iPhone development, as far as it matters...).

Freeway answered 28/7, 2010 at 12:12 Comment(3)
I would like to point out that if you can't find "Link Binaries With Libraries" in your build phases tab click the "Add build phase" button in the lower right corner.Abydos
I can't believe that: a. there's a (integrated, none the less) IDE+SDK out there in 2012 that still doesn't make clear how to add one of the bundled frameworks to a project. b. such a (normally) trivial subject got so much attention. c. the solution in so convoluted.Christchurch
I kept right-clicking the Frameworks folder in my project figuring there should be a contextual menu item there for this; there isn't, and xcode, somewhat like the over-extended iTunes app, is often not consistent, logical or intuitive. Sadly, with my xCode version (4.4), using help menu search crashed the app just as the relevant help page came up. I'm one update behind the latest xCode release, but switching horses with an overdue deadline seems like a bad idea (even though I hope they fixed the "help" crashing in the update)Sculpt
M
1752

As per Apple's documentation:

  1. In the project navigator, select your project.
  2. Select your target.
  3. Select the "Build Phases" tab.
  4. Open "Link Binaries With Libraries" expander.
  5. Click the + button.
  6. Select your framework.
  7. (optional) Drag and drop the added framework to the "Frameworks" group.
Magnificat answered 28/7, 2010 at 12:12 Comment(19)
For me at least, if you move the framework into any of the groups after this, it stops working.Biphenyl
I just tried this with the latest build and didn't have any issues with moving the framework to the Frameworks group after it was added to the build.Hazardous
They have made this so dumb... I think I kinda miss the old XCode... So many chnages... even some shortcuts dont work :PColossian
If i have 2 targets, then i have to add 2 times?Production
@vivianaranha, me too missing the old Xcode... xcode 4 crashes most of the time for me..Shotputter
Compare "right click, add, existing framework" to the above and yeah, no wonder people miss old Xcode. Why're they complicating stuff? baffled (+1 for answer, not that you need it with 131 +'es already but hey! :P)Passible
Same, lots of crashes. I really like most of the new stuff they added, as it makes stuff a lot clearer. It just needs some heavy development... let's hope the next version will be great ;)Truly
The learning curve from xCode 3 to 4 is high. Hard not to swear at the Apple engineering team when our projects are over due. Thank you for helping relieve this stress.Monorail
@Cyber, adding a target dependency should ask for recursive option. At the first time it asked me for recursive option in a project. Then I have created a new project and tried it there, but its not asking! Even if I remove the dependency from the first project(where recursive option was asked), and try to add again, its not asking for recursive option!! whats wrong here? I am using xcode4. thanks.Mcgaw
If you move the framework into any of the groups after this, it may turn red, but just leave and go back to the view and it went back to green for me.Jokjakarta
I like xcode 4, I know its gonna take time to switch, but you all will love it when you're used to it, be patient with learning :) CheersCrossroads
I am new to xcode, and just having problem with this, because the tutorial use xcodd 3 (I think). +1 for the stepsSagittate
this is crap - just like the debugging in xcode 4. +1 for your info, very helpfulStylet
What if i have multiple targets in my project and I want to add a framework to all these targets at once?Rozele
Well done Apple instead of making it easy with a simple CNTRL-click on Frameworks, you've added a colorful array of unnecessary steps.Chiromancy
this places the framework as the first thing under your project, not in your Frameworks folder. if you try to drag it into your Frameworks folder, it will only allow it to be inserted at the top, not in the middle or the bottom. why?Sublunary
If you need to add the same framework to multiple targets, add for the first one and then drag the framework from the navigator tree into 'Link Binary With Libraries' build phase for the other targets.Esquire
When i drag'n'drop framework in Frameworks folder (7 step) its missing from 'Link Binaries With Libraries' expander :) Epic xcode 4.2 fail! To fix that u must again drag'n'drop it from Frameworks to 'Link Binaries With Libraries' expander areaUnderstudy
For step 7: Do not worry if framework's name turns red in the 'Link Binary With Libraries' section after you move it - this is only temporary. In my case, quit and enter XCode will show it correctly. I have to say 'I HATE it!'Bering
S
44

I just added the existing framework folder manually into the project navigator. It worked for me.

Siana answered 28/7, 2010 at 15:5 Comment(1)
Ok, I finally did it, as follows: 1) In the "project navigator", open the "frameworks" folder and select one the existing frameworks (e.g. UIKit.framework) 2) Right click and select "Show in Finder" from the menu 3) From the newly opened folder in the finder, drag the framework folder you are interested in (e.g. OpenGLES.framework) into the "frameworks" folder in XCode 4) Be sure not to "copy items into destination's group folder" 5) Choosing "Create groups for any added folders" seems to make itFreeway
C
22

Follow the below five steps to add a framework in your project.

  1. Click on Project Navigator.
  2. Select Targets (Black arrow in the below image).
  3. Select Build phases ( Blue arrow in the below image).
  4. Click on the + button (Green arrow in below image).
  5. Select your framework from the list.

Framework

Here is the official Apple page.

Condor answered 5/9, 2013 at 10:55 Comment(0)
T
17

Another easy way to do it so that it is referenced in the project folder you want, like "Frameworks", is to:

  1. Select "Show the Project navigator"
  2. Right-click on the project folder you wish to add the framework to.
  3. Select 'Add Files to "YourProjectName"'
  4. Browse to the framework - generally under /Developer/SDKs/MacOSXversion.sdk/System/Library/Frameworks
  5. Select the one you want.
  6. Select "Add"

It will appear in both the project navigator where you want it, as well as in the "Link Binary With Libraries" area of the "Build Phases" pane of your target.

Tarweed answered 29/9, 2011 at 21:30 Comment(0)
B
11

The frameworks directory is as follows in my computer:

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks

Not the directory

/Developer/SDKs/MacOSXversion.sdk/System/Library/Frameworks
Bulbil answered 30/11, 2011 at 4:32 Comment(1)
Right - it depends on what you have installed. Also, the XCode 4.3 release causes them to be installed to a completely new location - under the XCode distribution path. On my two machines, it is: /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/SDKs/MacOSX10.7.sdk/system/Library/FrameworksTarweed
B
8

In Project:

  1. Select the project navigator
  2. Click on Build Phases
  3. Click on link binary with libraries
  4. Click on the + button and add your Frameworks
Barometry answered 18/10, 2012 at 11:46 Comment(0)
D
7

Follow the screenshots:

Go to linked framework and libraries

Enter image description here

You are ready to go!

Denysedenzil answered 29/7, 2014 at 10:43 Comment(0)
R
3
  1. In the project navigator, select your project.

  2. Select your target.

  3. Select the "Build Phases" tab.

  4. expander. Click the + button.

  5. Select your framework.

  6. (optional) Drag and drop the added framework to the "Frameworks" group.

    enter image description here

Receiptor answered 24/4, 2015 at 12:17 Comment(0)
T
3

Xcode 12

Just drag it into the Frameworks, Libraries, and Embedded Content of the General section of the Target:

enter image description here Done!

Note that Xcode 11 and 10 have a very similar flow too.

Toft answered 18/8, 2020 at 20:17 Comment(0)
S
1

Xcode add a framework

Starting Xcode v11 you should use

<Project settings> -> <App Target> -> Frameworks, Libraries, and Embedded Content
//or
<Project settings> -> <Framework Target> -> Frameworks and Libraries

[Xcode pre-v11. Embedded Binaries vs Linked Frameworks and Libraries]

[Xcode v11. Frameworks, Libraries, and Embedded Content plus Frameworks and Libraries with Embed vs Do Not Embed]

Also do not forget to check Library Search Paths or Framework Search Paths. I would recommend you to use drag-and-drop[About]

[Step-by-step examples here]

Suicide answered 8/5, 2021 at 11:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.