XCTest/XCTest.h not found on old projects built in Xcode 6
Re-visiting my very old question, as of Xcode 11 you can set
ENABLE_TESTING_SEARCH_PATHS = YES
in your target
After renaming project i get XCTest/XCTest.h not found.
I came across something similar and I'm wondering if my solution might be helpful.
You may want to check that the file which is throwing the error is included in the appropriate Target Source's "Compile Sources". It's possible your file might not have been included. In my case it had been included with the project target and not with the test target. Since XCTest is only accessible with the Test Target, it wouldn't compile for me generating the error "XCTest/XCTest.h file not found".
Project Targets >> Build Phases >> Compile Sources:
You can fix this by either manually adding it to the "Compile Sources" as per the above image or you can remove the file from the project and re-add it, making sure to select the Test Target when you re-add:
In case it helps anyone else I came across this after moving a test case file (in the file system) and then re-adding it to my test project (right click, 'Add Files to "Project"...'). It turns out I wasn't adding the file to the Test target - I was just adding it to the Project Target.
add xctest framework to an old project
In Xcode 6.1.1, and also in Xcode 6.0.1, the XCTest.framework is not listed anymore as an available framework. In Xcode 5.1.1, however, the framework is listed.
So something appears to have changed between Xcode 5 and 6 when it comes to testing. For instance, when you create a new project in Xcode 6 you no longer need the XCTest framework. You can simply add a new test case, build and the test runs just fine. I have yet to figure out why this is the case, but for you this might be the first thing to try: Just code a test case and see whether things work.
If they don't, then you could try this ugly workaround: Open the project with an older version of Xcode, add the framework there, then go back to work in your new version of Xcode. This worked for me when I tried it with Xcode 5.1.1.
EDIT: The reason why XCTest.framework is no longer needed in projects created by Xcode 6 is because these projects have the build setting CLANG_ENABLE_MODULES set to YES. Xcode 6 exposes this in the UI under the name "Enable Modules (C and Objective-C)". With this setting enabled, any #import
statements for system frameworks such as XCTest cause clang
to automatically link against that framework. Details are available in the "Modules" section of the clang documentation. Once this build setting is enabled you can also remove any other system frameworks from the "Link Binary with Libraries" build phase of your targets.
And for completeness' sake: The reason why Xcode 6 no longer lists XCTest.framework as an available framework is because the framework's location inside the Xcode bundle has changed:
# Xcode 6
/Applications/Xcode-6.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework
# Xcode 5
/Applications/Xcode-5.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/Developer/Library/Frameworks/XCTest.framework
Apparently Apple now relies entirely on CLANG_ENABLE_MODULES to get test targets to link against XCTest.framework. If you want Xcode 6 to list XCTest.framework as an available framework, you can manually create a symbolic link inside the Xcode app bundle:
cd /Applications/Xcode-6.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks
sudo ln -s /Applications/Xcode-6.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework .
You need to restart Xcode after creating the link.
Related Topics
Could Not Cast Value of Type 'Uitableviewcell' to '(Appname).(Customcellname)'
iOS Check If Application Has Access to Microphone
React Native Xcode Project Product Archive Fails with Duplicate Symbols for Architecture Arm64
Swift 3 - How to Make Timer Work in Background
How Detect Swipe Gesture Direction
How to Convert Uicolor Value to a Named Color String
Get Name of Airplay Device Using Avplayer
Cannot Assign to Property in Protocol - Swift Compiler Error
How to Install iOS 7.0 and iOS 8.0 Simulators in Xcode 6.1
How to Get the Front Camera in Swift
Why Force Unwrapping Is Required in Case of Enum and Switch
Swift Invalidate Timer Doesn't Work
How to Get a Swift Type Name as a String with Its Namespace (Or Framework Name)
Not Receiving Push Notifications from Firebase
iOS Timed Background Processing