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

时间:2015-07-02 11:22:55

标签: xcode swift xctest

我有一个已有几年历史的项目,现在我想在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,我有ensured I am using XCTest,我有changed my framework search paths,我有Symbols hidden by Default = NO,我确保我的桥接标头配置正确。

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

1 个答案:

答案 0 :(得分:0)

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

Build settings for test target: LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"

完整设置:

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

说实话,我不知道这意味着什么,但它确实有效。

相关问题