gpt4 book ai didi

frameworks - MacOS Swift Framework 测试失败

转载 作者:IT王子 更新时间:2023-10-29 05:39:33 25 4
gpt4 key购买 nike

我有一个用 obj-c 和 swift 编写的框架。

现在我尝试运行一个相关的单元测试目标,但我得到这个错误:

2014-07-10 07:45:54.064 xctest[4908:303] The test bundle at /Users/steve/Temporary/Build/Products/Debug/SOGraphDB-Mac Tests.xctest could not be loaded because an unanticipated error occurred: Error Domain=NSCocoaErrorDomain Code=3587 "The bundle “SOGraphDB-Mac Tests” couldn’t be loaded because it is damaged or missing necessary resources." (dlopen_preflight(/Users/steve/Temporary/Build/Products/Debug/SOGraphDB-Mac Tests.xctest/Contents/MacOS/SOGraphDB-Mac Tests): Library not loaded: @rpath/libswiftAppKit.dylib
Referenced from: /Users/steve/Temporary/Build/Products/Debug/SOGraphDB.framework/Versions/A/SOGraphDB
Reason: image not found) UserInfo=0x10011c640 {NSLocalizedFailureReason=The bundle is damaged or missing necessary resources., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Users/steve/Temporary/Build/Products/Debug/SOGraphDB-Mac Tests.xctest/Contents/MacOS/SOGraphDB-Mac Tests, NSDebugDescription=dlopen_preflight(/Users/steve/Temporary/Build/Products/Debug/SOGraphDB-Mac Tests.xctest/Contents/MacOS/SOGraphDB-Mac Tests): Library not loaded: @rpath/libswiftAppKit.dylib
Referenced from: /Users/steve/Temporary/Build/Products/Debug/SOGraphDB.framework/Versions/A/SOGraphDB
Reason: image not found, NSBundlePath=/Users/steve/Temporary/Build/Products/Debug/SOGraphDB-Mac Tests.xctest, NSLocalizedDescription=The bundle “SOGraphDB-Mac Tests” couldn’t be loaded because it is damaged or missing necessary resources.}

知道根本原因是什么吗?该错误似乎与“未加载库:@rpath/libswiftAppKit.dylib”有关

两者(框架和测试包)编译时没有任何错误或警告(在 Beta2 中)

最佳答案

我有一个类似的问题,虽然我的是一个 iOS 测试目标,链接到一个 Swift 框架,但无法在 Xcode 6 GM 上运行。测试目标在 Xcode 6 的早期测试版上运行成功,但最终版本报告运行时错误:Library not loaded: @rpath/libswiftCore.dylib

我注意到一个较新的项目没有失败,所以我比较了build设置和测试代码。我能够通过三个步骤解决问题:

  1. 测试目标需要将“嵌入式目标包含 Swift 代码”设置为"is"。这会告诉链接器将 Swift 运行时库添加到可执行文件中。

  2. 测试目标需要“运行路径搜索路径”build设置的明确值。这告诉加载程序在哪里可以找到 Swift 运行时库。我从一个全新的测试目标中复制了以下设置:

    LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks @loader_path/../Frameworks
  3. 测试用例需要显式导入链接框架使用的任何模块。在我的项目中,框架使用了 UIKit 但测试用例只使用了我的框架。当我向测试用例添加显式 import UIKit 时,链接问题就消失了。

关于frameworks - MacOS Swift Framework 测试失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24669403/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com