XCTest.framework build error
Asked Answered
S

9

34

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. 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.

Stamps answered 6/9, 2013 at 8:11 Comment(1)
XCTest is Apple's new unit testing framework. It should only be linked to unit test targets, not your actual app.Stew
O
51

I agree with Mike Weller. You should probably not be linking against the XCTest framework in your actual app code. Remove XCTest framework. 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. 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)
Orle answered 20/9, 2013 at 6:20 Comment(9)
This worked for me. The paths shown above are apparently correct for iOS 7. The migration (or maybe something else) set the first path to "$(SDKROOT)/Developer/Library/Frameworks\" including the quotes. Removing the quotes and backslash was necessary.Ramillies
Looks as though XCode5 doesn't spot changed to the framework paths option. A restart fixes it. For the the main issue was a link to the dev-tools and having the Dev-tools DEVELOPER_FRAMEWORKS_DIR on the path (which only has MacOSX x86 and x64 builds).Relativize
@veducm Spello fixed. Thank you!Orle
The refactor "Convert to XCTest..." definitely mangled the framework search paths for me (Xcode 5.0). I had to edit a couple paths that looked like this: \"$(SDKROOT)/Developer/Library/Frameworks\" to remove the spurious backslashes.Caporal
This worked for me as well. I had converted my original unit tests to XCTest and it didn't get the Framework Search Paths correct. Note that the above order of frameworks matter.Warsle
+1. Fixing the paths was the problem for me. I ended up with paths like Poulsbo describe, i.e. "stringified", and fixing them resolved it for me.Solarism
Adding $(SDKROOT)/Developer/Library/Frameworks to the projects' Framework Search Paths worked for me. Thanks!Highboy
I had $(DEVELOPER_FRAMEWORKS_DIR)/Frameworks path here. When I removed it, tests works wellDibble
Order of the paths is important; having $(inherited) first stopped working after installing a beta of Xcode.Gametophore
A
9

Adding to the possible solutions for this problem:

Make sure you did not include the MyApplicationTests.m file
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
when trying to run your app on the iPhone ( or simulator ).

XCTest should not be included in your regular application code as stated
in the other answers as well.

Aphrodisia answered 24/1, 2014 at 10:26 Comment(2)
"Make sure you did not include the MyApplicationTests.m file in the project's non-testing targets "Compile Sources" list." +1 for this tip. I was getting a "'XCTest/XCTest.h' file not found" error on the line "#import <XCTest/XCTest.h>" and removing the Tests.m was exactly the culprit!Suffragan
A common mistake is add test objective-C file and mark wrong "Add Target" checkbox. The answer was very useful. thanks!Conception
I
2

I Just removed the "XCTest.Framework" file from Project Navigator > Targets > 'Project Name' > Build Phases. Then, "Product" (drop-down) > Clean. Did it for me!

Iasis answered 17/1, 2014 at 17:31 Comment(0)
T
1

If you have a test target, you should also make sure that its Base SDK is set to iOS 7.0 (or even better: Latest iOS)

Tannatannage answered 24/10, 2013 at 9:18 Comment(0)
Z
1

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.

Zootomy answered 11/11, 2013 at 10:18 Comment(1)
I change order of framework search path to next : $(inherited), "$(DEVELOPER_LIBRARY_DIR)", $(SDKROOT)/Developer/Library/Frameworks". It works for meDibble
N
0

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. run the test to see it can run - by default it fails then check the Framework Searhc Path in main and test targets. and compare it to you project

see answer by me brian.clear here

Apple Mach-O linker (id) warning : building for MacOSX, but linking against dylib built for iOS

Nonresistant answered 7/11, 2013 at 15:51 Comment(0)
P
0

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)

I used the refactor option of XCode 6, converted my properly running SenTests to XCTests.

However when I set the framework search paths to ,

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

it worked.

Pisistratus answered 6/11, 2014 at 14:0 Comment(0)
F
0

You Can create your framework project, which is going to be a pod project without test files. Simple uncheck the tests while creating the project.

Finegrain answered 1/7, 2016 at 8:12 Comment(0)
P
0

This can be a reason:

If you have linked XCTest framework in both targets "MyApplication" and "MyApplicationTests". Then we do need to import "MyApplication" in "MyApplicationTests" file as

@testable import FlickrDemo

So it will create cyclic import and will cause XCTest framework not found issue. Simple solution will be to remove XCTest framework from "MyApplication" target.

Hope this will help someone.

Pydna answered 16/4, 2019 at 17:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.