简体   繁体   English

XCTest.framework构建错误

[英]XCTest.framework build error

I am using the DropBox Core API in my app and therefore, I must include the XCTest framework, because, when I haven't added the XCTest framework, my app can't connect to dropbox, however when I do add the framework, I get an error while building for the simulator. 我在我的应用程序中使用了DropBox Core API,因此,我必须包括XCTest框架,因为当我没有添加XCTest框架时,我的应用程序无法连接到Dropbox,但是当我添加框架时,我为模拟器构建时出错。 There is nothing wrong with my code! 我的代码没有错! Here is the error: 这是错误:

Ld /Users/Zach/Library/Developer/Xcode/DerivedData/SnapDrop!-fchnxyvnqyeefscfhmohrzxtiqeb/Build/Products/Debug-iphonesimulator/SnapDrop!.app/SnapDrop! normal i386
    cd "/Users/Zach/Desktop/SnapDrop!"
    setenv IPHONEOS_DEPLOYMENT_TARGET 6.1
    setenv PATH "/Applications/Xcode5-DP6.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode5-DP6.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode5-DP6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode5-DP6.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -L/Users/Zach/Library/Developer/Xcode/DerivedData/SnapDrop!-fchnxyvnqyeefscfhmohrzxtiqeb/Build/Products/Debug-iphonesimulator -F/Users/Zach/Library/Developer/Xcode/DerivedData/SnapDrop!-fchnxyvnqyeefscfhmohrzxtiqeb/Build/Products/Debug-iphonesimulator -F/Users/Zach/Downloads/dropbox-ios-sdk-1.3.5 -F/Users/Zach/Downloads/dropbox-ios-sync-sdk-1-1.1.0 -F/Applications/Xcode5-DP6.app/Contents/Developer/Library/Frameworks -F/Users/Zach/Desktop -filelist /Users/Zach/Library/Developer/Xcode/DerivedData/SnapDrop!-fchnxyvnqyeefscfhmohrzxtiqeb/Build/Intermediates/SnapDrop!.build/Debug-iphonesimulator/SnapDrop!.build/Objects-normal/i386/SnapDrop!.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=6.1 -framework iAd -framework AssetsLibrary -framework QuartzCore -framework SystemConfiguration -framework Security -framework CFNetwork -framework XCTest -framework Dropbox -framework DropboxSDK -framework CoreGraphics -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker /Users/Zach/Library/Developer/Xcode/DerivedData/SnapDrop!-fchnxyvnqyeefscfhmohrzxtiqeb/Build/Intermediates/SnapDrop!.build/Debug-iphonesimulator/SnapDrop!.build/Objects-normal/i386/SnapDrop!_dependency_info.dat -o /Users/Zach/Library/Developer/Xcode/DerivedData/SnapDrop!-fchnxyvnqyeefscfhmohrzxtiqeb/Build/Products/Debug-iphonesimulator/SnapDrop!.app/SnapDrop!

ld: building for iOS Simulator, but linking against dylib built for MacOSX file '/Applications/Xcode5-DP6.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest' for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What should I do? 我该怎么办? If my framework is corrupt, can you tell me how to reinstall it? 如果我的框架已损坏,您能告诉我如何重新安装它吗? I have tried deleting and reinstalling Xcode with no luck. 我尝试删除并重新安装Xcode时没有运气。

I agree with Mike Weller. 我同意迈克·韦勒的观点。 You should probably not be linking against the XCTest framework in your actual app code. 您可能不应该在实际的应用程序代码中链接XCTest框架。 Remove XCTest framework. 删除XCTest框架。 Look at the linker errors and remove things that are referencing the framework. 查看链接器错误,并删除引用框架的内容。 Wash, rinse, repeat. 洗涤,漂洗,重复。

If you have a test target, that is different. 如果您有一个测试目标,那就不一样了。 What can easily happen during the migration from SenTestKit to XCTest is having the wrong framework search path which causes linking against the Mac OS X framework instead of the iOS framework. 从SenTestKit迁移到XCTest期间,很容易发生错误的框架搜索路径,从而导致与Mac OS X框架而不是iOS框架进行链接。 This doesn't work. 这行不通。

An easy way to see what the correct framework search path settings are is to create a dummy project, open the build settings for the Tests target and then filter for "Framework Search Path." 查看正确的框架搜索路径设置的一种简单方法是创建一个虚拟项目,打开“测试”目标的构建设置,然后过滤“框架搜索路径”。

I think the correct vanilla paths are: 我认为正确的香草路径是:

$(SDKROOT)/Developer/Library/Frameworks     (non-recursive)
$(inherited)                                (non-recursive)
$(DEVELOPER_FRAMEWORKS_DIR)                 (non-recursive)

Adding to the possible solutions for this problem: 添加到此问题的可能解决方案:

Make sure you did not include the MyApplicationTests.m file 确保您没有包括MyApplicationTests.m文件
in the project's non-testing targets "Compile Sources" list. 在项目的非测试目标的“编译源”列表中。

This can happen when you cleaned up folders on the disk 当您清理磁盘上的文件夹时,可能会发生这种情况
and moved things around manually for example. 并手动移动东西。

Project > Targets > MyApplication > Build Phases > Compile Sources

The most obvious symptom is that you get the XCTest error 最明显的症状是您收到XCTest错误
when trying to run your app on the iPhone ( or simulator ). 尝试在iPhone(或模拟器)上运行您的应用程序时。

XCTest should not be included in your regular application code as stated 如所述,XCTest不应包含在常规应用程序代码中
in the other answers as well. 在其他答案中也是如此。

I Just removed the "XCTest.Framework" file from Project Navigator > Targets > 'Project Name' > Build Phases. 我刚刚从“项目导航器”>“目标”>“项目名称”>“构建阶段”中删除了“ XCTest.Framework”文件。 Then, "Product" (drop-down) > Clean. 然后,“产品”(下拉)>清洁。 Did it for me! 为我做到了!

如果您有测试目标,还应确保将其Base SDK设置为iOS 7.0 (甚至更好: Latest iOS

I should add small note: 我应该补充一点说明:

My project had all paths correct (those three default ones) but the order was different. 我的项目的所有路径都正确(三个默认路径),但是顺序不同。 Setting correct order (by dragging path with mouse in the list) fixed the issue. 设置正确的顺序(通过使用列表中的鼠标拖动路径)解决了此问题。

Check your Framework Search Paths for your Main target and your test Target. 检查您的主要目标和测试目标的框架搜索路径。 I had a lot of crap in mine 我有很多废话

easiest if to create a new single view ios project. 创建新的单视图ios项目最简单。 run the test to see it can run - by default it fails then check the Framework Searhc Path in main and test targets. 运行测试以查看它可以运行-默认情况下失败,然后检查主要目标和测试目标中的Framework Searhc Path。 and compare it to you project 并将其与您的项目进行比较

see answer by me brian.clear here 看到我的答案brian.clear在这里

Apple Mach-O linker (id) warning : building for MacOSX, but linking against dylib built for iOS Apple Mach-O链接器(id)警告:为MacOSX构建,但与为iOS构建的dylib链接

None of the above works for me, I still get the error, 以上都不适合我,我仍然会收到错误消息,

ld: warning: Auto-Linking supplied '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest', missing required architecture i386 in file /Applications/Xcode.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest (2 slices) ld:警告:自动链接提供的'/Applications/Xcode.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest',文件/Applications/Xcode.app/Contents/Developer/Library/中缺少必需的体系结构i386框架/XCTest.framework/XCTest(2片)

I used the refactor option of XCode 6, converted my properly running SenTests to XCTests. 我使用了XCode 6的refactor选项,将正确运行的SenTests转换为XCTests。

However when I set the framework search paths to , 但是,当我将框架搜索路径设置为时,

$(SDKROOT)/Developer/Library/Frameworks and 
$(inherited)

it worked. 有效。

You Can create your framework project, which is going to be a pod project without test files. 您可以创建框架项目,该框架项目将是没有测试文件的Pod项目。 Simple uncheck the tests while creating the project. 只需在创建项目时取消选中测试即可。

This can be a reason: 这可能是一个原因:

If you have linked XCTest framework in both targets "MyApplication" and "MyApplicationTests". 如果在两个目标“ MyApplication”和“ MyApplicationTests”中都链接了XCTest框架。 Then we do need to import "MyApplication" in "MyApplicationTests" file as 然后,我们确实需要将“ MyApplicationTests”文件中的“ MyApplication”导入为

@testable import FlickrDemo

So it will create cyclic import and will cause XCTest framework not found issue. 因此它将创建循环导入,并会导致XCTest框架未找到问题。 Simple solution will be to remove XCTest framework from "MyApplication" target. 一个简单的解决方案是从“ MyApplication”目标中删除XCTest框架。

Hope this will help someone. 希望这会帮助某人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM