UITextField causes crash in iOS 5, works fine in iOS 4 - iphone

I have a really weird problem where if I click on a UITextField, any UITextField in my app will crash with this error:
0_CreateCachePathEmbedded(__CFString const*, unsigned char)
0x0246ac4f <+0375> mov (%esi),%esi
Thread 5 WebThread: Program received signal: "EXC_BAD_ACCESS"
I tried adding a UITextField in interface builder not linked to anything, still get the same crash. Everything works fine in iOS4.3 simulator.
What on earth could be going on??

This also happened for me and changing the product name fixed it. I had a ∂ character in my Product Name for my debug/dev version of the application which seemed to work fine on iOS 4.3 but not on iOS 5. It is an impossible correlation to figure out that tapping on a random UITextField (not all caused this for example if I changed the UITextField to secure it did not crash) would cause a crash because the Product Name contained a non-standard character.
I hope this helps someone else having this issue as I spent days trying to debug this.

Still not sure what the problem was but I was able to fix it by just copying all code across to a new project.

in my case it was the product name in the target settings which caused this strange error.

Related

ADBannerContentSizePortrait not available on iOS 5

I am adding the iAd framework to an existing application. The application is portrait only and iPhone only. Everything is running in iOS 6, both in the simulator and on an iPhone 5. However, it fails in iOS 5 both in the simulator and on an iPhone 4. It throws the following exception:
'NSInternalInconsistencyException', reason: 'currentContentSize must be one of the requiredContentSizes; 'ADBannerContentSizePortrait' is not in {(
ADBannerContentSizeLandscape
)}'
The exception is thrown on this line:
iAdBannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
I see no way of displaying anything other than a landscape banner this way. I'm assuming I must have something configured wrong somewhere, but I don't know where, and find it curious that it works fine in iOS 6.
Any help here is greatly appreciated! Thanks!
UPDATE: I can't answer this because I don't have enough rep points. But I have it fixed:
Background: I'm using the Kobold2D wrapper around ADBannerView. It's class, KKAdBanner, is the one that is actually calling the line causing the error. It turns out, it was preceding this call by configuring ADBannerView to only allow landscape sizes. This was a configuration issue and I can resolve it.
Of course, now I don't know why in the world it ever worked in iOS 6 at all, but oh well :-)
I've never used this, but from what I'm understanding from the documentation you need to set the #property(nonatomic, copy) NSSet *requiredContentSizeIdentifiers
with all the value that currentContentSizeIdentifier could take.
And your exception is saying that in that NSSet you only have the one for the landscape.
The difference you are seeing could be due to a different default values in different iOS version. (I'm guessing)
Reference here.

Message sent to deallocated instance on device only

I'm at a complete loss with a memory bug. This issue only happens on the device and not the simulator. It also only happens when the app is loaded for the first time on the device. If I close the app and relaunch it the issue does not preset itself. This is the error I'm getting
-[CFString retain]: message sent to deallocated instance 0xfd5a2f0
I've tried everything to attempt to figure out what the released string is. Please help me figure out what the released object is when running on the device and not the simulator! Thanks in advance!
UPDATE:
I still do not have a solution but I have confirmed the app will crash consistently on the line of code where I set a frame and the above error shows. If I comment this code out the app will pass this point but may crash at other strange spots. I can't even begin to determine where the crash is originating.
CGRect frame = CGRectMake(27, 96, 265.0, 50.0);
someAcct.frame = frame;
I'm so confused by this since this is not a string. Any ideas?
UPDATE 2: This issue is directly related to the NSUser Defaults being synchronized. This seems pretty random but this is causing the issue. Any Help?
UPDATE 3: The problem has been solved as of a week ago. This was in fact due to a string being inaccessible. A string was passed to a method, that method then did work and passed data to another method and so on. Until finally the data was to be written to user defaults and a local plist contained within the documents folder. All of a sudden the app would crash at very strange places like the above consistently even though those places had nothing to do with a string. I was baffled and after playing with it for a very long time I decided to head over to the .h file and go through each string one at a time by making sure each were synthesized in the .m file and that self.stringName was applied throughout the .m file. After spending an hour on this I finally found the string that was to blame and the issue is now resolved. Using self.stringName allows the memory to be found and avoids these obscure and highly confusing application crashes. Thanks to everyone for all of the suggestions and tips!
To help you with tracing it down, could you try putting NSLog at the start of your didFinishLaunching() method, somewhere in the middle and at the of the didFinishLaunching().
Then also could you push a NSLog in the viewDidLoad() of the first view controller your app shows. For example, if you're using a tab bar interface, then a NSLog in the first tab's root view controller.
You can use NSLog(#"step 1"), NSLog(#"step 2"), NSLog(#"step 3") ... to organise the output so you know where the code managed to reach up to before it crash, rather than NSLog(#"I am here").
The problem is of retain count. Refer mememory management and check u r not missing something.
Don't forget to turn on NSZombieEnabled.
One reason can be due to the iOS compatibility.Check if your device and the simulator are using the same iOS.Try working the simulator on the same version of OS as your device and change the release of the string accordingly.

xcode4 with SDK 4.3 App working in sim but crashes on device, how is that possible?

I'm testing my app in the sim with SDK 4.3, My device is iPhone 4 with OS 4.3.3, when running the app on the sim every things is working, no errors and nothing, but on the device every thing crashes with the runtime error: "Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key addButton"
I can not find the problem in any xib file. I used to have this outlet, but not any more, not in the class and not in the xib (or maybe i am missing it, but i looked of many many hours for it) and the sim is getting it that i have changed the files but the device does not...
UPDATE: *maybe this would help. I decided to test my theory and removed (deleted) the MainWindox.xib file. compiled and got the same results...On the sim every things worked (WIERD AS IS) and in the device crashes.... The first part tells me that when the Xcode does the link and build, It builds from a deferent directory then the one that the project in... It is as weird as it can get in my eyes.... Any one has a thought about that? I think that when i will fix this every thing else will work just fine....*
What can i do?
Thank you very much,
Erez
There would most probably be a viewcontroller name just above the above error. Open the xib of that viewcontroller and check all buttons in that xib, and check the outlets of each of them. I assume you have forget to remove the outlet connection from one of the buttons.
If you cannot spot out the viewcontroller that has the problem, you need to check all xib files. Also, as alexJones mentioned, please check the capitalization of outlets as the device is case sensitive where the simulator is not.
You might had an outlet "addButton" connected to a button in XIB.
Later you might have removed "addButton" from code, but forgot to remove the connection in XIB.
If you open XIB, right click the "File's owner", you can see "addButton" in red color. Click "x" button to remove it. Then build the code and run on your iphone. It must work now.
Also clean your code, remove the app from your device before running on the device.
I've found the solution, the problem was exactly what i said, The XCode went to a wrong build somewhere, I don't know where and what happen, but it didn't go to the new build.... created a new project, copied all the files and then just changed the delegate and what needed and every thing is working, I am guessing it is a BUG, a very annoying one, but still a bug with XCode 4.
Thank you all,
Erez
Before going to such extremes as copying your project ... try cleaning your target sim and device first, then building from scratch. In effect i believe that is what you achieved by creating a new project.
I had the same problem too, would build and execute in the simulator but crash on my iPhone. The solution turned out to be improper case of a nib name in interface builder. detailView instead of the actual nib name DetailView. Great advice, thanks!

Universal app working on iPad 1 but not on iPad 2

First of all I want to say that I'm I aware that my question is probably way too vague to answer and may be closed/down-voted. I just hope for some inspiring brain-storming on possible solutions.
Here's the story:
My app was crashing on iPad 2, but not on iPad 1. I've fixed the crash related to unarchiving nib and now I have a very strange problem - my universal app still runs without any problems on 1st gen iPad with iOS 4.2.1 and 4.3.3, but not on (some/all?) iPads 2 with 4.3.3. Unfortunately I don't have an access to iPad 2 with iOS < 4.3.3 to test further and narrow down the problem.
My app has it's main screen displayed by using presentModalViewController. My modal VC is MGSplitViewController (it mimics native UISplitViewController and enhances its functionality). When my VC is presented, only "root view" is displayed and remaining part of screen for "detail view" is just black and empty however the controller is loaded and active (debug logs are printed etc.).
So on iPad 2 I have access to, it fails to display detail view properly, however I've heard from one user that it's fine on his iPad 2 (both iOS 4.3.3). App also works ok on iPhone/iPod regardless iOS version, so I assume it's related only to iPad code of my universal app.
I believe it may be more general issue with displaying views. I've tried to read view property of my detail view, which should force view to be displayed, but it didn't help. It may also be related to IB stuff (the initial nib unarchiving crash only on iPad 2??), but I think everything is wired ok in IB...
Anyone has a slightest idea how to investigate this problem?
EDIT: BTW: My iPad 2 is giving me hard time as it drops Wi-Fi connection very often. Other people are also reporting this kind of "feature". Can it be that it's just something wrong with my iPad 2?
EDIT2: the app is also not correctly displayed on iOS 3.2, 4.2 and 4.3.3 Simulator (via XCode 4), but gets displayed correctly on iOS 3.2, 4.2 Simulator via Xcode 3. Strange, isn't it?
Anyone has a slightest idea how to investigate this problem?
If you'll allow a somewhat vague answer to a somewhat vague question, then yes, I do have an idea.
To approach problems like this in general, bisection of the problem field is a great way to go forward:
You identify the general problem area. Could it be presentModalViewController in your case?
Then about halfway through the code in question, you set a breakpoint/write a message to a log file/play a sound/send a mail/tweet/whatever it takes to verify that your code has come that far without a crash.
Run it and see if your message has been produced.
If it has been produced, the problem is not in the first half, so it must be in the second half (a log message at the end of the identified problem area is useful, too, just to make sure that the crash actually happens before that).
On the other hand, if there is no trace of your log message, then the crash must occur in the first half, and you can rule out the second half of your code for this particular problem.
Now you repeat the algorithm by setting your breakpoint/log message about halfway into the culprit half you just identified.
Repeat until you find the problem. It won't take many iterations.
Of course, the crash may be due to some variable stored at a previous step or in another method, but now you know where to look.
Initially the app was crashing due to unarchiving the nib. I don't recall the exact crash output, but it was quite strange for me that same nib was properly unarchived on iPad 1 with same OS version, so I suspected that the problem lies in xib file... I've recreated the xib from scratch routing everything carefully and - bam! - it started working on both iPad 1 and iPad 2! How come some nibs aren't unarchived in a same way on same OS running different HW???

Overridden UIPickerView instantiated on simulator but not on device

In my project I have a subclass A of a UIPickerView.
In Interface Builder I have a UIPickerView whose type I have changed to my subclass A.
In another class B, also defined in my code, instantiated in Interface Builder and linked to A via its outlet, it refers to A with an IBOutlet field A *mySubclass.
The problem is this:
When running on the simulator it works fine; A breakpoint on B’s awakeFromNib confirms that mySubclass has been loaded and is indeed of type A.
When running on the device (iOS4.1 on iPhone 4) however, the same breakpoint reveals that mySubclass is now of type UIPickerView.
Adding an awakeFromNib to subclass A confirms that when running on the simulator A’s awakeFromNib gets called but not when running on the device.
Has anyone any idea why this might be?
Thanks in advance for any help,
Teo
An update:
After a couple of days of trying everything I eventually started trying some example projects on the device (which worked) and finally created a new project with the intention of migrating the code across in case the project itself had somehow gotten broken.
Having named the new project the same as the problematic one I noticed I couldn’t run it because of an UDID mismatch.
This caused me to have a look at the apps on the device through the Xcode organizer and noticed I had two of the same app on there. Deleting those made everything work again. Sigh. Glad it's sorted but if anyone has any idea exactly what happened I'd love to hear it.
Thanks for the eyeballs and sorry for asking an impossible problem although anyone reading this might now try removing the offending app from their device sooner rather than later.
Best, Teo