RestKit and Xcode 4 - Embracing Workspaces makes things simple

530 views
Skip to first unread message

Chad Podoski

unread,
Mar 21, 2011, 5:32:53 PM3/21/11
to RestKit
Seems there are a couple other threads on here about RestKit and Xcode
4 but I ran into some different issues and wanted to share how I went
about getting things building. I have chosen to go the workspace
route with Xcode 4 and overall it makes things pretty simple. There
are a few gotchas though.

Here is my setup:

Project Workspace
---> My App
---> RestKit (twotoasters, 0.9)
---> Three20 (twotoasters, master)

Once you have the three projects in the workspace, you can just go
into the 'Link Binary with Libraries' build phase of your app target
and pull in the required libraries from RestKit and Three20. This
results in the libraries being built/linked, and hence all the classes
enclosed in the include libraries to be built in the common Derived
Data Products directory. I ran into the follow two problems:

1) Since RestKit.h is actually not included in any of the libraries,
it is not compiled/copied into the mentioned build dir. I added a new
copy files phase to the RestKitObjectMapping target to copy RestKit.h
into the build dir (New Copy Files Phase, Products Directory, Subpath:
include/RestKit, File: RestKit.h) Note: It seems like you should be
able to use Target Dependencies to solve this issue (app project
depends on RestKit target of RestKit project, but for some reason
Xcode 4 does not allow you to add the dependency or any dependency for
that matter)?
2) The new JSONKit seems to have chosen a new 'Public Headers Folder
Path' in its build settings, I changed this back to match the approach
of the rest of the targets (include/RestKit/Support/JSON/JSONKit).

Finally, I included the following imports in my main project:

#import <Three20/Three20.h>
#import <RestKit/RestKit.h>
#import <RestKit/CoreData/CoreData.h>
#import <RestKit/Support/JSON/JSONKit/JSONKit.h>
#import <RestKit/Three20/Three20.h>

That is it, project is building great. Now if Apple would just
release an Xcode 4 that actually indexes properly so code completion/
highlighting would work, I would be a happy camper.

Hope it helps,
Chad Podoski
Shacked Software
getshacked.com

David Hopkinson

unread,
Mar 21, 2011, 6:58:40 PM3/21/11
to RestKit
I don't suppose you could do a screen grab vid and post it somewhere?
I am trying this and still getting xcode crashes when trying to add
the Restkit.h copy file phase. I must be doing something wrong.

I have managed to get this working via the 'other' routes finally
(though I am not quite sure why it is working as it doesn't look like
the libraries have compiled but everything works!!) but this seems a
more elegant route to take.

Thanks

David

Chad Podoski

unread,
Mar 21, 2011, 8:01:39 PM3/21/11
to RestKit
David,

Let me know what the errors are and I can try to help you through it.
What do you mean by 'other' route? I see the same thing with the
libraries, they never look like they are built (still red in Xcode
project hierarchy). I hesitate to put up some type of how-to video
yet as I want the two toasters guys to weigh in first. Ultimately
whatever method they settle on will probably be the easiest for us
since the RestKit project will already be configured accordingly.

Thanks,
Chad


On Mar 21, 12:58 pm, David Hopkinson <david.hopkin...@gmail.com>
wrote:

Blake Watters

unread,
Mar 21, 2011, 8:27:45 PM3/21/11
to res...@googlegroups.com, Chad Podoski
Chad -

Thanks for the catch on JSONKit, I have aligned its directory to match the others.

If you build against the RestKit aggregate target, it contains a copy files build phase that will copy the RestKit.h headers into the proper place. This target builds everything except for Three20 and should be the only dependency you need to add. Then you can just cherry pick the libraries you want to link.
Blake Watters
Two Toasters | CTO

Andrew Newdel

unread,
Mar 21, 2011, 9:24:53 PM3/21/11
to res...@googlegroups.com
I'm also using the workspace approach. To solve the missing RestKit.h
issue, and since Xcode 4 doesn't like target dependencies, I edited
the Build step of my project's scheme:

1. Choose 'Edit Scheme' from the scheme pulldown menu.
2. Select the 'Build' step in the left pane.
3. Click the '+' in the lower left of the the right pane.
4. Add the RestKit aggregate target. I also dragged the RestKit target
to be first in the list and deselected the 'Parallelize Build'
checkbox.

It's working, but I also have the missing code completion issue.
(Sometimes, RestKit's libraries and my app bundle are shown in red
under their respective 'Products' group in the project navigator -
like they are not being built. But they are being built in the Derived
Data location - just can't use 'Show in Finder' to get their quickly.)


On Mon, Mar 21, 2011 at 5:32 PM, Chad Podoski <ch...@getshacked.com> wrote:

Chad Podoski

unread,
Mar 21, 2011, 9:46:46 PM3/21/11
to RestKit
Andrew - Thanks for the explanation, I had forgotten about the Scheme
settings. That works great, now I don't have to modify the RestKit
proj at all. Makes having it as a git submodule much cleaner.

Blake - Thanks for clearing up the JSONKit path, as well as the
RKManagedObjectLoader issue from earlier.

Thanks,
Chad

David Hopkinson

unread,
Mar 22, 2011, 5:58:05 AM3/22/11
to RestKit
This works perfectly (once I remembered to add in the linker flags -
ObjC -load_all doh! - problem with starting over and over again)

Many thanks

Working beautifully now.

David

Blake Watters

unread,
Mar 22, 2011, 8:15:32 AM3/22/11
to res...@googlegroups.com, David Hopkinson
Have you guys tried doing a Distribution build yet? A short-coming I have just realized with the current setup (where no include paths are directly specified) is that if you build a configuration in your app that is not named "Debug" or "Release", the header imports will fail because Xcode will build the Release target, will look under the Distribution/include path for the headers.

I really don't understand why Apple doesn't make building Frameworks simple and recommended on iOS projects -- they make this process dead simple.

David Hopkinson

unread,
Mar 22, 2011, 8:46:39 AM3/22/11
to RestKit
Nope not tried yet. I did have a similar issue when using the Three20
library. What I ended up doing for that was going into each of the
library projects and adding in the Distribution build (copied the
Release build). That resolved the build issues. Was a bit of a pain
but a quick fix. Perhaps this will work in this situation?

David

On Mar 22, 12:15 pm, Blake Watters <bl...@twotoasters.com> wrote:
> Have you guys tried doing a Distribution build yet? A short-coming I have
> just realized with the current setup (where no include paths are directly
> specified) is that if you build a configuration in your app that is not
> named "Debug" or "Release", the header imports will fail because Xcode will
> build the Release target, will look under the Distribution/include path for
> the headers.
>
> I really don't understand why Apple doesn't make building Frameworks simple
> and recommended on iOS projects -- they make this process dead simple.
>
> On Tue, Mar 22, 2011 at 5:58 AM, David Hopkinson
> <david.hopkin...@gmail.com>wrote:
>  *Blake Watters*

Gregory Combs

unread,
Mar 22, 2011, 9:00:32 AM3/22/11
to res...@googlegroups.com, David Hopkinson
I'm wondering if all the difficulties you guys are experiencing are only when you start a RestKit project from the beginning in Xcode 4.  I'm still on Xcode 3, so when I go to 4, I'd just open my old project.  Will it build out of the box? (Assuming I don't have anything particularly wonky here).  Or is there significant configuration after the fact, even if you're starting with a Xcode 3 project that already has RestKit included.

David Steinberger

unread,
Mar 22, 2011, 9:40:01 AM3/22/11
to res...@googlegroups.com
I think there are multiple ways to get it somehow to build. I haven't understood each of them fully :(.
My biggest problem right now is that even if it builds fine, archiving and signing fails.

Anyone experiencing the same behaviour?

2011/3/22 Gregory Combs <gco...@gmail.com>

David Hopkinson

unread,
Mar 22, 2011, 11:25:15 AM3/22/11
to RestKit
Yep - just tested now. Archive fails to find restkit headers.

David

On Mar 22, 1:40 pm, David Steinberger <mail.steinber...@gmail.com>
wrote:

David Steinberger

unread,
Mar 22, 2011, 11:29:45 AM3/22/11
to res...@googlegroups.com
Same here and with my limited knowledge I cannot figure it out. Grateful for any suggestion.

2011/3/22 David Hopkinson <david.h...@gmail.com>

Blake Watters

unread,
Mar 22, 2011, 2:05:04 PM3/22/11
to res...@googlegroups.com, David Hopkinson
I pushed a Distribution configuration into the project on 0.9 this morning. I believe that will help with the headers not being found (haven't had a chance to try and build a TT project on distribution yet). 

I'm stuck in Rails dev land this week, so I am only getting RK time in the early mornings and evenings. Will pick the archive problem back up tonight.
Blake Watters

dave84

unread,
Mar 22, 2011, 2:51:46 PM3/22/11
to RestKit
Thanks Blake for your efforts on this.

Do you think you could push distribution config & archive support into
unit-testing-branch?

There are tons of things that are soo much enhanced here and I think
we need it there too.

On Mar 22, 7:05 pm, Blake Watters <bl...@twotoasters.com> wrote:
> I pushed a Distribution configuration into the project on 0.9 this morning.
> I believe that will help with the headers not being found (haven't had a
> chance to try and build a TT project on distribution yet).
>
> I'm stuck in Rails dev land this week, so I am only getting RK time in the
> early mornings and evenings. Will pick the archive problem back up tonight.
>
> On Tue, Mar 22, 2011 at 11:25 AM, David Hopkinson <david.hopkin...@gmail.com
>
>
>
>
>
>
>
>
>
> > wrote:
> > Yep - just tested now. Archive fails to find restkit headers.
>
> > David
>
> > On Mar 22, 1:40 pm, David Steinberger <mail.steinber...@gmail.com>
> > wrote:
> > > I think there are multiple ways to get it somehow to build. I haven't
> > > understood each of them fully :(.
> > > My biggest problem right now is that even if it builds fine, archiving
> > and
> > > signing fails.
>
> > > Anyone experiencing the same behaviour?
>
> > > 2011/3/22 Gregory Combs <gco...@gmail.com>
>
> > > > I'm wondering if all the difficulties you guys are experiencing are
> > only
> > > > when you start a RestKit project from the beginning in Xcode 4.  I'm
> > still
> > > > on Xcode 3, so when I go to 4, I'd just open my old project.  Will it
> > build
> > > > out of the box? (Assuming I don't have anything particularly wonky
> > here).
> > > >  Or is there significant configuration after the fact, even if you're
> > > > starting with a Xcode 3 project that already has RestKit included.
>
>  *Blake Watters*

David Hopkinson

unread,
Mar 22, 2011, 5:45:30 PM3/22/11
to RestKit
Yep - noticed that. Thanks Blake.

I am going to try more of the 'standard', sub-project install tonight
to see how I get on. Played with the examples again earlier and it
sort of worked through to archiving. If I get everything working I
will let you know.

As Dave84 says - thanks (too many Daves/Davids in this thread!

Thanks

Bob ;-)

On Mar 22, 6:05 pm, Blake Watters <bl...@twotoasters.com> wrote:
> I pushed a Distribution configuration into the project on 0.9 this morning.
> I believe that will help with the headers not being found (haven't had a
> chance to try and build a TT project on distribution yet).
>
> I'm stuck in Rails dev land this week, so I am only getting RK time in the
> early mornings and evenings. Will pick the archive problem back up tonight.
>
> On Tue, Mar 22, 2011 at 11:25 AM, David Hopkinson <david.hopkin...@gmail.com
>
>
>
>
>
> > wrote:
> > Yep - just tested now. Archive fails to find restkit headers.
>
> > David
>
> > On Mar 22, 1:40 pm, David Steinberger <mail.steinber...@gmail.com>
> > wrote:
> > > I think there are multiple ways to get it somehow to build. I haven't
> > > understood each of them fully :(.
> > > My biggest problem right now is that even if it builds fine, archiving
> > and
> > > signing fails.
>
> > > Anyone experiencing the same behaviour?
>
> > > 2011/3/22 Gregory Combs <gco...@gmail.com>
>
> > > > I'm wondering if all the difficulties you guys are experiencing are
> > only
> > > > when you start a RestKit project from the beginning in Xcode 4.  I'm
> > still
> > > > on Xcode 3, so when I go to 4, I'd just open my old project.  Will it
> > build
> > > > out of the box? (Assuming I don't have anything particularly wonky
> > here).
> > > >  Or is there significant configuration after the fact, even if you're
> > > > starting with a Xcode 3 project that already has RestKit included.
>
>  *Blake Watters*

David Hopkinson

unread,
Mar 23, 2011, 8:48:32 AM3/23/11
to RestKit
I have gone back to the workspace method to try this again. Still
can't get an archive out of the damn thing. Can't find the header
files :-(

David Steinberger

unread,
Mar 23, 2011, 9:47:22 AM3/23/11
to res...@googlegroups.com
Same here; frustrated and lost ;).

2011/3/23 David Hopkinson <david.h...@gmail.com>

David Hopkinson

unread,
Mar 23, 2011, 10:36:32 AM3/23/11
to RestKit
Just done everything in xCode 3 - followed the standard instructions
using the master branch and all just works.
Built and archived and created with no issues at all. The problem is
everything else we are doing has already been migrated to xcode 4.

I love the idea of this library and it looks to be just what I want.
Just wish I could get the damn thing to build.

Think I am going to go back to xcode 3 for now until one of the brainy
people on this site can sort if for me :-)

David

On Mar 23, 1:47 pm, David Steinberger <mail.steinber...@gmail.com>
wrote:
> Same here; frustrated and lost ;).
>
> 2011/3/23 David Hopkinson <david.hopkin...@gmail.com>

dave84

unread,
Mar 23, 2011, 6:21:12 PM3/23/11
to RestKit
I see this becoming the issue #1.

Restkit might be the best library for handling json in objective-c (no
doubt about that).
But some/most of use are forced to switch to Xcode 4 and iOS 4.3 and
apparently we have no clue how to get distribution builds done here.

Blake Watters

unread,
Mar 23, 2011, 9:34:30 PM3/23/11
to res...@googlegroups.com, dave84
Dave -

I am pulling your gallery app sources now and working on the build issues. Putting a bullet in this bullshit is my mission in life ATM.

- Blake
Blake Watters

Blake Watters

unread,
Mar 23, 2011, 10:24:16 PM3/23/11
to res...@googlegroups.com, dave84
Dave -

I was able to get your app building on XCode 4 with both derived data and target build locations without any modifications to RestKit (yay!). I did have to make a couple of changes to your app:
- Removed the Recursive Header Search Path for RestKit
- Upgraded Three20 to 1.0.5 and applied their changes to your project.
- Changed a few header imports that were referring directly to files as though they were part of your project when they were really being imported via Three20 or RestKit.

You can grab the modified project from: https://www.dropbox.com/s/k9jcult46m927k9/g3Mobile.zip

I have again updated the RestKit install instructions to remove the different paths for derived data vs. target builds. Both seem to be working fine now and added a note not to check the recursive search box. That Recursive search path seemed to be your biggest issue.

- Blake

Blake Watters

unread,
Mar 23, 2011, 10:32:02 PM3/23/11
to res...@googlegroups.com, David Hopkinson
David (Hopkinson!) -

Pull latest 0.9 and add a Header search path to your project/target for whever/you/have/RestKit/Build and try your build and archive. See if that works out for you.

- Blake
Blake Watters

David Steinberger

unread,
Mar 24, 2011, 5:54:02 AM3/24/11
to res...@googlegroups.com
Thanks Blake!!!

Yes, you are right. I require e.g. Three20 but I haven't pushed them because I was stuck on the archive issue.

Should those instructions also work on the unit-testing branch? I'm relying on RKRequestTTModel and this is way behind on 0.9.
Can I also create a signed archive with those instructions? So far I got the same error described here: http://groups.google.com/group/restkit/browse_thread/thread/6d9075f1440ecbe7

Again Blake, thanks so much for all your help!

2011/3/24 Blake Watters <bl...@twotoasters.com>

Blake Watters

unread,
Mar 24, 2011, 7:29:57 AM3/24/11
to res...@googlegroups.com, David Steinberger
I have merged 0.9 into the unit-testing branch. I am going to get this branch collapsed into 0.9 today. I really want to ship an 0.9.1 with Xcode 4 fixes by this weekend.
Reply all
Reply to author
Forward
0 new messages