XCTest.framework build error

33,729

Solution 1

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)

Solution 2

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.

Solution 3

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

Solution 4

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)

Solution 5

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.

Share:
33,729
user2703123
Author by

user2703123

Updated on July 05, 2022

Comments

  • user2703123
    user2703123 almost 2 years

    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.