Why Xcode 12.5b:Error: Cannot find 'XCTAssertEqual' in scope in playground?

I have import XCTest, it used to work. But error now:

XCTAssertEqual(counter.count, 0)

@young I was getting this issue as well in a test file that had previously been working up until Xcode 12.5 (beta1). I noticed that one of the "Known Issues" in the Release Notes directed this ENABLE_TESTING_SEARCH_PATHS=YES change. Setting that in Build Settings for my test target fixed my issue. Hope it does for you, too!

XCTest’s legacy Swift overlay library (libswiftXCTest.dylib) has been removed. Don’t use this library; instead use its replacement, libXCTestSwiftSupport.dylib. Any frameworks that link XCTest and encounter build issues due to this removed legacy library need to replace their manual framework or library search paths with the build setting ENABLE_TESTING_SEARCH_PATHS=YES, which automatically configures a target with the search paths needed to locate XCTest libraries. (70365050)

4 Likes

Thank you! This explains why the error.

But I cannot find anywhere to set this for Xcode Playground...

I'm not sure that we can change the Build Settings for Playgrounds. I was able to change this in my project's target Build Settings though.

Perhaps you could copy your playground code into a new project and set up a test target in order to move forward?

So XCTest doesn't work in Xcode Playground anymore...that's too bad. I use Playground for experimenting and study because it's so convenient. I hope they fix this.

I definitely see your point. Since the workaround is under "Known Issues", maybe it will be fixed/changed in a future version of Xcode?

Terms of Service

Privacy Policy

Cookie Policy