Why do my OCMock expects and stubs fail in iOS 5? - iphone

I have some simple mock objects with some stubs and expectations set up. When I run my tests on the iOS 4.3 simulator, everything passes. When I run on iOS 5, I get "unexpected method invoked" failures. As an example case, I have a method - (void) foo: (NSString *) bar that I set up an expectation for and then run. The result is
unexpected method invoked: foo:#"foobar"
expected: foo:#"foobar"
Any one know why this is happening, or how to fix it? The tests themselves are perfectly fine, and have been working for months in iOS 4.

Sorry only saw this now. It has been fixed for a while
https://github.com/erikdoe/ocmock/commit/db6f27041efc507ae6ab92721e2f7bbbbd14c28b
Update: The newly released version 2.0 of OCMock contains this fix. So, you don't have to build from source if you don't want to.

I'm using the latest version of OCMock from Github on iOS 5 without any problems. There have been some recent additions to this repository, so it's quite possible that the problems you're experiencing have been fixed in the latest version.

Related

Can't compile code containing iOS 5 method when setting lower deployment target

Not true for all new iOS 5 methods but I've found out that calling UINavigationBar's setBackgroundImage:forBarMetrics: method will trigger an 'instance method not found' warning if the deployment target is under 5.0. This is even though I am linking with the SDK 5.0.
More importantly the enum UIBarMetrics used as a parameter there is reported as an 'undeclared identifier' and this will trigger a compiler error.
Any idea why this is so? I realized the code will not work if the deployment target is under 5.0 but I'm checking if UINavigationBar responds to that selector at run time, so everything should be ok. I don't understand the compiler error though.
EDIT:
This only happens when compiling for a device, and when a device is actually plugged in (the device I've tested with runs iOS 5.0.1).
Well, I figured out the mystery. I manage to fix the problem by deleting SDK 4.3 (I had that one copied over from Xcode 3 since it doesn't come by default with the latest Xcode+SDK package and I was using it for another legacy project).
I still can't explain why having both SDKs caused the error since I was clearly compiling with the latest SDK.

TTLauncher in Xcode 4.0

Is there anybody who has successfully used Three20 v1.1 in Xcode 4?
I have a project with TTLauncher, but cannot get it to work properly (Creating an Archive for distribution). The v1.1 branch hasn't been merged yet with the updated 1.0.5 it seems.
Also, I don't seem to be able to run it anymore in the simulator, although it is ok on the iPhone.There seems to be a problem here in TTURLNavigatorPattern:
NSInvalidArgumentException: -[TTURLNavigatorPattern setSelectorWithNames:]: unrecognized
selector sent to instance 0x5c14f80
Originating in:
[map from:#"tt://ArticleTableView/(initWithCategory:)"toViewController:[ArticleTableViewController class]];
With my multiple tries to get the V1.1 to work I must have broken something in Xcode 4, so I ended up re-creating the whole project and just putting all my code back in (which allowed me to re-organsie it and put it into a new repo as well). Now using the 1.0.5 version of Three20 (and just wrote a TTNavigationController myself which does the simple job I am looking for now) it all seems to work again on both the iPhone as in the simulator.

XCode 4 says, "Argument Invalid" on attempt to run project

I had a project initially created in XCode 3 and used it successfully in XCode 4 Developer Preview version.
After upgrading to XCode 4 release, any time I try to run the project on the device, I get a "Argument Invalid" dialog. Except it doesn't tell me what argument.
How does one figure out what is wrong and why I can't run the app on my device any more?
Base SDK is set to 4.3
Deployment target set to: iOS 4.2
Ok, I have just managed to sort this out as I was having the same issue. This may not help you, but for me it was because I had a symlink inside a folder included in the project. I've removed this, and now it all works fine. Interestingly it works fine on the simulator in this case.
I've filed a bug with Apple on the issue (#9168893).
Just clean your producto
Menu>Product>Clean (Shift+Cmd+K)
I got the following message argument is invalid in response to some kind of USB weirdness. Sometimes it goes away if I unplug and replug the device, but what turns out to fix it more reliably is to start up iTunes. Usually, when I do this, the problematic device doesn't appear in the DEVICES list at first, but does after a few seconds, and once it does, the device and Xcode get along fine.

detecting and preventing crashed on older iOS (Suspecting EventKit)

Dear Scholars.
I have created a simple application using the latest SDK (4.2.1), Which runs smoothly and error free on all devices with iOS 4.x.x.
Lately I am getting some comments from users with older iOS version complaining the application is crashing on start, on Apple's crash log I see nothing at all.
Pushing my investigation forward, the only suspect I have at the moment is the use of EventKit class, which if memory serves, where introduced only after iOS4.
I am using it very lightly in one of my classes, and it works perfectly on iOS4.2.1
#import <EventKit/EventKit.h>
//some time later
[self setADateInCal: [MyTimeArray objectAtIndex:0] :formatterDate];
Thus my Questions:
Can this be the issue that crashes my application on iOS < 4 ?
How can I prevent it without dropping the feature for people with iOS4
In general, How can I test this? I have the latest official iOS on my device and SDK, the simulator is limited to how back it can go in regrading to iOS version... any magical way to do so?
1.) Yes. If it wasn't in the API in <4.0 than anyone not running >4.0 will crash.
2.) Test to see if the class is available using NSClassFromString (Google for examples) and respondsToSelector in correspondence to see if the method you want is available to use in the OS version the client is running. You will also probably need to weak link the EventKit framework (again Google for how to do this).
3.) The only real way to test this is to keep a device at the OS you want to test. Personally, I have an old iPhone that I never update running 3.1.3 for things just like this. Alternatively, you can keep old installs of xcode+iOSSDK on different partitions or something and use their simulator. (for future updates i guess since you obviously haven't done this for <4.0). But no, there is no magical way to do this. sorry.
edit for clarity on Number 2: Basically you will check to see if the class/method you want is available on the OS version you are currently running, if it is you can use it, if not you will have to find a work around (omit completely or do it another way that is compliant with older versions).
Yes it could be causing the crash. Issues with missing libraries do not report anything in the apple crash log.
To prevent it from happening you need to do two things,
Weak link the event kit library in xcode.
Check for its existence in your code with something like
,
if(!NSClassFromString(#"EKEventKit")){
//do stuff with event kit
}
The only way to test on the actual iOS version is to get hold of a physical device running ios < 4.

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