Search Unity

How to use XCode Instruments to profile Unity iOS builds?

Discussion in 'iOS and tvOS' started by Keepabee, Jul 12, 2012.

  1. Keepabee

    Keepabee

    Joined:
    Jul 12, 2012
    Posts:
    58
    Problem: Can't see Unity/C# method names in XCode Instruments profiling. How do I fix this?

    $NoSymbols.png
    Image from Instruments Time Profiler: No symbols for Unity's methods or C# script files are shown, making it impossible to identify what piece of my code or what functionality of Unity takes up time in the project.

    Anyone here who uses XCode Instruments to profile iOS builds? What settings are necessary for using Instruments in Unity/XCode: I can't see any Unity/C# method names in Instruments profiling, only hex addresses placeholding these missing symbols.

    I've tried building with probably all Unity build setting permutations for flags: Symlink Unity libraries, Development build, Script debugging.

    * XCode version 4.3.3.
    * Unity 3.5.3f3. License type: Unity, Android, iPhone.

    Unity Build settings, activated:
    * Development build.
    * Script Debugging.

    XCode Build Settings (that I have tried changing):
    * Debug Information Format: DWARF with dSYM.
    * Strip Debug Symbols During Copy: No
    * Preserve Private External Symbols: Yes
    * Generate Profiling Code: Yes
    * Generate Debug Symbols: Yes
    * Inline Methods Hidden: No
    * Instrument Program Flow: Yes
    * Symbols Hidden By Default: No
    * XCode Profiling Scheme uses a Release build.
    * Other linker flags: -all_load -weak_framework CoreMotion -weak-ISystem

    In Instruments, I've tried to:
    File => "Re-symbolicate this document" => Locate => then pointed to the dSYM file from within the last XCode archive I made of my build, copied to same folder as the .app for that same XCode archive.

    Anyone who succeeds in Instruments profiling, please post your settings or any help I could try to fix this.
     
    Last edited: Jul 18, 2012
  2. Mantas-Puida

    Mantas-Puida

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    I assume you are using Xcode 4.x. Unfortunately latest Xcode uses Release configuration for profiling and by default Unity forces symbol stripping for release builds to ensure you have smallest possible distribution size once you are submitting app to App Store. You can disable this symbol stripping by clicking on Unity-iPhone build target in Xcode and then selecting Build Settings tab and entering "other linker flags" in search field. Once you locate "Other Linker Flags" field modify "Release" version of it by removing "-Wl,-S,-x" from there.

    P.S. don't forget to restore it when you are making distribution build.

     
  3. Keepabee

    Keepabee

    Joined:
    Jul 12, 2012
    Posts:
    58
    I tried this, but it didn't seem to change anything. I updated my original post with more specific details about my latest tries of profiling with Instruments.
     
  4. Keepabee

    Keepabee

    Joined:
    Jul 12, 2012
    Posts:
    58
    Shamelessly trying to keep this thread alive if anyone should know anything about this issue. :/
     
  5. order66

    order66

    Joined:
    Apr 17, 2012
    Posts:
    150
    Would also like to know wether it is possible.

    I tried what Mantas suggested but it isn't working for me either.
     
  6. jomeier

    jomeier

    Joined:
    Jun 5, 2010
    Posts:
    45
    You have to turn off debug code stripping in XCode:

    - Build Settings -> "Strip Debug Symbols During Copy" -> No

    Also turn on Generate Debug Symbols:

    - Build Settings -> "Generate Debug Symbols" -> Yes

    Turn on DSYM Generation:

    - Build Settings -> "Build Options" -> Debug Information Format -> "DWARF with dSYM File"

    Then clean your project : Product -> Clean
    Build for Profiling

    Profile with Instruments and you'll see your unity symbol names :)
     
    ow3n likes this.
  7. BillyMFT

    BillyMFT

    Joined:
    Mar 14, 2013
    Posts:
    178
    great tip jomeier - thanks
     
  8. Umai

    Umai

    Joined:
    Jun 18, 2013
    Posts:
    74
    This has not helped me. No matter what I do, never does a Unity-iPhone project generate dsym file.
    I have a plain iOS project... where dsym generation works allright. In it I have "Strip Debug Symbols During Copy" turned to YES so I don't think that's related.
    In my Unity-iPhone project the Generate Debug Symbols is YES.
    Debug Information Format is DWARF with dSYM File


    but no luck
     
  9. Jmonroe

    Jmonroe

    Joined:
    Jul 7, 2012
    Posts:
    123
    Have you checked "development" build in Unity?
     
  10. Dadaze

    Dadaze

    Joined:
    Sep 21, 2012
    Posts:
    24
    I don't know if this works, but all those manual switches could be avoided by simply using Debug for command-line builds? I'm saying this because I tried everything and it still doesn't work, but I think this is how you use the Debug settings?