-
Notifications
You must be signed in to change notification settings - Fork 140
Troubleshooting
This page lists common issues you may encounter and how to resolve them.
This happens on new Xcode 4.5 projects where the defaults now use C++11. Cedar will eventually switch over once we phase out support for iOS 4.x (which does not ship with the C++11 standard library).
Until then, you'll have to change the "C++ Standard Library" build setting for your spec target to libstdc++
(instead of the default, libc++
).
Happens with spec bundles. Example failure:
ld: file not found: <path to build dir>/Products/<Configuration>-<device>/<target name>.app/<target name>
clang: error: linker command failed with exit code 1 (use -v to see invocation)
- This error occurs when there is an incorrect target name used.
- The target name should match the application your tests are running against.
- To fix this, update the
Bundle Loader
setting in build settings to$(BUILT_PRODUCTS_DIR)/<target name>.app/<target name>
ensuring that your new target name is the correct.
Example failure:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_SomeClassFromYourApp", referenced from:
objc-class-ref in SomeClassFromYourAppSpec.o
(maybe you meant: _OBJC_CLASS_$__OBJC_CLASS_$_SomeClassFromYourApp)
ld: symbol(s) not found for architecture i386
This error can happen when you have a spec bundle which is run against code built with "Strip Debug Symbols During Copy" set to Yes.
You should ensure that you're running your tests against code built with this configuration setting set to No. This should be the default if you're building with the Debug configuration.
Example failures:
FAILURE …
Attempt to compare non-pointer type for sameness.
FAILURE …
Attempt to compare non-pointer type to nil
This is caused by a C++ compiler bug in all current versions of Xcode when ARC is enabled and you use a Cedar matcher like be_same_instance_as or be_nil with an Objective-C object. You have 3 ways around this problem:
- Use an indirect comparison and check for truthiness. For example:
foo == bar should be_truthy; // instead of foo should be_same_instance_as(bar)
foo == nil should be_truthy; // instead of foo should be_nil
- Disable ARC for your spec files, but continue to use it for your application code. You can do this by selecting spec files in the target's "Compile Sources" build phase and adding the compiler flag
-fno-objc-arc
. You can help ensure that you do this by creating aSpecHelper.h
file in your spec target that you#import
into every spec which contains this guard:
#if __has_feature(objc_arc)
#error ARC must be disabled for specs!
#endif
- Use another matcher library like Expecta. Just remove the following line from your spec files:
using namespace Cedar::Matchers;
Example failure:
error: no matching function for call to 'CDR_expect'
note: candidate template ignored: substitution failure [with T = SOME_TYPE]
This is caused by a C++ compiler bug in versions of Xcode prior to 4.5 when ARC is enabled and you use a Cedar matcher. You have 3 ways to avoid this problem:
-
Switch to Xcode >= 4.5
-
Disable ARC for your spec files, but continue to use it for your application code. You can do this by selecting spec files in the target's "Compile Sources" build phase and adding the compiler flag
-fno-objc-arc
. You can help ensure that you do this by creating aSpecHelper.h
file in your spec target that you#import
into every spec which contains this guard:
#if __has_feature(objc_arc)
#error ARC must be disabled for specs!
#endif
- Use another matcher library like Expecta. Just remove the following line from your spec files:
using namespace Cedar::Matchers;