Cannot find interface declaration for 'XCTestCase'

I am writing the Unit test cases for the App Extension. The App Extension target is a combination of Swift Code + Objective Code. I just followed the below steps after creating the unit test target for the schema (The app target to be tested)which points out to the App Extension target in the XCode.

  1. Select you extension test target in Project settings
  2. Go to Build Phases
  3. Expand Compile Sources
  4. Click +
  5. Add source files with your testable code.
  6. Build for Testing

When I try to build the unit test target from the XCode. I am seeing the below error

Cannot find interface declaration for 'XCTestCase', superclass of 'TunnelTests'

Please provide help to overcome this Blocker.

Hi there,

It sounds like you haven't imported the XCTest framework in the test file. (XCTest.framework defines the XCTestCase class, and many other test classes and assertion functions used in unit tests and UI tests.)

Assuming that this is an Objective-C file, make sure you have the following import line near the top of your TunnelTests file:

#import <XCTest/XCTest.h>

In the attached TunnelTests file. You can clear see that the file clearly has an import XCTest statement indicates to import XCTest.framework defines the XCTestCase class.

It even generates the BridgingHeader for the PacketTunnelTests unit test target & throws an error that the "Cannot find interface declaration for 'XCTestCase', superclass of 'TunnelTests'.

Note: I have created a swift file not objective c file for writing the unit test cases.

Cannot find interface declaration for 'XCTestCase'
 
 
Q