我有一个已有几年历史的项目,现在我想在 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 {
}
Searching Stack Overflow 给出了几个建议。我尝试过 remove code signing ,我有ensured I am using XCTest ,我有changed my framework search paths ,我有Symbols hidden by Default = NO ,并且我已确保我的桥接 header 配置正确。
任何建议将不胜感激......
最佳答案
我尝试为我的 Swift 文件创建一个新的测试目标,并且该目标有效。然后,我逐个参数地比较旧测试目标和新测试目标之间的配置。我最终确定了一个参数,当我将其设置在测试目标上时,该参数会导致测试运行:
完整设置:
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
说实话,我不知道这意味着什么,但它确实有效。
关于xcode - 添加 Swift 文件后无法运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31183216/