XCode debug main app & today extension at same time - ios

I want to get main app, today-extension debug info at same time.
I run the scheme main app and got only main app debug info.
I try the attach by Process Identifier(today-extension id) but it's blank when I select today-extension process.
What should I do?

Basically select the Watch App as the scheme in xcode, hit build+run
which will build the iOS app and WatchKit app, install the WatchKit
app on to the Watch and attach the debugger to the WatchKit Extension.
Then in xcode select the iOS app in the scheme selector and select the
iPhone as the target device, launch the iOS app by tapping the app
icon on the phone and in xcode in the menu bar select "Debug > Attach
to Process" and select your app in the list. This should result in
having xcode attached to both processes at the same time. If you want
to debug something early in the iOS app's lifecycle you can select
"Debug > Attach to Process by PID or Name..." and type in the process
name of the iOS app prior to launching it manually. This way the
debugger will be attached right when the app launches.
From Apple Developer site.
Note that they discuss WatchKit but it´s the same for Today Extension.

Related

Testing a closed ios app

I'm currently trying to handle different application states (closed, background or in a different tab of the app) however when I try to test how the app works when it is closed and receives a push notification(double click home and force close the app then reopen it) I'm not sure where I'm going wrong in the code. Since I'm reopening the app from the phone itself and not xcode I can't test to see which method isn't being reached because no output is available in the console. Is there any way to test a situation like this or simulate a force close event in xcode so that when i re run the app on the phone it also launches in xcode?
I appreciate any responses.
Cheers!
If you force close app or stop (from xcode) then it close the connection with xcode. Then if you open it from phone then it will not make connection with xcode. You must run it from xcode. And there is no difference in opening app from phone or running from xcode. App's flow will be same in both case. So what you want to test that which methods get calls and in which sequence that you can check by rerunning the project.
Update:
Select the Scheme on the toolbar (just left beside from your device or simulator list)
Choose Edit Scheme
Select Run in the left panel
For the Launch option, select Wait for executable to be launched
Refer this link for more details
Since I'm reopening the app from the phone itself and not xcode I can't test to see which method isn't being reached because no output is available in the console.
In Xcode, hold down the Option key and choose Product->Run..., and then edit the Run scheme to use the "Wait for executable to be launched" option. You should then be able to choose Run in Xcode, and then open your app by some other means, such as responding to a notification, and Xcode will still connect and let you debug.
To debug the process after restarting the app again, attach the Xcode debug console to the running process.
In Xcode do:
Debug > Attach to process > [select your process]

How can I debug an iOS app executed in mobile not launched by Xcode?

I am developing an application for iOS in Objective C with Xcode. This application schedules local push notifications every 6 hours and it is crashing when I open the push notifications.
I need to debug the error to solve it. I can have the mobile connected to Xcode, but as the app is executed from local push notification I can't see the error messages on my Xcode debug console, as I haven't launched my app from Xcode.
Is there a way to have the iOS device connected to my Mac and see what error is happening?
I know that I can go to the mobile settings to view logs, but these logs are too ambigous for me aren't giving any error.
In addition to opening the console log as described by #saurabhgoyal you can tell Xcode to wait for your app to launch and then attach the debugger to it when it does.
Select the scheme you're using to build your app, select edit scheme, and click on the run icon. Then Look for a pair of radio buttons titled "Launch" and select the one with the name "Wait for executable to be launched."
Then when you run your app in Xcode it builds it and installs it on the device but does not launch it.
When your notification fires and the app launches the debugger attaches to your app and you can debug as normal (except that NSLog statements don't print to the debug console any more - an annoyance.)
Yes there is a way to see device logs on Mac.
Connect your iOS device to the Mac system using USB
Launch Xcode–>Window–>Devices
Select your device from the left panel
Now you can see the logs on the screen including the background activities.
In order to save the running logs.
Reproduce the issue or start working on your device on a the app you wanted to capture the logs. After the issue is reproduced click on the Save Console icon bottom right corner Xcode screen
For more details please visit this link
Hope this Helps!
Check your crash log
1.Launch Xcode on your desktop machine.
2.Open the Xcode Devices window. (Window menu -> Devices and Simulators, or Cmd-Shift-2.)
3.Find your device in the left sidebar, then select “device logs”.
Choose a Chrome crash (or multiple crashes) and select “Export” at the bottom of the Organizer window.

Stop xcode before run?

I have a bug which occurs because an user installs the app but doesn't run it. He adds some files via itunes and only then runs the installed app.
So I need to repeat the same actions. Breakpoints should help but I don't know where to insert them. NOTE: main.m is not the starting point so I can't just place breakpoint in it - some code is executed before it (maybe because of submodules).
How to solve this issue?
Edit the scheme, in the Run Info find the Launch section at the bottom and select Wait for executable to be launched.
Now, when you run, Xcode will install the app and wait. You can then do whatever you want with the device / iTunes and when you manually start the app Xcode will kick in.
You can build your app from the "Product" menu without running. Then open Xcode's "Devices" window, select your target device, and drag your app from the "Products" section of the Project navigator to the Installed Apps part of the device window. That should get you an installed build that hasn't been launched.

Watchkit app extension not launching

My watchkit app extension has suddenly stopped launching. I have a breakpoint in (void)awakeWithContext:(id)context, but that does not get called.
I am running the WatchKit app extension, and all the certificates are in order. I have a 42mm screen set as the external hardware display. I have tried re-starting XCode.
I had during the course of development cleared my DerviedData. This removes the WatchKit extension from the list of embedded binaries in the app. To fix this, you have to
1. Rebuild the project.
2. Click on Add Embedded Binaries, select the "App Name WatchKit extension.appex" file.
This solved the problem for me.

How to debug app when launch by push notification in Xcode

I am using Xcode 5. I am working with push notifications in iOS. I am getting satisfying results for background mode and foreground mode that can be debugged easily on an iOS device.
But problem is when app is in closed state and launched by push notification tap but I don't know how to debug in this situation. I know the solution for Xcode 4 but not for Xcode 5.
So is there any solution for Xcode 5 and debugging the app when launching it by push notifications?
Provide steps to debug in this situation.
Edit your project scheme and set "Launch" to "Wait for *.app to be launched manually".
Then Run the project or hit "cmd+R". The app will not be launched automatically, but the debugger will attach to the process as soon as the app launches. So send your test push notification, and launch the app from the push.
Here you go!
it takes few seconds:
1- go to edit schema
2- select run section from left list
3- then in info tab goto part launch options
4- select option: wait for executable to be launched
5- then close the window
6- run the app : the app will build but not launched because it's waiting for you to launch the app manually
7- at this time send your notification to your device
8- tap on the notification and your app will launched and the debugger goes to breakpoints you attached in lines of code
You can also connect to the app in debug mode using the debug menu of Xcode : Debug > Attach to process by PID or name (start typing the name of your target and Xcode will autocomplete for you)
As soon as the app is launched or if it is already launched, the debugger will be plugged. Really helpful in two cases :
notification/location debug
you didn't launch the app through Xcode but you have a strange bug you want to understand

Resources