Xcode -> Profile -> Instruments 'Can't find source code for selected symbol' - xcode

I'm attempting to use Xcode & Instruments to Time Profile my app - but there's something in my environment which is preventing Instruments from linking back to source code. It's this way with all of my apps, and even with a recent tutorial from Kodeco (RayWenderlich.com) - so I'm suspecting my environment.
In Xcode, I select Product -> Profile, which launches Instruments. I select Time Profiler. I click the record button, use the app such that the area of interest is executed, hit stop.
In the Profile section of Instruments, I can see the stack traces, and many of them have function names which are clearly from my app.
When I double-click on them, I expect them to show the source code from Xcode (as detailed in apple docs and the Kodeco tutorial).
However, instead I get this screen which says "Error: Can't find source code for selected symbol"
Most of the stack overflow question / answers I've seen come from many years ago, which suggests that my problem isn't common - which has me wondering what I've got lurking in my environment that's preventing this from working.
I'm using an M1 Mac w/ Ventura 13.1 Beta (22C5044e) and Xcode Version 14.1 (14B47b).
Any thoughts will be greatly appreciated...

Related

Memory profiling a Rust binary with XCode 13.2.1

With an earlier version of Xcode, I was able to profile my Rust binaries' allocations following these instructions. It worked beautifully.
https://developer.apple.com/library/archive/technotes/tn2434/_index.html
Now, I'm using version 13.2.1, and Xcode shows me empty windows.
I set up the profiling session like this:
Then, I click the run button. The Debugging Session panel lights up for a second or two, then my process exits and I'm left looking at the following. I don't see allocations profile information or a button to click to show it to me.
I tried using Release and Debug binaries, and the result is the same.
I found the old "Instruments."
Just skip the tools in Xcode.

Xcode Debugger Doesn't Begin Session When App Runs

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.

Xcode no longer displaying reasons for errors in the output in the debug area

I've been using Xcode for 3 years and whenever I have had a problem, such as an exception or unrecognized selector, its been very easy to see the culprit as Xcode displays the reason in the output.
However its no longer doing this, it seems to have stopped a few days ago, but I've not knowingly changed anything. Nor have I changed from running debug to release build for example, its the exact same project and I've not changed any settings of the project nor of Xcode.
How can I set it back to display useful information in the output window when there's an error?
(Xcode 5.0, output is set to "All Output")

Xcode 5 crashes when exporting a OS X application from an archive

I am just a member of the iOS Developer Program, not of the Mac Developer Program, so I can’t code sign my Mac applications.
I tried to rebuild an OS X App of mine with my fresh Xcode 5 installation. This only worked once completely, so I tried with an app template to see if it is related to my project. Problem persists:
Create new Cocoa Application (no Core Data, not document-based)
Leave build settings as they are (Don't Code Sign, PROVISIONING_PROFILE none)
Archive
Distribute
Export as Application
Result: "No Identities are available for signing”. No chance to continue without code signing.
Either
Select "Import Developer Profile", then cancel -> Crash
or
Select "Download Identities", select the one that is shown (only iOS Development) -> Crash
There used to be an option for "Don't code sign" after selecting "Export as Application", but this is gone. But I am pretty sure I have seen this when I tried Xcode 5 for the first time three days before. I managed to build, archive and export my application without problems. But when I try it now on my iMac and my MacBook Pro, it doesn’t work.
I also tried to follow the hints from this question, but to no avail.
Thanks for any help.

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