48

I "pod update", and my RestKit version now is 0.25.0, my RKValueTransformers is 1.1.2, and an error appeared "RKObjectMapping.h" not found.

What did RestKit change in the new version, that I check on the its github cannot find anything.

The following steps can reproduce the error:

1) Create a new project

2) pod init

Podfile looks like:

platform :ios, '8.3'
#pod 'RestKit', '~> 0.20.0'
#pod 'RestKit', '~> 0.24.1'
pod 'RestKit'

In all cases of different versions, the issue is the same

3) open .xcworkspace

4) in the viewcontroller.m

#import <RestKit/ObjectMapping/RKObjectMapping.h>
#import <RestKit/ObjectMapping/RKRelationshipMapping.h>
#import <RestKit/Network/RKResponseDescriptor.h>
#import <RestKit/Network/RKObjectRequestOperation.h>
#import <RestKit/Support/RKLog.h>
#import <RestKit/CoreData/RKEntityMapping.h>
#import <RestKit/Network/RKObjectManager.h>

or

#import "RKObjectMapping.h"
#import "RKRelationshipMapping.h"
#import "RKResponseDescriptor.h"
#import "RKObjectRequestOperation.h"
#import "RKLog.h"
#import "RKEntityMapping.h"
#import "RKObjectManager.h"

The error is still there: "RKObjectMapping.h" not found in a file of RestKit Pod

Note: I am using Xcode 7-beta5, Objective-C

Mazyod
  • 22,319
  • 10
  • 92
  • 157
chipbk10
  • 5,783
  • 12
  • 49
  • 85
  • What version did you previously have? What is importing `RKObjectMapping.h`? – Wain Sep 14 '15 at 15:41
  • the previous version is 0.24.1 – chipbk10 Sep 14 '15 at 15:42
  • And it's calling RKObjectMapping.h. The thing is even I downgrade to the previous version 0.24.1, the issue is still there. I create a new project and get RestKit 0.24.1, and call RKObjectMapping.h from viewcontroller.m, the issue is the same. – chipbk10 Sep 14 '15 at 15:43
  • Which suggests you have an unrelated problem. Is the pod building correctly? Did everything download correctly? Did you open the workspace? – Wain Sep 14 '15 at 15:52
  • Yes, I am not new to pod. I open .xcworkspace. You can reproduce the same error. Let me updated my question. – chipbk10 Sep 14 '15 at 15:55
  • 2
    I have the same issue! With cocoapods 0.38.2 it builds but i cannot submit it to the store and with 0.39.beta.4 it get the same error. – Michel Sep 15 '15 at 09:03

4 Answers4

96

There is easy way to work around this problem when you don't want to touch cocoapods. because fixing them itself a hassle. I have fixed my problem as follows:

Click on your project file
Then go to build settings search for "header search path"
With the drop down just make them recursive.

You Should be looking for following:

${PODS_ROOT}/Headers/Public/AFNetworking
${PODS_ROOT}/Headers/Public/Bolts
${PODS_ROOT}/Headers/Public/ISO8601DateFormatterValueTransformer
${PODS_ROOT}/Headers/Public/RKValueTransformers
${PODS_ROOT}/Headers/Public/RestKit 
${PODS_ROOT}/Headers/Public/SOCKit
${PODS_ROOT}/Headers/Public
Alok C
  • 2,787
  • 3
  • 25
  • 44
  • 5
    I was missing ${PODS_ROOT} itself. Adding this (and making it recursive) fixed the problem for me. You just saved me a lot of work. Thank you! – iHiD Jan 07 '16 at 01:22
  • This is why i love stack community! Happy coding :) – Milan Mendpara Jan 15 '16 at 04:55
  • 2
    If `${PODS_ROOT}/Headers/Public` is made recursive, why also make all the other subdirectories recursive? This fix did work for me, but I only needed to make that top level directory `${PODS_ROOT}/Headers/Public` recursive, not all the others. – Andy Obusek Jul 25 '16 at 17:56
75

After a while struggling, I noticed the error is not from RestKit. It comes from upgrading the latest version of cocoapods (0.39.beta.4).

The Header Search Path is not in recursive mode anymore.

The workaround is just downgrade the version of cocoapods to 0.38.0.

1) remove the latest version of cocoapod

sudo gem uninstall cocoapods

2) install the 0.38.0 version

sudo gem install cocoapods -v 0.38.0

Hope can help someone.

Updated:

Thanks Vig that we can do pod with a specific version:

pod _0.38.0_ update
pod _0.38.0_ install
chipbk10
  • 5,783
  • 12
  • 49
  • 85
  • 12
    On a side note, you don't need to uninstall cocoa pods, you can do pod on a specific version by using pod _ 0.38.0 _ install without space between underscores – Vig Oct 13 '15 at 14:53
  • I have the same issue after I upgrade cocoapods to 0.39.0. And the issue will not appear after downgrade back to cocoapods-0.38.2. – derjohng Oct 19 '15 at 14:23
  • after updating to OX X El Capitan I ran into this issue noticing pods was no longer found and then upgraded by default install of cocoapods. – Nick N Oct 24 '15 at 03:06
  • 2
    Still have this issue with Xcode 7.1, downgrading to 0.38.0 or 0.38.2 does not solve the problem. – John Muchow Oct 26 '15 at 02:22
  • in my case using pods version 0.38.0 was not sufficient. I had to also remove `use_frameworks!` and set the header search paths to recursive. – TomL Nov 10 '15 at 17:38
  • There's an open issue in the restkit project https://github.com/RestKit/RestKit/issues/2288 – pablobart Nov 10 '15 at 19:39
1

This has finally been fixed in the development branch of RestKit with the final patch being in 1d8f3e332, I think.

Hopefully it will be merged into master soon.

For now, if you're feeling brave, you can use

pod 'RestKit', :git => 'git@github.com:RestKit/RestKit.git', :commit => '1d8f3e3325d959094a3f96c832bf9f54c9c48df3'
kball
  • 4,923
  • 3
  • 29
  • 31
  • Unfortunately that does not fix the problem for me: I now get duplicate object declaration warnings. – pr1001 Jan 20 '16 at 16:50
  • My guess is that you have linked RestKit twice somehow. I would try resetting your workspace by deleting it and reinstalling pods or by removing all pods from your podfile, running pod update, then restoring the podfile and running pod install. – kball Jan 20 '16 at 17:16
  • kball's answer is the only one that fixed it for me. You should put it as an answer. Thanks. I used cocoapods 0.38.0 too. – Antenehs Jan 25 '16 at 21:55
  • I'm glad it helped you. Just remember to keep an eye on the repository and revert your Podfile when the commit is merged into a release – kball Jan 26 '16 at 04:42
  • this didn't work for me. Received: " [!] Error installing RestKit [!] Failed to download 'RestKit'." – Bill Noto Sep 30 '17 at 22:48
  • This is a very old issue and so this solution probably isn't relevant anymore. Also it looks like the commit referenced here is no longer available on github. I would look for more recent posts addressing the issue and check on the github repository for any help. – kball Oct 03 '17 at 16:24
-4

I solved this by building pods as frameworks.

use_frameworks!
olejnjak
  • 1,163
  • 1
  • 9
  • 23