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

标签 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 {
}

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

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

最佳答案

我尝试为我的 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"

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

关于xcode - 添加 Swift 文件后无法运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31183216/

相关文章:

ios - WKInterfaceMenuItem 上的自定义图像未显示

ios - Xcode 内存调试器显示已删除对象的实例 - iOS

iphone - paymentWithProductIdentifier 的替代解决方案是什么?

ios - 在 ViewController 之外显示 UIAlertController

ios - 区分触摸计数SKSpriteNode

ios - 测试私有(private)@IBOutlets 和@IBActions

ios - 使用Xcode5.1 beta5还是使用xcode 5.0.2部署?

swift - 使用或不使用主机应用程序对自定义 iOS 框架进行单元测试

ios - 有没有办法针对存档的构建(.ipa)运行 XCTest(UI)?

SWIFT4 - 从服务器刷新数据