Xcode - SenTestingKit not found

2019-01-17 06:10发布

问题:

I have an issue that popped up when I upgraded my version of xcode. I use unit tests, and I now when I try to import SenTestingKit (#import <SenTestingKit/SenTestingKit.h>), I get this error: SenTestingKit/SenTestingKit.h: No such file or directory.

I have looked at my build settings, and I have the following configuration options:

== Linking ==
Other Linker Flags: -framework Foundation -framework SenTestingKit -framework UIKit
Prebinding: No

== Search Paths ==
Debug Configutation: "/iphonesimulator4.0/Developer/Library/Frameworks" "/Xcode4/Library/Frameworks"

I've checked /Xcode4/Library/Frameworks, and the SenTestingKit.framework/ directory is there.

So what am I missing?

回答1:

I had this same issue when creating a new test case in XCode. However, this was due to stupidity of me selecting the wrong target when creating the test case.

Using "File New...", the test case was being included and compiled with the target application settings instead of test case's target. Checking the Build Phases tab and looking in the "Compile Sources" disclosure revealed my particular issue.



回答2:

I had this issue after upgrading to xcode 4.3. Nothing seemed to work until I came across this post. I already had the same search paths, but changing the order solved the issue.

So from the article, you need the two following values in your Framework Search Paths, in this order.

$(SDKROOT)/Developer/Library/Frameworks
$(DEVELOPER_LIBRARY_DIR)/Frameworks


回答3:

I had this issue because there's a space in my Xcode installation: /Xcode 4.0.2

I fixed it by adding "${DEVELOPER_LIBRARY_DIR}/Frameworks" (with the quotes) to my Framework Search Paths.



回答4:

For my Framework Search Paths, I've explicitly added /$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk/Developer/Library/Frameworks. Compiles correctly for simulator and device.

I am sure there are environment variables so that it works across SDK versions, so I will update answer if I find them.



回答5:

To clear this up once for all, there are three SenTestingKit frameworks in Xcode SDK, one is for OS X, one is for iOS and one is for the simulator.

Had you ran "lipo -info" on them you would have seen that

Architectures in the fat file: /Developer/Library/Frameworks/SenTestingKit.framework/Versions/A/SenTestingKit are: x86_64 i386

Architectures in the fat file: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/Developer/Library/Frameworks/SenTestingKit.framework/SenTestingKit is architecture: armv7

Non-fat file: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/Developer/Library/Frameworks/SenTestingKit.framework/SenTestingKit is architecture: i386



回答6:

You might want to check that Xcode is checking the Framework Search Paths: