从didFinishLaunchingWithOptions返回错误的应用程序崩溃[UIButton rac_signalForControlEvents:]

时间:2016-10-06 11:48:07

标签: ios objective-c cocoapods

didFinishLaunchingWithOptions方法返回时应用崩溃。

获取以下错误。

2016-10-06 17:09:34.717 Mamabear[2655:51800] [Crashlytics] Version 3.8.2 (118)
2016-10-06 17:09:34.732 Mamabear[2655:51800] Flurry: Starting session on Agent Version [Flurry_iOS_187_7.8.0] 
2016-10-06 17:09:34:738 Mamabear[2655:70b] Logging Initialized.
2016-10-06 17:09:34:738 Mamabear[2655:70b] Util Logging Initialized.
2016-10-06 17:09:34:738 Mamabear[2655:70b] Logging setup
2016-10-06 17:09:34.789 Mamabear[2655:51800] idfa class missing, won't collect idfa
2016-10-06 17:09:34.792 Mamabear[2655:51800] +[NSDate act_secondsSince1970]: unrecognized selector sent to class 0x10ad3ae08
2016-10-06 17:09:34.799 Mamabear[2655:51800] WARNING: GoogleAnalytics 3.08 void GAIUncaughtExceptionHandler(NSException *) (GAIUncaughtExceptionHandler.m:49): Uncaught exception: +[NSDate act_secondsSince1970]: unrecognized selector sent to class 0x10ad3ae08
2016-10-06 17:09:34.807 Mamabear[2655:51873] CoreData: warning: Unable to load    class named 'GAIProperty' for entity 'GAIProperty'.  Class not found, using default NSManagedObject instead.
2016-10-06 17:09:34.811 Mamabear[2655:51873] CoreData: warning: Unable to load  class named 'GAIHit' for entity 'GAIHit'.  Class not found, using default NSManagedObject instead.
2016-10-06 17:09:34.883 Mamabear[2655:51800] -[UIButton          rac_signalForControlEvents:]: unrecognized selector sent to instance       0x7ffc70cc5770
libc++abi.dylib: terminate_handler unexpectedly threw an exception

我也在项目中使用多个pod文件。

  

我也有关于NSDate的代码。请看这个。

-(void)saveCurrentTimeStamp{

    NSDate *ExpDate=[NSDate date];
    [[NSUserDefaults standardUserDefaults] setObject:ExpDate forKey:@"currentTimeStamp"];
    [[NSUserDefaults standardUserDefaults]synchronize];

    NSLog(@"saveCurrentTimeStamp....%@",[[NSUserDefaults standardUserDefaults]objectForKey:@"currentTimeStamp"]);
}
  

didfinishlauch代码。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
   {

self.timeNow=0;
[[NSUserDefaults standardUserDefaults]setInteger:0 forKey:@"countAdd"];
[[NSUserDefaults standardUserDefaults]synchronize];
//[self.timerForInterstitialAd invalidate];
//self.timerForInterstitialAd = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updatetimerForInterstitialAd:) userInfo:nil repeats:YES];

[[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"fstTimeLoad"];
[[NSUserDefaults standardUserDefaults]synchronize];

adZones = [NSArray array];

[Crashlytics startWithAPIKey:@"50a6f020b3dff7ef81c7b6e5fa4ca9f2a2694c2a"];

[Flurry setCrashReportingEnabled:NO];
[Flurry startSession:@"2R4ZDZQH4F8QYYN2V8PC"];
[Flurry setBackgroundSessionEnabled:NO];

[Ouralabs setAppVersion:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
[Ouralabs initWithKey:@"7fbe83476d77bfcc71f14d104585bc0b"];

_fileLogger = [Util setupLogging];
[self setupLogging];

OULogInfo(@"AppDelegate", @"App started");
DDLogVerbose(@"Logging setup");

[self configureURLCache];

[self migrateUserDefaultsToGroupLevel];

//**************for debugging, write console to file
// [self redirectConsoleLogToDocumentFolder];
//**************

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

[MMSDK initialize];

//    [self initAdAdaptedSDK];

NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
                            //                                [UIColor whiteColor], NSForegroundColorAttributeName,
                            [UIFont fontWithName:@"Avenir" size:16.0f], NSFontAttributeName, nil];
[[UIBarButtonItem appearance] setTitleTextAttributes: attributes
                                            forState: UIControlStateNormal];

//--------------------------------------------------------------------------------------------
// Set userdefaults with the default values
//--------------------------------------------------------------------------------------------

// CFBundleVersion returns build number
//  NSString *bundleVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
//  NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];

// CFBundleShortVersionString returns version in General identify settings
NSString *bundleVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];

[MAMABEAR_GROUP_DEFAULTS setObject:[NSString stringWithFormat:@"%@", bundleVersion] forKey:@"version"];


//--------------------------------------------------------------------------------------------
// Environment Settings
//--------------------------------------------------------------------------------------------

     #if USE_PRODUCTION_ENVIRONMENT
// ************************************** PRODUCTION ************************************** \\
//--------------------------------------------------------------------------------------------
[MAMABEAR_GROUP_DEFAULTS setObject:@"https://api.mamabearapp.com" forKey:MBMainServerURL];
[MAMABEAR_GROUP_DEFAULTS setObject:@"https://api.mamabearapp.com" forKey:MBCoordinateServerURL];
[MAMABEAR_GROUP_DEFAULTS setObject:@"https://api.mamabearapp.com/time" forKey:MBReachabilityServerURL];
[MAMABEAR_GROUP_DEFAULTS setObject:@"https://analytics.mamabearapp.com/v1/" forKey:MBAnalyticsServerURL];

//--------------------------------------------------------------------------------------------
    #else
// ****************************************** UAT ***************************************** \\
//--------------------------------------------------------------------------------------------
[MAMABEAR_GROUP_DEFAULTS setObject:@"http://api-uat.mamabearapp.com" forKey:MBMainServerURL];
[MAMABEAR_GROUP_DEFAULTS setObject:@"http://api-uat.mamabearapp.com" forKey:MBCoordinateServerURL];
[MAMABEAR_GROUP_DEFAULTS setObject:@"http://api-uat.mamabearapp.com/time" forKey:MBReachabilityServerURL];
[MAMABEAR_GROUP_DEFAULTS setObject:@"https://analytics-uat.mamabearapp.com/v1/" forKey:MBAnalyticsServerURL];
//--------------------------------------------------------------------------------------------
      #endif

// ************************************ Other Environments *********************************** \\
//[MAMABEAR_GROUP_DEFAULTS setObject:@"172.16.168.99:8080/mamabear" forKey:MBMainServerURL]; //Nate LOCAL Environment
//[MAMABEAR_GROUP_DEFAULTS setObject:@"10.10.0.134:8080/mamabear" forKey:MBMainServerURL];   //Mac mini LOCAL Environment
//[MAMABEAR_GROUP_DEFAULTS setObject:@"ec2-23-22-115-247.compute-1.amazonaws.com/mamabear" forKey:MBMainServerURL]; // Uncomment for QA server

//--------------------------------------------------------------------------------------------
// AFNetworking Reachability
//--------------------------------------------------------------------------------------------

NSURL *reachabilityServerURL = [NSURL URLWithString:[MAMABEAR_GROUP_DEFAULTS objectForKey:MBReachabilityServerURL]];
AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:reachabilityServerURL];

[manager.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {

    //NSLog(@"Reachability (%@): %@",[MAMABEAR_GROUP_DEFAULTS objectForKey:MBReachabilityServerURL],
    //                             AFStringFromNetworkReachabilityStatus(status));
}];

[manager.reachabilityManager startMonitoring];

[[MBAnalyticsHTTPClient sharedClient] getConfigWithCompletion:^(BOOL active, NSError *error) {

    if (error) {

        [MAMABEAR_GROUP_DEFAULTS setBool:FALSE forKey:@"MBAnalyticsActiveFlag"];
        [MAMABEAR_GROUP_DEFAULTS synchronize];
        return ;
    }

    [MAMABEAR_GROUP_DEFAULTS setBool:active forKey:@"MBAnalyticsActiveFlag"];
    [MAMABEAR_GROUP_DEFAULTS synchronize];

    if (active) {

        NSString *uniqueAnalyticsId = [MAMABEAR_GROUP_DEFAULTS objectForKey:@"MBAnalyticsUniqueId"];
        if (!uniqueAnalyticsId || [uniqueAnalyticsId isEqualToString:@""]) {

            [[MBAnalyticsHTTPClient sharedClient] getUniqueDeviceIdWithCompletion:^(NSString *uniqueId, NSError *error) {

                if (error) {

                    [MAMABEAR_GROUP_DEFAULTS setObject:@"" forKey:@"MBAnalyticsUniqueId"];
                    [MAMABEAR_GROUP_DEFAULTS synchronize];
                }

                if (uniqueId && ![uniqueId isEqualToString:@""]){

                    [MAMABEAR_GROUP_DEFAULTS setObject:uniqueId forKey:@"MBAnalyticsUniqueId"];
                    [MAMABEAR_GROUP_DEFAULTS synchronize];
                }
                else {
                    [MAMABEAR_GROUP_DEFAULTS setObject:@"" forKey:@"MBAnalyticsUniqueId"];
                    [MAMABEAR_GROUP_DEFAULTS synchronize];
                }
            }];
        }

                    }

        [[MBAnalyticsHTTPClient sharedClient] updateDevice:device completion:^(BOOL status, NSError *error) {

            if (error) {

                OULogError(NSStringFromClass([self class]), @"Failed to update device for analytics.", @{@"error": error.userInfo.debugDescription});
            }

            if (status) {

                OULogInfo(NSStringFromClass([self class]), @"Updated device for analytics.");
            }
            else {

                OULogError(NSStringFromClass([self class]), @"Failed to update device for analytics. Status not 200.");
            }
        }];
    }
}];

//--------------------------------------------------------------------------------------------
// Initialize Batch ID (idk if we need this)
//--------------------------------------------------------------------------------------------
if ([MAMABEAR_GROUP_DEFAULTS objectForKey: @"batchId"] == nil)
{
    [MAMABEAR_GROUP_DEFAULTS setObject:@"1" forKey: @"batchId"];
}
[MAMABEAR_GROUP_DEFAULTS synchronize];


//--------------------------------------------------------------------------------------------
// When lauching, check for the phone number in user defaults and set keychain. (Steve Wilson)
//--------------------------------------------------------------------------------------------
if (!phoneNumberItem)
{
    phoneNumberItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"MamaBearApp_Creds" accessGroup:nil];
}
if ([MAMABEAR_GROUP_DEFAULTS objectForKey:@"phoneNumber"] && ![phoneNumberItem objectForKey:(__bridge id)kSecAttrAccount])
{
    //NSLog(@"****Setting keychain values from UserDefaults");
    [self setBackgroundKeychainValues:[MAMABEAR_GROUP_DEFAULTS objectForKey:@"phoneNumber"] :[MAMABEAR_GROUP_DEFAULTS objectForKey:@"coordinateServerUrl"] :[MAMABEAR_GROUP_DEFAULTS objectForKey:@"userId"] :[MAMABEAR_GROUP_DEFAULTS objectForKey:@"name"]];
}


//--------------------------------------------------------------------------------------------
// Initialize Instagram SDK
//--------------------------------------------------------------------------------------------
self.instagram = [[Instagram alloc] initWithClientId:APP_ID delegate:nil];


//--------------------------------------------------------------------------------------------
// Initialize Cubs & Guardians
//--------------------------------------------------------------------------------------------


//--------------------------------------------------------------------------------------------
// Set up the CLController delegate so we can send to the server.
//--------------------------------------------------------------------------------------------
locationUpdateController = [[LocationUpdateController alloc] init];


//NSUserDefaults *InterstitialObject;
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"InterstitialCount"];
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"InterstitialTime"];

//--------------------------------------------------------------------------------------------
// Set up the alert badge
//--------------------------------------------------------------------------------------------
alertCountOBJ = [AlertCount sharedAlertCounts];
application.applicationIconBadgeNumber = 0;


//--------------------------------------------------------------------------------------------
// Set up the Master View Controller
//--------------------------------------------------------------------------------------------
MBWelcomeViewController *masterVC = [[MBWelcomeViewController alloc] init];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterVC];
// navigationbar
//    self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];


//--------------------------------------------------------------------------------------------
// Register for Remote Notifications
//--------------------------------------------------------------------------------------------

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge |
                                                                                     UIUserNotificationTypeSound |
                                                                                     UIUserNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];

//--------------------------------------------------------------------------------------------
// Handle Launching from a notification
//--------------------------------------------------------------------------------------------
UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif)
{
    //NSLog(@"Recieved Notification %@",localNotif);
}


//--------------------------------------------------------------------------------------------
// Initialize Background Fetch Interval if iOS7 or greater
//--------------------------------------------------------------------------------------------
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1)
{
    //set minimum number of seconds between background.  This will call performFetchWithCompletionHandler
    [[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:300];
}


//--------------------------------------------------------------------------------------------
// App was launched from a Location Update (Steve Wilson)
//--------------------------------------------------------------------------------------------
if ([launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey])
{
    DDLogVerbose(@"************MamaBear Re-Launched from Background - LOCATION UPDATE*********");

    CLController = [CoreLocationController sharedInstance];
    [CLController startMonitoringSignificantLocationChanges];

    [MAMABEAR_GROUP_DEFAULTS synchronize];

    __block UIBackgroundTaskIdentifier bgTaskEnter;
    bgTaskEnter = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{

        [CLController stopUpdatingLocation];
        [CLController startMonitoringSignificantLocationChanges];
        DDLogVerbose(@"****App Relaunched --> GPS Background Task Out of Time*******");
        [[UIApplication sharedApplication] endBackgroundTask:bgTaskEnter];
        bgTaskEnter = UIBackgroundTaskInvalid;
    }];

    // Start the long-running task on an expiration.
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        DDLogVerbose(@"****App Relaunched --> Starting background GPS on Timeout*****");
        [CLController startUpdatingLocation];

        [[UIApplication sharedApplication] endBackgroundTask:bgTaskEnter];
        bgTaskEnter = UIBackgroundTaskInvalid;
    });

}


//--------------------------------------------------------------------------------------------
// Initialize Appearance
//--------------------------------------------------------------------------------------------
[[[self navigationController] navigationBar] setBackgroundImage: [UIImage imageNamed:@"nav_bar_orange.png"]
                                                  forBarMetrics: UIBarMetricsDefault];

      [[UINavigationBar appearance] setBackgroundImage: [UIImage imageNamed: @"nav_bar_orange.png"]
                                   forBarMetrics: UIBarMetricsDefault];
// blackcolor
[[UINavigationBar appearance] setTintColor: [UIColor whiteColor]];

NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowOffset = CGSizeZero;

NSDictionary *titleTextAttributes =
@{
  NSForegroundColorAttributeName: [UIColor whiteColor],
  NSFontAttributeName: [UIFont fontWithName:@"Avenir-Light" size:28],
  NSShadowAttributeName: shadow
  };
[[UINavigationBar appearance] setTitleTextAttributes:titleTextAttributes];

if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1)
      {
    UIImage *backButtonImage = nil;
    backButtonImage = [[UIImage imageNamed:@"iOS_blank_back_button"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 10) resizingMode:UIImageResizingModeStretch];
    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
       }






//--------------------------------------------------------------------------------------------
// MamaBear BI Recording
//--------------------------------------------------------------------------------------------
if ([MAMABEAR_GROUP_DEFAULTS objectForKey:@"userId"] != nil && [MAMABEAR_GROUP_DEFAULTS objectForKey:@"userId"] != 0)
{
    NSDictionary *parameters = @{@"userId": [MAMABEAR_GROUP_DEFAULTS objectForKey:@"userId"], @"slat": [NSString stringWithFormat: @"%.07f",CLController.locationManager.location.coordinate.latitude], @"slng": [NSString stringWithFormat: @"%.07f",CLController.locationManager.location.coordinate.longitude]};

    [[MBMainHTTPClient sharedClient] sendForegroundStatus:parameters completion:nil];

    if (![[MAMABEAR_GROUP_DEFAULTS objectForKey:@"role"] isEqualToString: @"mama"])
    {
        application.applicationIconBadgeNumber = 0;
    }
}
else
{
    [MAMABEAR_GROUP_DEFAULTS setObject: [NSDate date] forKey: @"foregroundTime"];
}


//--------------------------------------------------------------------------------------------
// Initialize Google Analytics
//--------------------------------------------------------------------------------------------
[GAI sharedInstance].dispatchInterval = 20;
[GAI sharedInstance].trackUncaughtExceptions = YES;
self.tracker = [[GAI sharedInstance] trackerWithTrackingId:kTrackingId];


//--------------------------------------------------------------------------------------------
// HasOffers SDK Integration
//--------------------------------------------------------------------------------------------
NSString * const MAT_CONVERSION_KEY = @"83020f2524e98767f2319ed4ca09abcd";
NSString * const MAT_ADVERTISER_ID = @"13098";

[MobileAppTracker initializeWithMATAdvertiserId:MAT_ADVERTISER_ID MATConversionKey:MAT_CONVERSION_KEY];
[MobileAppTracker setAppleAdvertisingIdentifier:[[ASIdentifierManager sharedManager] advertisingIdentifier]
                     advertisingTrackingEnabled:[[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]];

//--------------------------------------------------------------------------------------------
// Google Adwords Tracking
//--------------------------------------------------------------------------------------------
    [ACTConversionReporter reportWithConversionID:@"997118172" label:@"yKOXCIzOgAsQ3KG72wM" value:@"0.000000" isRepeatable:NO];



return YES;
    }

0 个答案:

没有答案
相关问题