最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]iOS如何调试app启动时的代码

iOS crifan 4101浏览 0评论

iOS的app,想要调适启动时的代码AppDelegate.swift的:

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        //handle user tap remote notification
        if let options = launchOptions {
            if let notification = options[UIApplicationLaunchOptionsLocalNotificationKey] as? UILocalNotification {
//            if let notification = options[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSNotification {
                if let userInfoDict = notification.userInfo {
//                if let userInfoDict = notification.object {
                    print("userInfoDict=\(userInfoDict)")
                   
                    gCurUserItem.needAutoLogin = true
                   
                    //delay to save message list
                    delayDispatchInBackgroundThread(5, thingsTodo: {
                        SingletonLoginVC().loginAction()
                    })
                }
            }
        }

想要知道启动时传入的参数

尤其是用户点击远程推送的消息时传入的参数

ios debug app launch

ios – how to debug app when launch by push notification in xcode 5 – Stack Overflow

xcode – Attach debugger to IOS app after launch – Stack Overflow

手机插入Mac

选择Target为iPhone6真机

开始调试

iPhone6中kill掉app程序

然后此处是远程发送消息,点击推送消息,启动app

[多图]

然后Xcode中果然可以调试到app了:

改了点代码后,再去调试,终于看到传入的远程推送的参数了:

[总结]

想要调试iOS的app在启动时候的过程,则可以:

1.通过Xcode去调试,使用iOS模拟器或者真机,得知显示出来的app的名字

2.然后Xcode-》Debug-》Attach to Process By PIDs or Name

然后在PID or process name中输入你的app名

3.然后去启动app

4.Xcode即可开始调试app,比如此处调试运行对应的didFinishLaunchingWithOptions

转载请注明:在路上 » [已解决]iOS如何调试app启动时的代码

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
85 queries in 0.208 seconds, using 22.05MB memory