I am adding OCUnit test case target to my existing iOS project. I have followed the tutorials from below links and done it. It created a new target for "MyAppTests" and .m, .h files. I added SenTestingKit.framework also.
http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/UnitTesting/02-Setting_Up_Unit_Tests_in_a_Project/setting_up.html#//apple_ref/doc/uid/TP40002143-CH3-SW1
http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/
But when i click on "Product" menu "Test" option, it gives always the following linker errors.
I tried solving errors by following these links and the solution they have provided,
xcode 4 fails to initiate unit tests (with linker error) after I created a new scheme
OCUnit testing an embedded framework
but, none of the solution worked for me, its still giving linker errors as it is. Please help on resolving these errors.
Thank you.
I resolved it myself, i just removed everything related to test target and created new test target and followed the same as per below Apple link, and it worked as expected!
http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/UnitTesting/02-Setting_Up_Unit_Tests_in_a_Project/setting_up.html#//apple_ref/doc/uid/TP40002143-CH3-SW1
Related
I'm trying to run some UI tests for my iOS app. I was successfully able to record my UI tests, but when running them, I get a linker error:
I have a UI Testing Target added to my project, and my UI Test file has been added to that target.
I've already been able to write and run several Unit Tests without a problem.
Anyone know where I should look to solve this, or have a guess what the problem may be?
EDIT: The full log output shows that the UI test file can't import an SDK that my target app relies on.
For some reason, when I created my UITest target, a linker flag was added in the target that shouldn't have been there (-lMySDK).
Removing that flag resolved the linker error.
I am unable to access my app classes in xctest target. Getting "_OBJ_CLASS_$_MYClassName", reference from: objc-class-ref in TestsCase.m ld:Symbol(s) not found for acrtichecture i386. When I add .m file in test case build phase this error is removed but while running on test cases I am getting following warning - class is implemented in both. one of the two will be used. which is undefind xcode7 ios.
I have read many solution over stackoverflow saying to remove .m reference from test case target's build phase but if I do it, it gives me class reference error.
In this project I have added test case target later it was not exists earlier. Is this the reason that I need to do some build setting. I have tried all things which I found over stakoverflow nothing has solved my problem.
Everything is working fine if I create `new project' and try to access classes in the newely created project test case class.
I just got the reason and happy to share. Since I was adding test case target into an existing project and Enable Testability' option was set to NO for debug mode in my project's build setting. I set it toYES` and it solved my problem :-) Reference - stakeoverflow.
"compilation errors"
I was trying out EarlGrey on one of my apps as a POC. If that goes well, I was planning to use the same for the enterprise app that our company is working on.
I setup the framework as described in the github page. The link is https://github.com/google/EarlGrey/blob/master/docs/install-and-run.md
I followed all the steps and added EarlGrey.swift file too in my tests folder. Because it was the way the Demo project in EarlGrey project directory was setup. Unfortunately I started getting 13 compilation errors in EarlGrey.swift file. I was getting "Use of unresolved identifier grey_accessibilityID" errors all over. Snapshot attached.
I have tried most scenarios, please let me know if you have any ideas.
Have you tried importing EarlGrey in the bridging header?
See Swift section in https://github.com/google/EarlGrey/blob/master/docs/install-and-run.md#swift
Update:
The fix was to rename the EarlGrey-1.0.0 folder to EarlGrey that's downloaded by Pods and fix all the broken links in the xcode project.
I've read through the article referring to this in xcode 4.5, but it didn't help me in xcode 5.0.2.
I have a project that compiles successfully. If I add the Stripe framework to my project then it immediately fails to compile and gives me this file not found error for an #import made in this header file:
Stripe/Vendor/PaymentKit/PaymentKit Example/PaymentKit Test/PKCardNumberTest.h:9:9: 'SenTestingKit/SenTestingKit.h' file not found
I do not have the SenTesting framework in my link libraries. If I add it I get an error about it being an OSX library and not an ios. None of the Stripe documentation gives any indication that you need to add this library. I sent their support an email and they told me they don't have any information.
Anyone out there have any suggestions? Again, as soon as I add the framework to my project (and I am making sure it copies the files to my project) it fails to compile.
I tried adding quotes around my framework search paths, but it just changed the error so now Parse/Parse.h was no longer found.
The two framework search paths I have are: $(inherited) and /Users/ctam/Documents/development/Chw
See the Xcode 5.0 Release Notes:
Unit Testing
The CPlusTest unit testing framework has been removed
from Xcode 5. To write unit tests for C++ code, use the new XCTest
framework and create Objective-C++ (.mm) test case subclasses. 8273037
SenTestingKit and OCUnit are deprecated. Use the migrator to move to
XCTest. 14857574
When you download the Stripe library via the link in their documentation there are a bunch of subfolders for a test project they don't tell you about. I looked through and removed the test application files and everything works fine now. Curious that their explicit directions lead to this problem.
My unit tests worked fine in xcode4 until I had to create a new schema to compile a package to run on my device for testing.
All I did was creating a new Target and a new Scheme, now I try to run the unit tests and get the following error:
The test bundle at [...]Tests.octest could not be loaded because a link error occurred. It is likely that dyld cannot locate a framework framework or library that the the test bundle was linked against, possibly because the framework or library had an incorrect install path at link time.
What did I break?
Like #Haoest and #Peter DeWeese above's comments to Answer 1 - I had exactly the same problem when I changed the product name.
To fix this for the case where you've renamed the product, you need to go to the Build Settings tab of the test target, and change the Linking section - the Debug and Release bundle loader settings. If you have renamed the product - the directory and name of the application may both be incorrect.
Thanks to both of them for pointing this out - but I thought this alternative fix for this situation deserved a higher profile than a comment.
I've also run across problems with Xcode 4 after adding a target to an existing project. I eventually figured out that the Xcode DerivedData for the project was damaged. By deleting that data, I caused Xcode to rebuild the data and the project returned to normal. I found the data in my home Library folder (~/Library/Developer/Xcode/DerivedData/).
I tried everything (including the other answers and those noted here http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/), but finally found a different solution:
Set Deployment Postprocessing (in the Deployment section of Build Settings) to NO for the Debug target.
Before I did this, the executable was being stripped, and the link would fail with
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_SomeClassUnderTest", referenced from:
objc-class-ref in SomeTest.o
No matter that Strip Linked Product and Strip Debug Symbols During Copy were set to NO, it made no difference - only changing the Deployment Postprocessing setting finally made sure that the symbols were not stripped.
Same error message, in my case I wasn't linking one of the classes that were needed during the tests.
I discovered my problem was that I had 'Link time optimisation' enabled on my debug build. Setting it to no resolved the problem.
We were using nodejs-mobile which would build with the app but fail building with the tests.
Undefined symbols for architecture x86_64:
_start_node
In addition to all of the previous answers (build settings, search paths, making a brand new Unit Test, deleting DerivedData), what finally resolved it was creating a brand new new UI test instead of a Unit Test in Xcode.
It built successfully. Then you can copy your test definitions from your current test to the one one.
If you do not need the UI part, you can uncomment XCUIApplication().launch() in setUp of the generated tests, which makes it run as fast as before.