是否有可能在Xcode中使用adhocconfiguration文件debugging我的应用程序?

如您所知,我将Signingdebuggingconfiguration文件设置为Adhocconfiguration文件。

如果我运行我的应用程序到我的iPhone,所以我可以使用我的iPhone接收我的后台的远程推送通知(我的后台使用分布configuration文件,所以我必须使用adhoc或分布configuration文件)。

但每次运行应用程序(使用Adhocconfiguration文件)到我的iPhone,它将断开连接:

无法启动“项目名称”
进程启动失败:无法获得进程xxx的任务

所以,我不能debugging我的应用程序(使用Adhocconfiguration文件)与真正的设备在我的Xcode,有没有办法做到这一点?

我的要求是去一个特殊的vc ,我didFinishLaunchingWithOptions方法中的代码如下:

 // If application is launched due to notification,present another view controller. UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if (notification) { [SVProgressHUD showSuccessWithStatus:[NSString stringWithFormat:@"success"]]; PushDetailViewController *detail_push = [[PushDetailViewController alloc] init]; detail_push.isPresentCome = YES; PushModel *new_model = [PushModel initPushModelWithDic:notification.userInfo]; if (new_model) { detail_push.pushModel = new_model; [self.window.rootViewController presentViewController:detail_push animated:NO completion:nil]; } }else { //LMLSystemAlertControllerShowSingelButtonWithMessageWL(@"没有notification 信息", @"确定"); } return YES; 

而我不知道notification.userInfo是什么,所以我想要debugging它,如果我使用SVProgressHUD警告信息,我的应用程序将崩溃,因为我的iPhone与Xcode无关,我不能得到错误信息。

所以,有一些问题:

  1. 是否有可能debugging我的应用程序(使用adhocconfiguration文件)与我的iphone在Xcode?
  2. notification.userInfo的内容是什么,是从我的后台状态推送的内容吗?
  3. 我的推送内容(从我的后台状态)是哪里?

尝试 – 1

我试图提醒notification.userInfo ,但如果我访问notification.userInfo ,我的应用程序将崩溃,所以我不能得到它,不知道它是什么。

尝试 – 2

我也使用Xcode – > Deveice来查找NSLog信息,什么也找不到:

在这里输入图像说明

用于debuggingUserInfo:将NSLOG用于打印UserInfo并检查值是否正确。 我知道你不能在Xcode控制台中检查NSLOG,但你可以在Xcode中检查设备中的NSLOG选项。 Xcode – >窗口 – >设备 – >在左侧面板中select您的设备。 在这里你可以看到你所有的日志。

根据UserInfo的详细信息,您可以validation您的代码是否正确。

对于在Adhoc构build模式下推送通知载荷,您可以简单地把UIAlertView放在你想要的位置。 并可以看到你的iPhone屏幕上的输出。 🙂

例如你的情况。

 NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if (notification) { NSDictionary *apsInfo = [notification objectForKey:@"aps"]; // Put AlertView here UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"NotificationPayload" message:[NSString stringWithFormat:@"%@",apsInfo] delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil]; [alert show]; [SVProgressHUD showSuccessWithStatus:[NSString stringWithFormat:@"success"]]; PushDetailViewController *detail_push = [[PushDetailViewController alloc] init]; detail_push.isPresentCome = YES; PushModel *new_model = [PushModel initPushModelWithDic:apsInfo]; if (new_model) { detail_push.pushModel = new_model; [self.window.rootViewController presentViewController:detail_push animated:NO completion:nil]; } } else { //LMLSystemAlertControllerShowSingelButtonWithMessageWL(@"没有notification 信息", @"确定"); } return YES; 

完成debugging后,请勿忘记注释或删除此AlertView代码。

我不确定是否正确理解了您的问题,但听起来像您在testing推送通知时遇到了问题,因为您使用的是“生产”推送证书,因此尝试使用Ad-Hoc置备configuration文件进行debugging为了接收通知?

如果是这种情况,那么解决办法是更新您的推送证书。 我们不再需要为“沙箱”使用一个证书,而另一个用于“生产” – 新的推送证书在两种环境中均有效。 因此,您应该能够使用开发configuration文件在Xcode中正常构build和debugging您的应用程序,并且仍然会收到通知。

现在在“沙盒和生产”