iPhone development Unit Testing Linking Problem - iphone

I've been trying to determine the cause of this error for days now. Tried doing simple projects by I could not get the unit tests to work? Does anyone know how to solve this problem?
Building target “ChildTests” of
project “Person” with configuration
“Debug” — (2 errors) Linking
/Users/me/Desktop/Person/build/Debug-iphonesimulator/ChildTests.octest/ChildTests(1
error) ".objc_class_name_Child",
referenced from:
literal-pointer#__OBJC#__cls_refs#Child
in ChildTests.o
symbol(s) not found
collect2: ld returned 1 exit status
...
Pardon me, I am new to iphone development.

The missing symbol is .objc_class_name_Child. I'm guessing you have a class called Child but its implementation file is not being built as part of your test target.
To fix the problem find the file (probably called Child.m) and make sure your test target is checked in the Targets tab of the file's File->Info.

Linker errors normally mean you've neglected to add a framework or static library to your project and/or neglected to add the header import for the library in question.
What unit test library/framework are you using?
If you're new to the platform, you may be causing yourself unnecessary confusion by trying to start out with unit tests. Unit testing can be very beneficial to delivering a stable final product, however, it doesn't seem to me to be a good place to start out. I would suggest you get your app working first and then add unit tests later once you're sure you're going to develop it to completion.

Related

XCode7 Unit tests fail (compiler error)

I have created a Unit Test target AFTER my app was already created.
The problem i have is that the test will fail with compiler errors unless i manually add each .swift file and library to the testing target. Since my app is a rather large app with many files and library dependencies this seems rather difficult to do.
I have followed the advice on this post http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/ which suggests that XCode can do this by setting the "Bundle Loader" and "Test host" settings in the testing target and setting "Symbols Hidden By Default" to NO in the app target, but that doesn't work.
What is the right way to solve this?
You can add #testable import YourModule and then all your classes should be available in your test case file.
You can read a little bit more here and some Apple docs.

Having some build issues on an app developed by someone else: ld: library not found for -lAdServer_Iphone

The build error I am getting is:
ld: library not found for -lAdServer_Iphone
I have experience in making apps from scratch. However the issue I am having is not having enough experience importing existing apps and making them work.
Would someone be able to give me some clarity on this?
Thank You
The error means that you did not copy the library called 'IAdServer_iPhone' to the proper location. To fix this, either get the location the project is linking to and copy the library there, or you can reimport the library from the new location.

iPhone Linker Error (AudioStreamer)

I'm using Matt Gallagher's Audio Streaming Project. I downloaded the code/project and it runs/compiles/links just fine.
The problem is when I try to integrate the AudioStreamer class into my own project. I added all the necessary frameworks and checked over the project settings to make sure they match Matt's project as much as possible.
I haven't added any of Matt's code yet (except for the AudioStreamer class). All I'm doing for now is defining this function:
- (void)createStreamer {
streamer = [[AudioStreamer alloc] initWithURL:audiourl];
}
If I comment out the only line in that function the project compiles/links fine. If I leave that line there I get this error (which if I understand correctly is a linker error):
"_OBJC_CLASS_$_AudioStreamer", referenced from:
objc-class-ref-to-AudioStreamer in AudioViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
I googled this error and most people get it because they forgot to include a certain framework. I have all the frameworks I need in my project.
Does anyone know any other reason why this error could occur? Is there some setting that I may be overlooking?
Most of the project settings are the same except for the build architecture being set to arm6,arm7 in Matt's project and i386 on mine. I tried compiling for both simulator and device and I get the same error.
The only thing I could think of is that Matt's project is dated 2009 (pretty old) so maybe something changed in the default configuration in the new xcodes?
If anyone can provide any insight I'd appreciate it.
Thanks.
It sounds like you need to add AudioStreamer.m to your target.

How to build command line tool in iphone project

I just started programming in Xcode and I'm trying to write an iphone application. I started out with a simple template for Iphone development and took it from there. Now I would like to build a command line tool (for converting data) which reuses some of the classes in my iphone project. I managed to add a new target 'convert', link the appropriate source code to the target, make the target dependent on the main target. Everything builds, so far so good, but it does not generate the right executable, it will build only build/Debug-iphonesimulator/convert which is not runnable from the command line (I'm guessing because it is not linked with the right libraries).
~/Documents/XCode/SQLiteTutorial> ./build/Debug-iphonesimulator/convert
dyld: Symbol not found: _OBJC_CLASS_$_NSCharacterSet
Referenced from: /Users/marc/Documents/XCode/SQLiteTutorial/./build/Debug-iphonesimulator/convert
Expected in: /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
in /Users/marc/Documents/XCode/SQLiteTutorial/./build/Debug-iphonesimulator/convert
Trace/BPT trap
Is this possible with xcode at all? I'm not sure what kind of extra information you would need to answer this question, so let me know what to provide, if anything.
Kind regards,
Marc van Kempen.
What if you simply created a different project entirely and then dragged in the relevant classes you wanted to reuse, but instead of copying them, merely used references to them? Just don't select 'copy items into destination's folder' option when you drag the class files into your groups & files pane. That way your CL project always uses the latest version from the main iPhone one.
Having it all in one project would no doubt be cleaner though.
iPhone SDK does not officially support building command-line tools. iPhone does not run command-line tools; at least, not without jailbreaking.

"No architectures" error when compiling objective flickr for iphone device

I'm getting the following error when I attempt to compile my XCode project to debug on my device.
No architectures to compile for (ARCHS=x86_64, VALID_ARCHS=armv6 armv7).
I've included ObjectiveFlickr in my project just as the readme describes. I've gone through the process several times and redownloaded objectiveFlickr a few times to start over.
I've gotten objectiveFlickr to work on devices in the past. I don't know why I am suddenly having trouble. Can anybody point me to something that might hold the clue I need? Any other info I need to provide? I made only changes to my project that are specified by the OF documentation.
I also get this error when compiling the included snap-n-run example project provided with OF. So I must be missing something beneath my project.
Thanks,
Charlie
Check out this post for another solution. I have not tested it for release/dist but it works for debug so far.
http://groups.google.com/group/objectiveflickr/browse_thread/thread/ad8e5ec6ba976672
Well, I wasn't able to truly solve this problem. However, after corresponding with Lukhanos, the creator of objflickr, I tried including the objflickr source code directly in my project. After a bit of trial and error to sort out which source files were needed (the "source" directory and the "LFWebAPIKit" directory) and adding the "SystemConfiguration" framework to my project, things are building OK.
Still no clue as to why I was experiencing this issue, but at least I can get my project built now!
Thanks
- Charlie