Xcode Debugger Doesn't Begin Session When App Runs - xcode

I'm using version 12.4 of Xcode, and when I run my app to test it, the debugger never starts a session. When I open the Debug Navigator, the message "No Debug Session" stays, and none of the normal analytics data appears.
I am running my app through Xcode onto my iPhone 12 Pro. It requires the use of the camera, and in fact the part I need the debugger for also requires the camera, so I can't use a simulator to see if that magically fixes it.
I also looked through every setting I could find that mentioned "Debug" or "Debugger", but nothing I could find changed anything.
Also, I downloaded a random tutorial app and ran that through Xcode on my iPhone, and the debugger boots up as expected.
I am completely lost and really need a GDB/LLDB tool to debug my code, so any help is greatly appreciated, as I could not find a single person or post with a similar problem to mine, and all of the Debugger tutorials and Apple Documentation are outdated and useless.
EDIT: Here is the Scheme info I have set, I have nothing in the Arguments tab. (This is a new account so I'm not allowed to embed images RIP)
Scheme Info
Scheme Options
Scheme Diagnostics

As Matt pointed out, the debugger will not point at the app target if the Executable dropdown (in Scheme Info) is "Ask On Launch". It must have the app itself selected.

Related

Xamarin Remote Simulator results in blank screen

I know this feature is very new, so I'm hoping someone has had experience with this issue before and may shed some light on what might be going on. Right now we are trying to utilize Xamarin 4.2's new "remote iOS simulator for Windows". When I build to Mac simulator, it works fine the app shows up and no issues. When I turn on the option to use the remote simulator, the simulator opens, and then there's just a blank screen, as you can see from the screenshot there's no errors and it built fine:
Looks like you are hitting the following:
https://bugzilla.xamarin.com/show_bug.cgi?id=42333
The remote simulator is in preview, so there are likely to be bugs that have not been fixed yet. I'd suggest adding a comment to that bug report with any information you can provide.
If you would like to receive a notification when the bug is updated, you can add yourself to the CC list for the bug. Please note that you will need to create an account on that system if you have not already done so.

iOS9 Share Extension can not debug on Xcode

When I build share extension from Xcode for the real device, Xcode arbitrarily stop debug. But when I launch for simulator, the problem does not occur.
Environment
Xcode 7.1.1
iOS 9.1
Details
When I build share extension, Xcode shows "Finished running MobileSafari.app on iPhone", but Safari does not run. And, The square stop button is arbitrarily gray. So, I launch Safari by myself and choose my extension and post. The debug section does not show anything. Also, URL request is not sent Rails server.
This is the picture when I build the share extension for the real device.
I do not know why the real device can not launch share extension at Xcode.
If anyone know the answer about this problem, please tell me.
Typically you can debug a share extension by going to Debug -> Attach to process or PID and entering the name of your share extension. From there you can open the share extension on your device or simulator and Xcode's debugger should attach and hit breakpoints correctly. However, I've noticed that log messages do not show up when doing this, nor do values populate for variables in the debugger view.
Here's how I got the debugging to work correctly. Run the share extension scheme. When it asks you what app to run, chose 'Photos' (because that's the app your extension will operate in). The Photos app will then launch on your device and you may proceed to use your extension. The debugger in Xcode should then work as expected.
I encountered this issue as well, though unfortunately I don't know the exact solution, maybe I can offer some information that might be helpful.
I (like you, judging by your screenshot) was using Cocoapods, and Cocoapods was copying resources from the pods into the bundle of the app extension after it was code signed. If memory serves, this was interfering with the code signing in some way, and therefore preventing the app from running under the debugger.
I believe that one of the symptoms of this was that logs appeared in the mac's console (or the device's console, can't remember which) saying something about "blasting onto the device using the old skool[sic] method."
You could confirm that this is the case by removing Cocoapods from your project, or any pods that require resources to be copied after compilation. I believe that the solution was to add some kind of special build phase to the extension project to copy the bundle resources, and disabling whatever Cocoapods uses by default.
As a temporary solution, I believe that deleting your app from the device should allow you to attach the debugger once, on the run where the app is installed for the first time. You might also try deleting derived data for your project.

Today Widget on OS X not working

I can't seem to get my Today widget (or any extension for that matter) running in the Widget Simulator. The simulator launches and says "Couldn't Open Widget" along with
Failed to find Widget /Users/SomeUser/Library/Developer/Xcode/DerivedData/Build/Products/Debug/MyApp.app/Contents/PlugIns/MyApp.appex
I looked in Console app and I see this as well:
pkd[299]: ignoring mis-configured plug-in at /Users/SomeUser/Library/Developer/Xcode/DerivedData/Build/Products/Debug/MyApp.app/Contents/PlugIns/MyApp.appex: plug-ins must be sandboxed
But it is sandboxed in xcode! It's codesigned, sandboxed and the lot. Even if I try and deploy it on a new machine (registered as a developer machine with my developer provisioning profile), the widgets don't even show up in System Preferences.
Any idea what I need to do?
Okay finally found the problem. I was codesigning my app by hand (which had never been a problem before) since I had an intricate set of frameworks the app relied upon, and needed to hand copy them using a Copy / Runscript post-build script. Any way, it seems starting Xcode 7 at least, this no longer works as expected. The app works and codesign says the app has been signed correctly, but clearly something is happening behind the scenes that's breaking the codesignature. I ended up removing all my manual codesigning stuff and simply using Xcode's 'Copy Framework' post build step and checked 'Sign on Copy'. It's now finally working as expected.
I couldn't stop building & codesigning by hand, so I looked into Xcode build logs and found the difference :) in my case, I just added -fapplication-extension to compiler & linker flags, now it works!
Based on strangetimes's answer here a little more detailed answer:
First select your project and then your App Target (not the extension)
Then click on Build Phases, then on the top navigation on Editor,
here select first Add Build Phase and lastly click on Add Copy Files Build Phase.
That's it. Build again using the Widget Simulator and it should work now.

How to get UIAutomation, Simulator, and Xcode Debugger Running at the same time?

Can anyone point me to the documentation on how to make Instruments run UIAutomation scripts and start the iPhone application with the debugger running in the Simulator?
Constraints:
I only have iPhone 3g hardware to test with and debugging against the device with UIAutomation just does not reliably work.
Normally the test scripts are just ran to make sure everything passes, but now a weird bug exists that only gets triggered when the UIAutomation script runs (which is a good thing). The bug cannot be duplicated in manual operation.
There does not seem to be anyway to attach Instruments UIAutomation to a process already running in the simulator. There is no selection.
Starting Instruments UIAutomation directly does not cause it to start with the debugger.
I would assume that there is some command line magic that can be configured in Instruments edit active target (environment variable, arguments, working directory) to make this happen, but I've not found the magic paragraph.
Thanks,
Neil
This stumped me for a while, too -- especially since when the Automation Instrument is selected, the Instruments application explicitly says Current instrumentation disallows attach. The key is to realize that an app running in the simulator is visible in your host system as its own process, so attaching directly from GDB works well. These instructions are for XCode 4.2 (4C199) on Snow Leopard 10.6.8:
Start your test in Instruments however you normally do (either directly from Instruments, or from Xcode 4's Product -> Profile. Pick whatever templates and scripts to get your automated test underway.
Back in Xcode, under the menu Product -> Attach to Process, you should see your iOS app, listed by name, alongside all the other applications on your host computer. In fact, it very likely will be listed first, under the section header Likely Targets.
If it's not visible, choose View -> Debug Area -> Show Debug Area so you can see the gdb console.
Hit the pause button (Product -> Debug -> Pause) to interrupt your program. Set breakpoints, inspect, as usual.
Then next question is: why can't I see my normal NSLog() output in the debugger console?
Your app already bound itself to the console output streams, so the simplest place to look for its output is in OS X Console app (/Applications/Utilities/Console.app) and look under DATABASE SEARCHES -> All Messages.

Can't run Instruments from Xcode

I recently upgraded to Snow Leopard and since then I am having difficulty running Instrument to instrument my app from Xcode. The Record button would be grayed out, and nothing happens. There is no message in Xcode's console telling me what's wrong either. I used to be able to attach it to process or launch the process from Instruments as well, all these are no longer working.
Any idea what's causing this?
I had the same issue! I could only use Instruments on my iPhone but not on iPad or iPad2!
Whenever I started instruments with Xcode 4 it would just beep and the record button would be disabled..
I solved this issue by in XCode going to >Targets>Edit Scheme>Profile "yourAppName" and changing the Build Configuration from Release to Debug.
Then try to profile again Product>Profile
If you get the beep again..
You will see that it says "CHOOSE TARGET" next to the record button open the drop down >Choose Target> "yourAppName" then hit record.
This solved it for me and was finally able to run instruments again!
I know this post is old but i hope it helps someone.
I had this issue in Xcode 7. It turned out that, somehow, in the Profile section of my scheme settings, the Executable field had been cleared:
I set the Executable field to my target name and the menu enabled again.
I was unable to get instruments to work with my iPhone (it had previously worked). The behaviour I saw was that xcode would say "finished running - Profiling [app name]" before the instruments window was even shown (the choose instrument window).
I worked around this by going to product->scheme->edit scheme, select profile [app name] and select an instrument (i.e. Allocations) under the instrument drop down (instead of "ask on launch").
Once I did this, selecting Product->profile worked for me and the instruments was running.
I wanted the zombie instrument which strangely isn't in the xcode dropdown, I was able to use this by simply using file->new in instruments (while the allocations instrument was still connected and running) and I could then choose the zombies instrument and the record button wasn't greyed out!
All of this was with iOS 7.0.3 and xcode 5.0.1.
I hope this helps at least one other person to stop ripping their hair out, but knowing xcode I somehow doubt it!
I had the same problem after reinstalling Snow Leopard last week. I moved my /Developer folder to /Developer_old and re-ran the Xcode installer pkg, and now have Instruments back.
HTH
The problem is instrument needs a gateway to your app and simply pointing to it doesn't do it. The Instrument's workflow is as such: You need to profile it from Xcode first.
I highly recommend seeing Apple's own links shared in this answer. They are amazingly good and simple.
Apple's documentation says
If Instruments has access to information about your app’s source code,
a leak is reported as a class name. Otherwise, a leak is reported as a
memory address, such as Malloc-size. To ensure that Instruments has
access to information about your code, initiate profiling from Xcode
(see Profile from Xcode) or configure a symbol mappings file (see Map
Data to Source Code).
what worked for me was
running the app on Simulator
going back to Xcode's Debug Navigator (CMD+7)
selecting CPU/Memory
clicking Profile in Instruments
Note that if you have multiple targets, it is very likely that you need indeed to tell Xcode which one you want to profile. Use the edit targets scheme above
I've noticed that if I go to File->Record options, and press OK, the record button suddenly is enabled.
Make sure all of your instruments support recording modes. When I upgraded from Xcode6 to Xcode7, one of my instruments was marked as "This instrument's supported recording modes are none". When I deleted this specific instrument, the recording button becomed enabled.
As pointed out in Apple's discussion forum, restarting your machine works. It works for me.

Resources