简体   繁体   English

运行应用程序时,xCode失去与设备的连接

[英]xCode loses connection to device when running app

I have been building an iOS app and have been testing it both on the simulator as well as my iPad. 我一直在开发一个iOS应用,并在模拟器和iPad上都对其进行了测试。 Everything was working perfectly until- 一切运行良好,直到-
when i recently added the code to register for push notifications to my AppDelegate.m file. 当我最近添加代码以将推送通知注册到我的AppDelegate.m文件时。 Now when I try to run the app on the device the app lingers on the splash screen for a while and then xCode comes up with the following error. 现在,当我尝试在设备上运行该应用程序时,该应用程序会在启动屏幕上停留一段时间,然后xCode出现以下错误。

process launch failed: timed out waiting for app to launch 进程启动失败:等待应用启动超时

and here's the code i added, Just in case : 这是我添加的代码,以防万一:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
 // Override point for customization after application launch.

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
   if ([[UIApplication sharedApplication]respondsToSelector:@selector(registerUserNotificationSettings:)])
   {
      UIUserNotificationType userNTypes = (UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound);

      UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNTypes categories:nil];

        NSLog(@"sherikkum registering 8.xx...");

      [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
      [[UIApplication sharedApplication] registerForRemoteNotifications];
   }
   else
   {
      [[UIApplication sharedApplication] registerForRemoteNotificationTypes: 
      (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
#else
   [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
   (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

#endif

return YES;
}

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
  NSLog(@"My token is: %@", deviceToken);

  //I added this alert coz i couldnt view NSLogs - coz my xcode wont connect
  UIAlertView *tokenalert = [[UIAlertView alloc] initWithTitle:@"Token"
                                                     message:[NSString stringWithFormat:@"%@",deviceToken]
                                                    delegate:nil
                                           cancelButtonTitle:@"OK"
                                           otherButtonTitles:nil, nil];
  [tokenalert show];
}

- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
   NSLog(@"Failed to get token, error: %@", error);
}

Thanks 谢谢

You may be using a Distribution Certificate instead of Developer Certificate while running your app. 您可能在运行应用程序时使用分发证书而不是开发人员证书。 Change it in Target => Build Settings=> Code Signing . Target => Build Settings => Code Signing中进行更改。

在此处输入图片说明

If you are using a provisioning profile created from a distribution certificate, your code will not run on a device running from xcode. 如果您使用的是通过分发证书创建的配置文件,则您的代码将无法在通过xcode运行的设备上运行。 You need to use a provisioning profile created from a development certificate. 您需要使用从开发证书创建的供应配置文件。 For further details on provisioning profiles and certificates please read Apple's Documentation. 有关配置文件和证书的更多详细信息,请阅读Apple的文档。

退出模拟器,清理您的应用程序,然后再次运行。它运行正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 xcode 在物理设备上运行应用程序 - Running app on physical device with xcode 不是在我的设备上运行Xcode应用程序吗? - Running Xcode app in not my device? 在iOS设备Xcode 5上运行时,应用程序名称显示为空白 - App name showing as blank when running on iOS device Xcode 5 错误:在设备上运行的Xcode中的连接中断 - Error: CONNECTION INTERRUPTED in Xcode running on Device 当应用程序在设备上的 Xcode 中运行时,MKMapView 使应用程序崩溃,但如果通过应用程序图标点击在设备上运行则不会 - MKMapView crashes the app when app is run in Xcode on a device but not if running on device by application icon tap 通过QuickTime录制屏幕时,Xcode失去与iPad的连接 - Xcode loses connection to iPad when recording its screen via QuickTime 从Xcode在设备上运行应用程序时,以前的应用程序安装会如何? - What happens to previous app installs when running an app on a device from Xcode? 在设备上运行时,日志未显示在xcode中 - Logs not showing in xcode when running on device Xcode - 仅在设备上运行时出现位码错误 - Xcode - Bitcode error only when running on device 调试/运行iOS8 App Today Extension时,Xcode将多个包含应用程序安装到设备上 - Xcode installs multiple containing apps onto device when debugging/running iOS8 App Today Extension
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM