UnitTesting on iPhone doesn't build - iphone

I am trying to perform some unit testing on the iphone but for some reason I cannot get it to build the executable
I have downloaded TestMyApp from the Standford lecture slides and that compiles and runs perfectly. I have created a test project and even gone as far as to use the test code from the Stanford sample but for some reason depsite every setting looking identical I get the following precompiler errors:
/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:13:26:
error: AppKit/AppKit.h: No such file
or directory
/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:14:30:
error: CoreData/CoreData.h: No such
file or directory
N.B> Only other point to note is that Im running it on a "tweaked" xcode install on a PPC not an Intel mac

If you right click on your unit test target and select the "get info" menu you will see your target options.
At the bottom of the pane, you'll see a section called "User Defined": remove the entry containing the path to cocoa.h.
I don't remember the name of this entry as I removed it, but this fixes the same problem I had before.
I also changed Base SDK to be Device - iPhone OS 2.2
and other linker flags to -framework Foundation -framework SentestingKit

AppKit is not available for iPhone development. Looks like you downloaded a desktop mac app project. iPhone dev uses UIKit in place of AppKit.
CoreData is not available for iPhone dev as well.
Try setting up a Desktop cocoa application, and these frameworks and objects should be available.
For unit testing an iPhone app, the Google Toolbox for mac is useful.
GTM iPhone docs

You can find instructions and a sample project on Sen:te web site: http://www.sente.ch/s/?p=535&lang=en

I had to remove the value for GCC_PREFIX_HEADER in the "User Defined Section". It was using
$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h
Once I removed that, I got past this problem.

Do you have the iPhone SDK 2.2 installed? Without using the GTM for iPhone, OCunit doesn't work with iPhone SDK < 2.2.
I have been working with the Stanford example code as well. When I try to set up my own project, I wasn't able to get my tests to run. So, I took the Stanford example projects and renamed everything. Now the OCunit testing is working fine.

Do not use the Sen:te thing for testing any classes that make use of the UIKit framework. It will fail with code 139. Use Google's GTM.

Related

Newbie: Errors in an iPhone app

I'm really newbie in iOS and I have to handle a complicated situation. I was given an iPhone app developed by someone and I have to make it work. The guy who developed it has told me that it worked, but sometimes crashed in an iPhone. I've never developed using iOS and I don't really know how this app works.
Well, when I open the app with Xcode, the first problem that I detect is some errors with the references. The app uses the project CorePlot-CocoaTouch.xcodeproj. I've added again this project and solved the references (I've followed some other posts like this one: http://www.jaysonjc.com/programming/pie-chart-drawing-in-iphone-using-core-plot-library.html).
I want to test it with the simulator (I don't have an iPhone yet). I have a doubt here...should I use iOS Device, or iOS Simulator as Base SDK? Firstly I chose iOS Simulator, but it appeared a problem with Cocoa.framework (it turned into red).
Anyway, using iOS Device as Base SDK, I build the project and it says "Build failed (59 errors, 3 warnings)". I check out the errors, and most of them are "Expected specifier-qualifier-list before ..."
Can anyone help me? This is more or less the situation, but I can provide more specific details if they're needed.
I'm sorry if I'm talking about something really basic, but I've been trying to solve it for 2 weeks and I give up. I've tried to talk to the guy, but he's not really helpful..
Thanks for the replies!
By the way, I didn't say it and I don't know if it's relevant or what it means. The guy has a directory called "Libraries" where it's stored the CorePlot. The files there are the same than if you download the CorePlot project from other source. The only exception is a folder called "SDKBuild", which contains files like "build.sh", "iphoneos-SDKSettings.plist" or "iphonesimulator-SDKSettings.plist". I'm really newbie, so it's probably obvious, but I have no idea...
just try to add CocoaTouch framework to your project.
and for base SDK use "latest iOS".
Right click on the project name in 'group & files' set on the left of xcode. Choose add -> Existing Frameworks.
Find Cocoa.framwork and click add. Do this to all red colored framework.
Choose IOS Simulator as base SDK.
Try run it..
If you want to run the app on simulator, you have to build with iOS simulator. The base SDK basically sets the OS version (this will be the same regardless of whether you are running the app on simulator or device). You should be chaining the build settings to device only if the device is connected and if you have installed the appropriate provisioning profiles.

Building the Objective-C XML-RPC Framework for iOS

I'm fairly new to the iOS SDK and Xcode and I stumbled across this XML-RPC framework https://github.com/eczarny/xmlrpc that I'd really like to use in one of my projects. I downloaded the sources, the initial target was set to Mac OS, so I changed that to iOS 4.3 but got the following dependency error:
target specifies product type 'com.apple.product-type.framework', but there's no such product type for the 'iphoneos' platform
So I removed all the targets and added a new one from scratch using the Cocoa Touch Static Library, and it seems like it's been built just fine. Now my question is whether this is the correct way to build that library for iOS development, and where do I take it from here? I can't find the .framework directory anywhere (the install dir was set to "#executable_path/../Frameworks") so I can't embed it in my iOS project. How exactly does this go? Thanks!
Thanks for your help and sorry if this is too "newbish". Cheers!
If you're using Xcode 4.x open the Organizer, select the Projects tab and then down the left hand side you should see an entry relating to the XML-RPC project. Select that and under the Derived Data heading you'll see a path which if you follow using finder should lead you to the folder containing the static library you've built.

Will old source code run with SDK 4.2?

I've been working on creating my own iPhone app with source code my company gave me. This code was created with iPhone SDK 3.0. I've worked on it for over a year (I'm a designer so my coding is mostly copy and paste) and to test the app on my iPhone it says I must update my SDK to 4.2. I'm wondering will this break my app? I probably don't have the skills in xcode to upgrade my code if I am required to rewrite parts.
Thanks,
Chris
If none of the code has been deprecated, changed or even removed, chances are good it still runs fine. Most projects run, and if you have used external code (and hopefully noted where you got it from) there might be an update available for that piece of code.
Just set the deployment target to iOS 3.0 in your project settings
here some little explanation: link

Where's the MessageUI framework?

I'm trying to add the ability to send an email from my iPhone app, and step one appears to be to add the MessageUI Framework to my project and I it doesn't appear in my list of existing Frameworks. There is something called Message Framework. Is that it? Has Apple renamed it?
I did download the MailComposer sample and I can see that that project seems to have the MessageUI.framework in it, albeit not in the Frameworks folder with UIKit, Foundation, and CoreGraphics.
How should I proceed?
Note that I'm running Xcode 3.2 on Mac OS X Version 10.6.1
This is the real answer - To add it to your project, open up your target information. (You can do this by selecting your build target, and right-clicking to select Get Info). On the 'General' tab, you'll see 'LInked Libraries'. Here you can add new libraries that are actually available. MessageUI.framework is indeed one of those libraries. This should solve your cross-platform build issues. – Malaxeur
I ran into the same thing (I think), check to make sure you're in the iPhone frameworks folder when you go to add framework. Hit M to take you to it, the Mac one has a bunch of M frameworks in it, the iPhone has only 1, message kit (I think), just hit M.
That's what was wrong with mine.

iPhone framework paths?

I recently moved my projects to a new mac, along with a newer version of Xcode.
When i opened my project i noticed that some files were red. So i remapped them by setting the path (by project path) and then providing the proper path location.
Now my problem is that the frameworks that i have are red, and i cant find their location! I did set the framework paths to be "relative to current SDK" however.
Can anybody help me get my frameworks mapped correctly?
The frameworks im using are:
- QuartzCore.framework
- libsqlite3.0.dylib
- UIKit.framework
- Foundation.frameowrk
- CoreGraphics.framework
The XCode version is 3.1.4 (the only one installed).
The iPhone app was originally created using a prior version of Xcode (i dont remember which version).
I still dont have an answer. Im going deeper into this mess of a problem that Apple created.
In all my .m files im importing
How can i add this UIKit framework to my project Target with respect to the current SDK?
In fact, forget about the ref w/ respect to the SDK, let's just get the framework from the 3.0 SDK as a referenced framework. Right now when i reference it is red.
Note: references related to frameworks, everything about it, is driving me insane, and making me more frustrated at apple for this sloppiness, more than ever.
Any help is greatly appreciated.
I had exactly this problem. Somehow 'Base SDK' in Build Settings of a project was set to Mac OS X after I have installed Xcode 4.2.
Click on your project, change Base SDK to 'Latest iOS' and enjoy the vibe.
If you double click on your target to bring up the info pane you will see a tab labeled "Linked Libraries". From here you can click the plus button to add the libraries and xcode will do the right thing when you add the desired frameworks
I was having the same issue with red frameworks and bad pathing. If you're getting an error that says, "Base SDK Missing" you'll need to Get Info on your Xcode Project and check that it can find the right SDK.
Near the bottom of the General Info tab there will be an option Base SDK for All Configurations. Select a different SDK and see if that helps.
I ran into issues when I upgraded to a beta SDK and it was loading up deprecated frameworks from an old SDK.