How to import JSON framework? - cocoa

I've downloaded the JSON framework DMG from http://code.google.com/p/json-framework/downloads/list. I followed Option 3 here: http://code.google.com/p/json-framework/wiki/InstallationInstructions. For the copy files build phase, I set path to ~/Library/Frameworks/JSON.framework. Buid failed. I then tried setting it to my project root. Build failed.
I keep getting this error:
<JSON/JSON.h>: No such file or directory
Any suggestions?

There's no need to put the framework in Library, at least under Xcode 3.1.3. Here's what you do:
Put the JSON framework source tree in your source tree.
Add the framework project to your project.
Get Info on your target, click + under the Direct Dependencies list, and choose the framework target from the framework project.
Right-click on your target in the group tree and choose “New Build Phase▶ Copy Files”. In the window that results, choose Frameworks as the destination.
Add the framework target (which will transmogrify into its build product) to the Copy Files phase.
Add the framework target (which will transmogrify) to your target's Link with Libraries phase.

Related

Xcode Framework Search Paths not finding frameworks outside project directory

In a large monorepo of Cocoapod projects I have the following directory structure.
Project
Common
Foo.Framework
First Project
Project.Xcode
Second Project
Project.Xcode
The goal is that there are multiple Cocoapod projects and rather than have the same framework copied in multiple places within the First and Second project, I'd rather have it once in a Common folder in the parent directory, and then drag it into the project and set the framework search paths.
So I'm running into an issue where the linker cannot find the Foo.framework.
What should I set the framework search path to so that it correctly finds the framework.
If I include the framework inside the Project directories it doesn't run into any issues.
I had the same issue and solved it like following:
Go to Build Settings
Find the "Framework Search Paths"
Add $(PROJECT_DIR)/../your_directory
Use the recursive flag if the framework file isn't in the exact directory you selected)

How to run a specific project when you have multiple projects in xcode?

If you have a xcode project like restkit that has the core code for restkit + examples that have their own project, how do you run a specific project?
https://github.com/RestKit/RestKit/
If you look at the /Example's folder, you will see they have a few of them and each have their own project file.
You can use multiple targate in xcode.
A target specifies a product to build and contains the instructions
for building the product from a set of files in a project or
workspace. A target defines a single product; it organizes the inputs
into the build system—the source files and instructions for processing
those source files—required to build that product. Projects can
contain one or more targets, each of which produces one product.

xcode target dependencies between two projects

I have a problem with setting dependencies in XCode 4 between separate projects. Currently, I have two projects in the same workspace. The first project have a Framework amongst it's products. I would like to use this framework in the second project, as a dependency for Bundle target.
First project build successfully. However, the second one claims that it cannot access headers from the framework, although it exists in there. I added the framework to Build Phases -> Link Binary With Libraries section of my target, but this does not help. I was looking for an answer, but all I found were suggestions to add library on the Summary page. Unfortunately, in opposite to Application targets, Bundle target does not have this pane. Is there any other place where should I add the framework?
This answer describes the current procedure for adding a library dependency, including headers: https://stackoverflow.com/a/9726445/382938

Target dependencies vs. Link binary with libraries

I don't understand the difference between these Xcode features.
I'm building and app - but the functionality of the app is being abstracted into libraries (so they can be distributed separately as an "SDK").
So I have a workspace of library projects and the app project. I can add library projects to the app project by doing "link binary with libraries". This gives me a list of .a library projects in the current workspace which I can link to.
I can also add frameworks here.
In the "target dependencies" bit all I can add is other targets in the current project.
What I really want to do is both - I want my app project to build all the other library projects when I build it. I also want to make it verbose what libraries the app (and other libraries) depend on.
So can somebody please explain the difference, and whether what I am doing is the right way to go about it?
Many thanks!
It says here...
Drag your framework product (located in the Products folder) to the existing Link Binary With Libraries build phase of your application
target. This causes the application to link against your framework.
And...
In the General tab of the inspector window, add your framework as a dependency for the application. Adding this dependency causes Xcode to
build the framework target before building the application target.
The build dependency you establish in the application target causes
the framework to be built before the application. This is important
because it guarantees that a built version of your framework will be
available to link against and to embed in the application. Because of
this dependency, you can set the active target of your Xcode project
to your application and leave it there.
So it seems that you're supposed to use both. Seems redundant though, because if you're linking to a framework then its a dependency. I suppose you might want to only link to a library and not build it first. Although Xcode seems to build linked libraries even without them being added to the dependency section. Perhaps that's a result of the "Find Implicit Dependencies" option in a scheme's build settings.
I do something similar and was explicitly setting the 'header search path' and 'library search path' in the final executable target. However this all depended on where the objects were being generated. Initially I had set this to be within the source tree (actually a sibling directory called build), however after changing the location of the Xcode DerivedData directory and telling it to build into that directory, the projects no longer built.
The final solution was simply to remove the explicit setting of the 'header/library search path' and set the target dependencies correctly. This resulted in the project building for debugging and archiving without issue.

Target Dependency between two projects in the same workspace

I'm using Xcode 4.3 to create a framework for OS X. I created a workspace and a project (with a framework target) to go in this workspace.
Now, I want to include & link with a third-party framework which I've also added to the same workspace (but not within my project). I clicked the + button in the "Link Binary With Libraries" build phase, and the third-party framework simply appeared in the list of available libraries.
The linked framework shows up red in the Project navigator, as the third-party library has not been built yet (confusingly, though, my project successfully builds — although I'm not yet trying to use the third-party framework):
I was going to solve this by adding it as a Target Dependency, but when I click + on the "Target Dependencies" build phase, the third-party target doesn't show up in the list.
How should I properly configure/resolve this dependency? Also, do I need to create a Copy Files build phase to ensure the framework is copied into my target's Frameworks directory? How would I set that up properly?
I ran into something similar but with static libs.
Do what you did to build the framework, build your app (even if it fails, the framework should build)
Remove the reference to the framework in your app target's link build phase
Locate the built framework in the Finder (the one built by your app workspace).
drag/drop it into the app project that uses it. Notice that this time it appears with black color (not red)
click it, and make sure the Xcode inspector shows "relative to built products" (you may need to change it reference type), and that the path is just the myframework.framework.
check that it has been added to the app link phase (it should)
that's the one you can use in the copy/build phase.

Resources