XCTest/XCTest.h not found on old projects built in Xcode 6

I have a few projects I’m trying to build with Xcode 6 Beta 2. The projects all have some type of library that uses XCTest (Kiwi/XCTest and Specta) that don’t build in Xcode 6 because XCTest/XCTest.h cannot be found.

fatal error: 'XCTest/XCTest.h' file not found
#import <XCTest/XCTest.h>

I noticed that XCTest.framework is no longer in the “Link Libraries with Binaries” build phase list, but that’s fine because when I create a new project with Xcode 6 it appears the library is linked in automatically.

  • addUIInterruptionMonitor(withDescription:handler:) not working on iOS 10 or 9
  • AFNetworking Cause Error while using XCTest in Xcode5
  • XCUIElement - Obtain Image value
  • How to run one-time setup code before executing any XCTest
  • How to access Core Data generated Obj-C classes in test targets?
  • How can I run XCTest for a swift application from the command line?
  • Perhaps of some relevency, my XCTest-needing dependencies are all brought in via Cocoapods.

    Is there anything I’m unaware of that I need to update with my project?

    10 Solutions Collect From Internet About “XCTest/XCTest.h not found on old projects built in Xcode 6”

    Note: This may not be needed for any projects created in Xcode 7.

    CocoaPods had a fix for this here and here

    In order to fix this for any CocoaPod dependencies you need to add the following to FRAMEWORK_SEARCH_PATHS in any Pod target that requires XCTest (e.g. Kiwi, Specta, FBSnapshotTestCase, etc).



    This will allow you to reference XCTest in any dependencies you may have. This may be fixed in a future update of CocoaPods, or the Pod you are referencing, so you may want to remove it later.

    It is not detrimental to earlier versions of Xcode so should be safe to use.

    I was moving files in project around. All you have to do is select your test files xxxTests.m etc. and in file inspector select target as test and not as a regular target.

    I’ve noticed that XCTest is available to a test target only (in XCode 6). If you are using using XCTest for any other target (for whatever reason), you will see the XCTest.h not found error.

    @squarefrog has the right answer but you’ll have to keep doing that manually each time you update your pods 🙁

    If you add this to your podfile it will automatically add the extra path for you. E.g. if you wanted to add $(PLATFORM_DIR)/Developer/Library/Frameworks to FRAMEWORK_SEARCH_PATHS for Specta:

    post_install do |installer|
        target = installer.project.targets.find { |t| t.to_s == "Pods-Tests-Specta" }
        if (target)
            target.build_configurations.each do |config|
                s = config.build_settings['FRAMEWORK_SEARCH_PATHS']
                s = [ '$(inherited)' ] if s == nil;
                config.build_settings['FRAMEWORK_SEARCH_PATHS'] = s
            puts "WARNING: Pods-Tests-Specta target not found"

    This error comes up when you have added a file where XCTest is being used outside of a test target. To fix this in AppCode, you can right click on any suspected file and select ‘Manage Targets’ then make sure only the test target is checked.

    I have faced same issue after some time I have imported XCTest framework from build phases and solved the issue.

    Build phases-> XCTest.Framework>clean and run. I hope it will be helpful to some one..

    for your reference…Import XCTest in to existing project

    As of the time of writing, the latest version of Cocoapods (0.33.1) doesn’t have a fix for the problem.

    But the cutting edge version does.

    Follow this guide to set the latest version of Cocoapods up from source. I call mine pod-dev (covered in the guide) to distinguish it from the gem-installed version of pods.

    The benefit of this approach is that you don’t need extra scripting in your Podfile. You just have to remember to do a pod-dev install instead of the usual pod install.

    This is the easiest work-around I’ve found. No project changes are necessary. And this change will persist until your next Xcode upgrade:

    cd /Applications/Xcode6-Beta7.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/Developer/Library/Frameworks
    ln -s ../../../../../Library/Frameworks/XCTest.framework

    On a project without Cocoapods (so not directly answering the OP’s question but perhaps helpful for me or others in the future), we had the same issue. It was solved by replacing our previous OCTest items with XCTest. For example, a file MyApp.xcodeproj/project.pbxproj has this diff (shortened) ;

    - path = MyAppUnitTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
    + path = MyAppUnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };

    add the follow to framework search path