0

Thanks for reading. I solved the problem. The reason was the following:

In the info.plist file I altered the row "Localization native development region" to "Germany". After that the app no longer ran on the iphone but in the simulator. After resetting it to "en" it worked again on the iphone device.

Does anybody have an idea why it does not run on the iphone for this particular case?

I have a really really strange problem. I can run my iPhone app in the simulator but not on my iphone device. If I run it on my device it cashes on the following line

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); <-- crashes here
    }
}

In my AppDelegate.m file I put a NSLog in each method:

#import "AppDelegate.h"
#import <CoreLocation/CoreLocation.h>

@implementation AppDelegate

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSLog(@"didFinishLaunchingWithOptions");
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    NSLog(@"applicationWillResignActive");
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    NSLog(@"applicationDidEnterBackground");
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    NSLog(@"applicationWillEnterForeground");
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    NSLog(@"applicationDidBecomeActive");

    if( ![[Logic si] network_is_available] ) {
        [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"AlertView_error_title", @"") message:NSLocalizedString(@"No_Internet_connection_available",@"") delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil] show];
    }

    if( ![CLLocationManager locationServicesEnabled] ) {
        NSLog(@"not locationServicesEnabled");
        [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"AlertView_error_title", @"") message:NSLocalizedString(@"No_location_management_available",@"") delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil] show];
    } else {
        NSLog(@"locationServicesEnabled");
    }
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    NSLog(@"applicationWillTerminate");
}

@end

Nothing is printed to the console if I run the app it immediatly crashes. Other apps I programmed work fine when started from within xcode on the iphone.

I know this could be everything, but do you have any ideas what might cause this problem?

toom
  • 12,864
  • 27
  • 89
  • 128
  • Where is the coding have to be in didFinishLaunchingWithOptions: in this method? – Dinesh Raja Apr 29 '12 at 17:26
  • did you add an Exception Breakpoint in Xcode? Also try to enable zombie objects. This could improve the backtrace quality – Jonathan Cichon Apr 29 '12 at 17:27
  • Yes I did add Exception Breakpoints in xcode. I'm quite shure this has nothing to do with my code. But with some kind of configuation rather. – toom Apr 29 '12 at 18:02

1 Answers1

0

You have nothing in didFinishLaunchingWithOptions:. This is where you need to create your window. Start a fresh new project, Master-Detail for example, and see how the window is created in this delegate.

Example

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    
    DashboardViewController * dashboard = [[DashboardViewController alloc] init];
    self.navigationController = [[UINavigationController alloc] initWithRootViewController:dashboard];       
    self.window.rootViewController = self.navigationController;    

    [self.window makeKeyAndVisible];

    return YES;
}
WrightsCS
  • 50,551
  • 22
  • 134
  • 186
  • Thanks for the answer. I don't think that's the reason. Firstly because the app runs in the simulator anyway and secondly I would at least see the output of NSLog(@"didFinishLaunchingWithOptions"); on the console. But absolutly nothing happens the console remains black and the app crashes – toom Apr 29 '12 at 18:01
  • You aren't creating any windows... how do you expect to see something? In the Simulator as you claim, what do you see, because your code contradicts that. – WrightsCS Apr 29 '12 at 22:49