添加 Swift 文件后无法 运行 测试

Cannot run tests after adding a Swift file

我有一个已有几年历史的项目,现在我想在 Swift 中创建一个新功能。但是,在插入第一个 swift 文件后,我无法对 运行 进行单元测试。测试编译,模拟器启动。但是在测试开始到 运行 之前,我得到这个错误:

Simulator session started with process 58478
Debugger attached to process 58478
IDEBundleInjection.c: Error 3587 loading bundle '/Users/jrv/Library/Caches/AppCode32/DerivedData/MobileBank-542f20a4/Build/Products/Debug-iphonesimulator/Test.xctest': The bundle “Test.xctest” couldn’t be loaded because it is damaged or missing necessary resources.
DevToolsBundleInjection environment:
XCInjectDiagnostics: (null)
XCInjectBundleInto: /Users/jrv/Library/Caches/AppCode32/DerivedData/MobileBank-542f20a4/Build/Products/Debug-iphonesimulator/Sydbank.app/Sydbank
XCInjectBundle: /Users/jrv/Library/Caches/AppCode32/DerivedData/MobileBank-542f20a4/Build/Products/Debug-iphonesimulator/Test.xctest
TestBundleLocation: (null)
TMPDIR: /Users/jrv/Library/Developer/CoreSimulator/Devices/8016383A-A404-4D35-BDCB-0ED5317AD44A/data/Containers/Data/Application/CA2E7792-CA10-4109-B95E-7B0CA9D18147/tmp
DYLD_LIBRARY_PATH: /Users/jrv/Library/Caches/AppCode32/DerivedData/MobileBank-542f20a4/Build/Products/Debug-iphonesimulator
DYLD_INSERT_LIBRARIES: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection
DYLD_FRAMEWORK_PATH: /Users/jrv/Library/Caches/AppCode32/DerivedData/MobileBank-542f20a4/Build/Products/Debug-iphonesimulator
DYLD_FALLBACK_LIBRARY_PATH: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib
DYLD_FALLBACK_FRAMEWORK_PATH: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks

即使是最简单的 swift 文件也会出现同样的错误:

import Foundation
class MyTests: XCTestCase {
}

搜索Stack Overflow给出了几个建议。我已尝试 remove code signing, I have ensured I am using XCTest, I have changed my framework search paths, I have Symbols hidden by Default = NO,并已确保我的桥接头配置正确。

任何建议将不胜感激...

我尝试为我的 Swift 文件创建一个新的测试目标,这个目标成功了。然后我比较了旧测试目标和新目标之间的配置,逐个参数。当我在我的测试目标上设置它时,我终于确定了一个导致测试 运行 的参数:

完整设置:

LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"

老实说,我不知道这是什么意思,但它确实有效。