Xcode Instruments Unknown Addresses - ios

I'm using the Xcode Instruments tool to Time Profile my application. Unfortunately, no matter how much I interact with the application while recording, I don't see a comprehensive break down of function calls in the profile. Instead, I see these <Unknown Address> [inlined] messages.
Running on Simulated iPhone on Mac:
Running on actual iPhone:
I verified that under the Xcode build options DWARF with dSYM File is selected for both Debug and Release and that the file exists. I'm using the IOS deployment target that matches the current version I have running on my iPhone and I have the latest (13.2.1) Xcode Command Line Tools selected.
I also took a look in Instruments > File > Symbols and noticed that there was a perms issue with what seems to be the CLT - not sure if this is at all related?
When I select the app name below Unknown, there isn't a dSYM path selected. However, every time I select it /Users/username/Library/Developer/Xcode/DerivedData/AppName-<sequence of characters>/Build/Products/Debug-iphoneos/AppName.app.dSYM I see a message "1 library will be symbolicated". However, this path doesn't seem to work because there is no behavior change in instruments AND it never sticks - it shows as empty if I open the window again.
Any suggestions would be greatly appreciated!

Related

Migrating SceneKit app from xc10 > xc11, I encounter "xcrun: error: unable to find utility "scntool", not a developer tool or in PATH"

Due to character limits in the title, allow me to elaborate on what is happening.
I have an application that builds with no warnings & errors while using Xcode 10.2.1, but I would like to test it in the latest Xcode 11 beta.
However, it produces an error during the build process, yet oddly enough, the app properly launches and is usable on a simulator.
The error:
xcrun: error: unable to find utility "scntool", not a developer tool
or in PATH
Initially, I thought it was possible that the spaces in my app's name were a problem, so I quickly renamed it to use _ in place of the spaces, but that did not work.
Rebuilding the app after I removed the spaces also shows the following warning:
copySceneKitAssets: warning: Failed to copy SceneKit assests because
scntool failed to process the following resources:
/Users/someidiot/Library/Developer/Xcode/DerivedData/Build/MyAmazingApp/Products/Debug-iphonesimulator/My_Amazing_App.app/art.scnassets/Game.scn
And yes, the file is there:
Out of curiosity, I purged my derived data in case something was causing problems there.
rm -rf ~/Library/Developer/Xcode/DerivedData
However, the same scenario as before... warnings & errors upon building, but the app successfully launches on the simulator.
My concern here is that if something is genuinely wrong, I'd like to fix it before it becomes an issue, but at the same time, the app does launch successfully.
Unfortunately, I do not have access to an iOS 13 device at this time to test on hardware.
After any new Xcode installation, or even when switching between versions of Xcode, always go into Xcode's Preferences and, under Locations, adjust the Command Line Tools pop-up menu to point to the version of Xcode you are using.
Otherwise, something like xcrun, which means "run a tool inside Xcode", will be looking in the wrong Xcode.

Missing symbol names while profiling in Instruments 7

I don't see any symbol names when I'm profiling application for iOS 8.
If I run profiler on simulator with iOS 9 everything works fine. Then I close instruments and switch to simulator with iOS 8.4 and I can see only hexadecimal addresses which reference to assembler or 'unavailable' content. Other threads are unnamed and everything, including system names are shown as binary pointers.
Instruments can't find dSYM file, so I tryied to re-symbolicate app as File ▸ Symbols... then I select missing symbols and there is option to locate dSYM file.
After select dSYM file, I get this message.
And it's over. I also tryied restart PC, rebuild application, clean project, delete Derived Data, reopen XCode and Instruments, reindexing files from this post but it has no effect.
Thanks.
PS: There is similar post without solution

Can I debug iOS app installed from IPA archive?

I m having some problem with my app which reproduces only when i install it ad hoc, but doesn't reproduce if i just run the app from Xcode. I would like to debug this problem, but so far i m not having any luck. I m using Xcode 5.1.1. Here is what i did:
1) Go to Product->Scheme->Edit Scheme->Archive and set build
configuration to Debug.
2) Code signing identity is set to iPhone Developer.
3) Generate Debug Symbols is set to Yes.
4) Go to Product->Archive and after it is archived, click
"Distribute", then choose "Save for Enterprise or Ad Hoc Deployment".
5) My development provisioning profile is selected.
6) Click "Export" and export the .ipa file.
7) Use iPhone configuration Utility to install the app onto the
device.
8) Run the app on the device.
9) In Xcode, go to Debug->Attach To Process->By PID or Name, enter the
app name. Xcode attaches successfully and says running the app on
iPad.
10) However, i cannot hit any breakpoints which should be hit when i
do certain actions in my app (if i install and run the app from Xcode
instead, all breakpoints are hit).
Am i missing something?
You don't have any debug information for the app at this point, and since most apps are pretty thoroughly stripped, there won't even be symbols for lldb to hook on to. So we're not going to be able to successfully set breakpoints.
When you built the app, Xcode produced a dSYM file (MyApp.app.dSYM) which has the debug info in it, so all is not lost. Problem is when you attach to some - to Xcode - random app on the device, Xcode has no way to know where to find its debug info.
You can add the debug info into your debug session in lldb by using the command:
(lldb) add-dsym <PathTo.dSYM>
You have to do this after you have attached.
lldb also uses SpotLight to find dSYM's so if you put the dSYM somewhere that SpotLight knows to search (like your Desktop or a folder under your User directory) then lldb should pick it up automatically.
You can tell whether lldb has successfully read in the dSYM by doing:
(lldb) image list <AppName>
If lldb found the dSYM, it will list the path to it on a separate line after listing the path to the AppName binary.
Jim Ingham, thanks for your answers.
I found the reason why i was unable to debug into static libraries. In each Xcode project, there is a setting called "Strip Linked Product" under "Deployment" section. In all my projects this setting was set to "Yes".
In order to debug into static libraries for an app built by archiving, i set this setting to "No" in each dependent library project (as well as the main project). This can also be set differently for Debug/Release modes. After this, i see the library symbols built during archiving and i m able to debug into library code. I hope this helps someone.
Unfortunately (or maybe fortunately) the bug i was trying to debug no longer reproduces when the library symbols are not stripped. Maybe something happens when the symbols are stripped, i will need to investigate further.
I was struggling with the same problem, and just launching my app from Xcode was not an option - I had to build the IPA, sideload it on an iOS device, and then debug. Eventually I was able to make that work with the following steps:
1) Set the scheme archive target to Debug
2) Change the following settings for the Debug builds
Keep Private External Symbols (KEEP_PRIVATE_EXTERNS) : YES
Enable Bitcode (ENABLE_BITCODE) : NO
Strip Linked Product (STRIP_INSTALLED_PRODUCT) : NO
3) Rebuild, archive, and deploy the resulting IPA file to your iOS device.
4) Launch the app, and in Xcode, select Debug/Attach to Process/YourAppName(id)
5) Break into the debugger - you should be able to see the code, put and use breakpoints, etc.
If you want to debug your code from the very beginning, just put a loop that sleeps for a second or two and then checks a flag at the top of your main function - when you break into the debugger, just change the flag to let it escape the loop.

Xcode: error: failed to launch with duplicated target. Original target runs fine in Xcode/gdb

I have an app that I want to be able to build two different versions. One a "test" version that hits test databases, populates a test analytics backend, etc, and then the "live" version which its the production database and analytics backend.
So I duplicated my target, made appropriate changes, and I can build both, and both get installed on the phone, and I can run both manually on the phone. However, when I try to run it in Xcode on the device in order to debug with gdb or lldb (same error happens with both), the original target runs fine. However, the duplicated target (the "test" one) gives an error when running on the device (both run fine in the simulator, the problem is only running on the device)
lldb gives: [APPNAME] is the overall app name -- the test version has product set to [APPNAME]Test
error: failed to launch '/Users/chad/Library/Developer/Xcode/DerivedData/[PROJNAME]-ezbuaazlwmgdwydjykcufhicaspu/Build/Products/Debug-iphoneos/[APPNAME]Test.app/[APPNAME]Test'
gdb basically gives a dialog box that says that the same path cannot be found.
However, that path actually DOES exist. If I cut and past the path from the Xcode debugger window and go to Terminal and type % ls -a '/Users/chad/Library/Developer/Xcode/DerivedData/[PROJNAME]-ezbuaazlwmgdwydjykcufhicaspu/Build/Products/Debug-iphoneos/[APPNAME]Test.app/[APPNAME]Test'
it finds it just fine. I can also click in Xcode in the file list under the Products folder and click on [APPNAME]Test.app and choose in the contextual menu to "Show in Finder" and it finds it just fine.
AND the app does get copied to the phone and it shows up in the organizer and I can manually launch the app and it runs on the device. It just won't auto launch in Xcode on the device for the copied target, while the original target runs just fine in Xcode.
I'd appreciate any insight into this. This is my first real time playing with multiple targets on an iPhone project I created (versus working on a team on a project someone else created). Thanks.
Wouldn't you know. Xcode crashed (for some totally other reason when I was doing something different unrelated to this) and now both targets will launch and run from Xcode. So I guess the solution is to quit Xcode after duplicating a target if you have problems with the target launching from Xcode.

Instruments can't attach to running process on iPhone

I created a build for ad-hoc distribution of our product and installed the same on my device. Now I want to run the time profiler on the running process but Instruments is unable to attach to it. This is the error that I get when I try to attach to a running process on the iPhone:
Target failed to run : Could not attach to process <app-name> (<pid>)
I also tried "Choose Target" > app-name but that too failed with the following error:
Target failed to run : Remote exception encountered : 'Failed to get task for pid <pid>'
Here are the details of my setup:
OS X 10.7.2
Xcode 4.2.1 (Build 4D502)
Instruments 4.2 (4233)
iPhone OS 5.0.1 (Build 9A405)
I had the same problem. I didn't solve it initially, but an easy workaround is to launch the app yourself and then attach to it from the "Attach to Process..." command in the Target menu in the Instruments window.
After some digging around it seems this is a common topic of discussion on the apple developer forums: Instruments does not work on Xcode 4 with device
It appears that different Apple products will change/update the MobileDevice framework. Some of these updates break the Instruments integration.
To fix this on my own machine, I installed the iTunes 10.5 beta v6. Fire up XCode, and I'm back in business Instrumenting on my device.
I would recommend this tutorial since it is one of the better ones for explaining how to use Instruments
It can be very confusing at first, but take the time to get to know it and it'll ease a lot of headaches later.
Hope atleast one of these approaches work for you.
In Xcode 10: don't launch Instruments separately. Instead:
From Xcode’s menu bar, select Product\Profile, or press ⌘I. This will build the app and launch Instruments. You will be greeted with a selection window...
Full Tutorial
Note
If you do launch separately you'll get the failed to attach to target error with the recommendation to disable System Integrity.

Resources