23

I have default project template with tests and cocoapods installed (pod install). Pods works fine with main target, but when I try to import something in tests, I get something like

Time.m:11:9: 'NSDate-Utilities.h' file not found

Does this mean that I should add pods directory to header search path in tests target? Can this be done via cocoapods CLI automatically somehow?


That question by suggested link had WRONG answer until yesterday.

Nik
  • 9,063
  • 7
  • 66
  • 81

2 Answers2

57

Ok, there is a simple solution, see answer above to get this working automatically. I had to select Pods/Pods configuration file for tests target in project info.

configuration file settings

Nik
  • 9,063
  • 7
  • 66
  • 81
  • I like this solution better than the other, it doesn't require using `link_with` in the `Podfile`. – Liron Yahdav Apr 20 '14 at 00:39
  • 3
    Thank you, this worked. It took me some time to find this. Here is it in Xcode 6.1: Your Project → Project (blue icon) from the topleft dropdown menu → Info tab → Configurations. – gklka Nov 04 '14 at 14:17
  • 6
    This is a bad idea since it could get overwritten on future `pod install`s – Keith Smiley Nov 05 '14 at 17:16
  • 1
    I found that link_with was not enough - and had to have link_with AND manually set the config as described in this answer – Ben Clayton Feb 24 '15 at 13:39
  • I don't think this is a bad idea. For me, this still works after running `pod install` again. It doesn't delete this setting. Well done :) (using Cocoapods 0.37.2) – Hlung Aug 17 '15 at 16:21
  • @Hlung - I thought the same thing. When I first set Tests it was set to none. After setting it to Project.debug it worked. It also worked after I did `pod install` a few times with no issues. Then out of nowhere I started having problems after adding a new pod. A few hours later I found this post again and after re-reading I checked this setting because of `Keith Smiley` comment and found it had changed to ProjectTest.debug. – pls Jun 29 '16 at 12:49
  • It doesn't work for me, guys. I have this error: ld: framework not found FBSDKCoreKit for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) – Evgeny Jul 25 '16 at 04:49
38

What you want to use is link_with from your Podfile. Something like:

link_with 'MainTarget', 'MainTargetTests'

Then run pod install again.

Keith Smiley
  • 61,481
  • 12
  • 97
  • 110