Search Unity

How to use Xcode Framedebugger for Unity?

Discussion in 'Formats & External Tools' started by GuardHei, Dec 10, 2019.

  1. GuardHei

    GuardHei

    Joined:
    Feb 10, 2018
    Posts:
    89
    Hi guys, I want to do a graphic analysis of my game following the guidelines found here https://docs.unity3d.com/Manual/XcodeFrameDebuggerIntegration.html. However, it really confused me when it said "To load the Xcode frame debugger, launch the Unity Editor through Xcode, with Metal selected as the GPU Frame Capture option."

    So my question is how should we launch the Unity Editor through Xcode?
     
    Last edited: Apr 9, 2020
    eclmist likes this.
  2. friuns

    friuns

    Joined:
    Jan 14, 2016
    Posts:
    23
    i guess you need unity source code to doing that
     
  3. eclmist

    eclmist

    Joined:
    Oct 25, 2016
    Posts:
    7
    The documentation is hilariously vague. It feels like it was written by an underpaid intern.
     
  4. Halcomb

    Halcomb

    Joined:
    Jan 23, 2020
    Posts:
    3
    You can use the Xcode frame debugger to capture a frame of a complex scene
    in your application, then identify bottlenecks in your shaders
    . On devices with the A11 chip or later (iPhone 8 and newer devices), Xcode offers an even more detailed breakdown of shader timing. This allows you to analyze performance and debug vertex and fragment issues.
     
  5. eclmist

    eclmist

    Joined:
    Oct 25, 2016
    Posts:
    7
    Please read the thread that you're replying to. No one is asking what the frame debugger is nor why it is used. What are the steps to hook it up with the Unity Editor?
     
  6. wanzhang

    wanzhang

    Joined:
    May 19, 2015
    Posts:
    8
    same confusion.
     
  7. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    472
    haven't figured out how to launch Unity Editor from Xcode yet either
     
  8. dcolman

    dcolman

    Joined:
    May 21, 2017
    Posts:
    8
    Has anyone figured this out yet? Can't figure it out either.
     
  9. dcolman

    dcolman

    Joined:
    May 21, 2017
    Posts:
    8
    Ok, I got close, maybe this will help some people.

    To launch Unity editor from Xcode:
    • Open Xcode
    • Select “Create a new Xcode project”
    • Under “Choose a template for your new project” select macOS -> Command Line Tool and press Next button.
    • Enter a Product Name (i.e. MacEditor) and any additional information. I selected C++ for language. Press Next, and save to a location on your computer.
    Now that you're in your new project, select main.cpp and write a short script to open your specific project with Unity.
    Here is an example, you can follow the general format using your specific Unity version and specific project path and name:
    Screen Shot 2020-06-27 at 1.28.15 AM.png

    Press the play button at the top and it should open your project in the Unity editor!

    Here is where I run into trouble. If I launch like this, I get the little person icons as expected: XcodeCaptureButton.png
    But when I press the button to capture a frame, it does not open the Xcode frame debugger. Nothing happens.

    To be fair, at this point I haven't fully followed the instructions at the link at the beginning of this thread. I still need to change the scheme of the MacEditor target to select Metal as the GPU Frame Capture option (it defaults to Automatically Enabled). But when I do that and press play, Unity launches, but now the little person icons are no longer there so I can't even try to capture a frame. Wondering if that's a bug. I do have Metal Editor Support checked in Project Settings.

    So I got close. If anyone wants to try out what I've got so far and see if they can get further, please keep us posted! I'll follow up if I have more luck.
     
    chrismarch likes this.
  10. mathieur

    mathieur

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    31
    I think I found the way.

    1. Create a new command line project (I chose c++).
    Screen Shot 2020-06-30 at 8.30.06 AM.png
    2. Change the project's executable to be unity editor
    Screen Shot 2020-06-30 at 8.29.16 AM.png
    3. Change the arguments to add a project path to open
    Screen Shot 2020-06-30 at 8.29.49 AM.png
    4. Press play in xcode. The editor should now start and the frame debugger button should work.

    Basically, the code in your xcode project doesn't matter. You're not using or even compiling it. You're just using xcode to start your project.
     

    Attached Files:

  11. cassius

    cassius

    Joined:
    Aug 5, 2012
    Posts:
    125
    I felt hopeful this would work since I did get the xcode Frame Debugger icon after following the above instructions. However clicking the icon did nothing at all. :(. Xcode shows that Unity is running, so I know it's "connected" in some way. Icon appears in Unity... just doesn't do anything.
     
  12. naive_magic

    naive_magic

    Joined:
    Jun 5, 2020
    Posts:
    7
    Mathieur solution works.
     
  13. xinaesthete

    xinaesthete

    Joined:
    Mar 13, 2015
    Posts:
    7
    I was initially a bit confused about finding the right place to set executable and command line arguments in Xcode. Shortcut ⌘< helps there.

    Unfortunately I'm not even seeing the frame debugger icon. This is with Unity 2021.2.19f1

    EDIT::: I hadn't followed the step to "Enable Frame Capture" in the Xcode scheme - it is working now.
     
    Last edited: Apr 11, 2022