[英]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.