XCode error: "GDB:Program received signal: "SIGABRT"." - iphone

I am writing a simple application using cocos2d 0.99.5, the iPhone SDK is 4.2. I have run my application on device, but when I press the button to switch CCScenes, sometimes the app suddenly has no response and XCode received the error:"GDB:Program received signal:"SIGABRT". "
This issue happens by accident. You have to press the transition button many times to reproduce this bug.
I have learned that SIGABRT is raised by the abort() function. abort() is called by the standard assert() macro when an assertion fails. But there is no assert function in my program.
Could anyone tell me how does this problem happen, and how to solve this problem? I don't know what to do next now.

The problem has been solved. See the comments above.

If you get SIGABRT when app starts check your XIBS
Open each XIB
Check the Files Owner in each in the Identity Inspector
Make sure the class mentioned is the correct one and class exists (I had renamed some files and it failed)
Start with
MainWindow.xib
RootViewController.xib
Check Class names in Identity Inspector is ok.
Place breakpoints in
AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//if it enters this method then MainWindow.xib ok
STEP 2 - in didFinishLaunchingWithOptions place another breakpoint on
self.window.rootViewController = self.viewController;
In the RootViewController.m (or whatever sub class of VC self.viewController in AppDelegate is) place a break point in
viewDidLoad
If it crashes here check RootViewController.xib (or what ever class the first VC is)
and check Class is correct for Files Owner
iterate down through all View controllers
look for initWithNibName to find what XIBs are called.
In each check the Class name in the XIb is set correctly.

Related

Can't type text into UITextField or UITextView in iOS6

In one of my apps, when I try to edit (type some text) UITextField, UITextView or any other 'text-able' UIControl the cursor just blinks but no characters are typed in except BACKSPACE (possible only when I have some initial text in it), RETURN and switching character types. This goes to all controls across whole application.
Summary:
It happens only from iOS 6.0 (does not occur on iOS 5.x, 4.x neither Simulator or real device)
All delegate methods are fired (shouldBeginEditing: didBeginEditing:) except shouldChangeCharactersInRange:
isFirstResponder flag is behaving set correctly (shouldBeginEditing: logs NO, while didBeginEditing: logs YES correctly). It is also tested using logs that THE firstResponder IS the one already edited.
It repairs itself after any UIAlertView is presented to the user and dismissed. It doesn't matter if this alert is shown on the same screen (UIViewController view) or any other.
I have no idea how to even approach or debug this.
Where should I look for hints? Any experts of tracking responder chain related issues etc.?
How can I track down the UIAlertView's effect on the issue?
Depending on your implementation it's either the makeKeyAndVisible method of the UIWindow class that you forgot to call inside the - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method of the application delegate or corresponding Visible at Launch flag in your main interface xib file.
Cheers... :)
in my case, there is a 'visible at launch' on the main window, it was unchecked, which works on iOS5 only, needs to check it to make it working on iOS6.
In my situation I had an activity indicator that would pop up over the main window during periods of background activity. In this case the activity indicator view had its own window that was set to UIWindowLevelAlert. I was inadvertently calling makeKeyAndVisible on this window. Later on I would call resignKeyWindow. This used to work on iOS 4 and 5 but no longer worked in iOS 6. I discovered that this was not technically necessary as simply using window.hidden = Y/N worked just as well.
In my case I moved becomeFirstResponder for my UITextField from ViewDidLoad to ViewDidAppear and this solved my problem.

Xcode4, iOS: Certain parts of instance method being ignored, no errors, just passed by

new iOS guy here. I have a problem that Googling and searching on here has not shed any light on. I'm assuming this is basic. I have a simple app (app delegate and 1 view controller), and as part of it I'm using local notification. So, in the app delegate I use the 'didReceiveLocalNotification' to watch for the notifications. Depending on which one comes in, I then call one of several instance methods in my main view controller.
ie in the AppDelegate.m
- (void)application:(UIApplication *)application didReceiveLocalNotification: (UILocalNotification *)notification {
MyViewController* controller = [[MyViewController alloc] autorelease];
if ([[notification.userInfo objectForKey:#"id"] isEqualToString:#"myKey"]) {
[controller checkActive];
}
}
Through logging and watching some breakpoints, this is all working. If the app is in the background, the notification comes in, app opens, and the correct instance method is called.
What I cannot figure out at all is why some parts of the instance method are simply being passed by, with no effect. For a simple example, if we have this:
-(void)checkActive {
ViewThing.alpha = 1.0;
NSLog(#"checkActive ran");
}
The log statement will show up fine, but the ViewThing will not change. Elsewhere in the main view controller I'm calling the same checkActive method with no problems and it changes the ViewThing. (via another interface button IBAction method in that case).
There are no errors, no warnings, the console shows nothing, putting a breakpoint on ViewThing shows that it hits the line. I'm stumped, cannot see what is different from trying to calling the method from the delegate vs. on an IBAction.
Thanks for any tips!
If the alpha is not correctly changing there a few possible issues with 1 and 2 being the most likely.
ViewThing is nil. Reasons could be is the view unloaded and you set it to nil or checkActive was called before the outlets were set.
ViewThing.alpha is being set on a thread that is not the main thread. Attempting to change UI elements on a separate thread will caused undefined behavior such as never updating the change or taking an extended amount of time to update the change. You can check if it is the main thread using [NSThread isMainThread].
ViewThing is pointing a different view.
1 & 2 can easily be checked by logging view
NSLog(#"checkActive ran %#", ViewThing);

iOS add rootViewController to window causes delegate not found error

I'm creating an application that first loads a settings screen which displays a series of text fields and labels asking the user for input. This is all working fine.
What I then want to do is once this data has been input, it comes up with the main application interface.
What is happening though is that when I'm telling the application delegate to load the main view, it says that the viewController isn't key value complaint for the key delegate.
The code I'm using to create the viewController is:
CustomViewController *viewController = [[CustomViewController alloc] initWithNibName:#"CustomViewController" bundle:nil];
self.window.rootViewController = viewController;
If anyone thinks that UIWindow doesn't have a rootViewController property, please check the documentation. That's what I did, and it does have one.
Any help with figuring this out would be greatly appreciated.
For those that like full debug info, this is what I get from xcode.
2011-06-18 15:03:15.474 Some App[15596:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<CustomViewController 0x53368b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key delegate.'
Thanks,
Matt.
Most likely you try to use delegate somewhere in your xib file, but it doesn't exist in your CustomViewController class.
Check the connections in your nib file and remove the one that connects to the non existing delegate.
The rootViewController property was only recently introduced and might not be available on devices running an older version of iOS.
You want to have a UINavigationController as the root view controller of your application and subsequent pages you simply push onto it. If you don't want animation, then do animate:NO. If you don't need a navigation bar, then hide that as well.
It is generally preferable to use one of the existing container view controllers over swapping them out yourself.

Strange behavior with MainWindow.xib, app will not reach didFinishLaunchingWithOptions

I've started a new project in Xcode 3.2.5 where everything is being done in code. I don't want to use xibs this time though am looking forward to an integrated IB in Xcode 4.
The problem came up when I edited a string in a json file. On running the code I noticed the old string appearing even though the file was certainly changed, so I deleted my Library/Application Support/iPhone Simulator folder, expecting that my json changes would then be loaded to the bundle and the code would then see the expected value.
Then command-Y to build and run and it wouldn't run. Although there is no MainWindow.xib in my project folder my Info.plist file refers to MainWindow.xib. (I removed it, following the creation of this iPhone app with Xcode's New Project template) So I removed that key from the plist figuring the xib must have been sitting around in the app bundle after being installed in the simulator the first time I ran the app.
Then I ran the app again. No complaints, only a black screen - and a breakpoint in my app delegate, on didFinishLaunchingWithOptions is not being hit.
I have not changed anything in main.m. How can it be that the app is not launching?
I think something got messed up when you removed MainWindow.xib. Try these steps to see if it'll correct the problem.
Under the Project menu, choose Edit Active Target. Select the Properties tab and blank out the Main Nib File field. Close the Target Info window.
Under the Other Sources group and edit the main.m file. In the UIApplicationMain function call, change the last parameter to the name of your application delegate class.
int retVal = UIApplicationMain(argc, argv, nil, #"AppDelegate");
In your application delegate you need to create a window object. I do this in -applicationDidFinishLaunching:. If you defined anything else in your MainWindow.xib, you can probably create that here, too.
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
UIWindow *appWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = appWindow;
[appWindow release];
}
If this doesn't work, let me know and I can give you another way.
Sounds like you dont have a view connected in the XIB.
This is the same as #"AppDelegate" but you can write like this too :
(argc, argv, nil, NSStringFromClass([AppDelegate class]))

SIGABRT on iPhone when changing xib

I've just finished off an app for the iPhone which, until today, ran fine on the iPhone simulator and actual devices.
I tried changing the xib which is loaded in the applicationDidFinishLaunching method in my application delegate class - all I did was change the string in initWithNibName.
When I launch the app on the simulator, the Default.png image is shown, then the app crashes with an uncaught exception. When running on a device, the Default.png image is shown for about 10 seconds, the UI is never loaded and I get 'GDB: Program received signal: "SIGABRT".' on the Xcode status bar. Debugging shows that applicationDidFinishLaunching is never actually reached before the app crashes.
Setting the starting xib back to the original solves the issue, but now I've made a change and saved it in the Interface Builder and the app shows the same issues as above - I've made no code changes at all.
Is this a memory issue, or a known issue of a common mistake?
NOTE: I've made no code changes whatsoever, and the only changes I've made to the xib are cosmetic, the IBOutlets are all intact.
You probably changed an IBOutlet's name in code without changing it in the xib.
Sorry guys, my fault - it appears I deleted the MainWindow.xib file, so the delegate wasn't called on startup after I made changes. I've recreated it and linked it to the app delegate and UIApplication so now everything works.
You probably had IBOutlets connected from a xib back into your code, and those connections are broken.
You'll have to give us a little more detail on how the nibname string was changed. Did you rename your xib file?
I renamed some classes and Xibs and got SIGABRT into main.m
the Class name in Identity Inspector may be pointing to non existant class name
its because in the initWithNibName you are not giving the correct xib name so it will crash