Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Cannot connect IL2CPP managed debugger to iPhone

Discussion in 'Experimental Scripting Previews' started by thisisthedave, Aug 17, 2018.

  1. thisisthedave

    thisisthedave

    Joined:
    Dec 2, 2013
    Posts:
    7
    I'm attempting to try out the IL2CPP managed debugger feature advertised in Unity 2018.2.3, but I'm unable to make it work. What can I try next to figure out why it's failing?

    I created a lightly modified version of the SimpleMobilePlaceholder sample project, and configured an iOS build with "Script Debugging" enabled:

    upload_2018-8-16_19-44-52.png

    The build completes successfully and I'm able to build and install the app to my iPhone 7 using xcode. In Visual Studio 2017, I click Run, Attach to Process, and select the Unity iPhonePlayer:
    upload_2018-8-16_19-47-45.png

    But visual studio cannot connect to the player.
    upload_2018-8-16_19-49-5.png

    Some diagnostic info:
    * I'm using Unity 2018.2.3f1, Visual Studio 2017 Version 7.5.2 (build 40), and Xcode 9.4.1.
    * I am able to connect the Unity profiler.
    * I've experienced the same inability to connect on a different Mac, and on a different Unity project.
    * IL2CPP managed debugging does work when the target platform is MacOS Standalone.
    * I'm happy to send the sample project, but I can't attach the file (42MB zip exceeds the upload limit).

    I'm excited for the potential of debugging on an iPhone! I appreciate any help you can provide.

    Thanks!
    -Dave
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Thanks for the information. This should work, based on the versions you are using. Can you submit a bug report via the Unity editor? I think you can upload a 42 MB project there. If not, we can get the project from you via another route. Please let me know the bug number if you are able to submit one.

    In the meantime, you can try another IDE, just to gather more data. Jetbrains Rider and VSCode should work on macOS as well. If you have a Windows computer on the same network as the iOS device, you can use Visual Studio on Windows to connect to it as well.
     
  3. thisisthedave

    thisisthedave

    Joined:
    Dec 2, 2013
    Posts:
    7
    Hi Josh,

    Thanks for your response. I'm unable to connect the managed debugger with either VS Code or Rider. I submitted a bug report (Case 1072724). Are there any network settings that might interfere with connection, but not with discovery (which might explain why I'm able to see the IOS player listed as a debug target, but cannot connect)?
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Yes, the discovery and debugger connection use to different TCP ports. On iOS, the TCP port for the debugger can change each time the app runs. It might be worth peeking at the open ports on the machine running the IDE and the iOS device (if you can). Also, check for any firewall settings.

    We'll investigate your bug report and see if we can reproduce it here.
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    @thisisthedave

    I have another possibility for your to try. This might be a problem because the iPhone has two network interfaces, the cellular data connection, and a Wifi connection. We need to use the Wifi connection for debugging. Please try to use airplane mode, with Wifi enabled. That should disable the cellular data connection, and might allow debugging to work properly.
     
    zwcloud likes this.
  6. thisisthedave

    thisisthedave

    Joined:
    Dec 2, 2013
    Posts:
    7
    @JoshPeterson Thank you, that worked perfectly! I had even attempted disabling the ethernet connection on my iMac on the suspicion that it was attempting to connect on the wrong network interface, but it never occurred to me that I should disable the phone's cellular network. For the sake of anybody who has this problem in the future, swipe up on your iPhone to disable the cellular connection:

    upload_2018-8-28_15-47-2.png

    Thanks Josh, I really appreciate your help!

    -Dave
     
    Mobazy and JoshPeterson like this.
  7. stgs73

    stgs73

    Joined:
    Mar 23, 2015
    Posts:
    59
    Hi, we're still experiencing the issue with all the above

    Our setup

    iOS
    Xcode 9.4
    Rider 2018.2.2
    Unity 2018.2.6/2018.2.7

    We get the error in Rider with regards to unable to reach a specific IP, Rider detects the device but fails to Attach to Unity Process. We can ping the IP

    Android
    We tried a couple of devices, OS 6.0/7.0/8.0 - identical result, same Unity + Rider

    We disabled Cellular, enabled wifi+airport mode etc
    We tried on 2 different macs, ensured same wifi connection on device/mac

    Unity Profiler works fine
    OSX Version 10.13.4

    Any other thoughts or things we could possibly try?
     
  8. stgs73

    stgs73

    Joined:
    Mar 23, 2015
    Posts:
    59
    Couple of things we have also tweaked in the player settings

    Note: We use AllowDebugging in the BuildPlayer options in code

    iOS
    ARM64 only
    Api Compat 2.0
    IL2CPP
    Runtime 3.5
    Engine stripping on

    Android
    Min Api 19
    Target Auto
    Runtime .net 3.5
    IL2CPP
    Api Compat 2.0
    C++ Compiler Config Release
    ARMv7 only
    Engine stripping on
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    The iOS debugger should always use port 56000. Is there a firewall blocking that port, or maybe something else using that port?

    Also, you may want to try Visual Studio for Mac or Visual Studio on Windows as additional data points for trouble shooting.
     
    stgs73 likes this.
  10. stgs73

    stgs73

    Joined:
    Mar 23, 2015
    Posts:
    59
    Ya we'll give VS OSX a go and see, if it's good then it's a Rider issue and we'll ping them on it
     
  11. stgs73

    stgs73

    Joined:
    Mar 23, 2015
    Posts:
    59
    Just to let you know, we tried VS for Mac and still the same issue
     
    ina likes this.
  12. stgs73

    stgs73

    Joined:
    Mar 23, 2015
    Posts:
    59
    It seems the UDP port is open but the TCP port is blocked ( i assume this is the issue ). We've double-checked for firewall stuff but no dice there.
     
  13. stgs73

    stgs73

    Joined:
    Mar 23, 2015
    Posts:
    59
    Ok we found the issue, our player settings are on 3.5 .NET - this is why it didn't work

    We only noticed because there was some small text in the build player settings that said you had to be on 4.0 .NET and api compat 2.0 :)

    We usually build via our own menu so we completely missed this, i don't recall seeing it in the docs ...maybe we missed?

    Also the Unity docs on the original 4.0 net said something along the lines of not to use for mobile due to bloat or was that just referring to api compatibility?

    We now have 1 conflict with a plugin provider that is stopping us from changing this, we'll chase this down.

    The problem error we have is if we use Api Compat 2.0..
    The type or namespace name `Remoting' does not exist in the namespace` System.Runtime'.

    Update: We hacked the plugin to fix the issue, should be good now.

    thnx
     
    Last edited: Sep 12, 2018
    ina likes this.
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    No, you did not miss this in the debugger docs - they don't exist yet! We have new debugger documentation in process now, hopefully it will be posted soon.

    This was referring to the Api Compatibility Level option. You should avoid using the .NET 4.x Api Compatibility Level option in Unity 2018.1 and Unity 2018.2, as it is a much larger amount of code than the .NET Standard 2.0 Api Compatibility Level. In Unity 2018.3, they are much more comparable in size.

    However, we still recommend .NET Standard 2.0, and the .NET 4.x profile include a number of APIs which we don't support on most platforms.
     
    stgs73 likes this.
  15. MikePage_Artrix

    MikePage_Artrix

    Joined:
    Mar 18, 2016
    Posts:
    15
    Hi,

    I'm having a similar issue on Android using Unity 2018.3.0f2. The instance shows up on the device (after disabling all windows firewalls) but when I hit OK, I just a get a spinner for a second or two and then nothing happens.

    Any ideas?

    upload_2019-1-24_10-49-3.png
     
    seandanger likes this.
  16. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Make sure the device only has one network interface active. It looks like it might be a phone, so you can put it in airplane mode an enable Wifi. Also, you can use the USB connection to debug for Android devices. If you have physical access to the device, try to connect it via USB. That might be more reliable.
     
  17. zwcloud

    zwcloud

    Joined:
    Mar 15, 2016
    Posts:
    377
    Here is another case when the debbuger can see the iPhone player but cannot connect and attach to it: The mac has two network connections. One is WiFi, another one is a network via a USB ethernet adapter. After I removed the USB ethernet adapter, VS for mac can attach to the iOS player without any problem.

     
  18. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    I have the same issue MikePage_Artrix posted about, the USB connected option for the device never shows up in the Attach Unity Debugger window when the project was built using IL2CPP backend. It does show the wifi connected option for the device though -- but doesn't successfully connect. As he wrote, I get a spinner for about a second and then nothing. Profiling in the Unity Editor attaches and records properly, FWIW.

    If I build the project using the Mono backend, both the USB and wifi option for the device appear in the Attach Unity Debugger device list, and successfully attach. My Windows Defender firewall is disabled and the device is in airplane mode.

    Edit: Issue persists with a freshly reformatted machine, fresh install of Unity 2019.1 and included Visual Studio Community 2017 (15.9.11), using a new project with just a single Canvas Button in scene.
     
    Last edited: May 7, 2019
  19. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Can you submit a bug report for this issue? It looks like something is wrong on our end. The specific Android device you are using might have an impact as well, so please provide that information in the bug report if possible.
     
  20. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    39
    Hey Josh, thanks a lot for the response. I did end up submitting a bug report, case 1152416. I had the same results with 3 different devices: a Nexbit Robin running Android 7.1.1, a Sony Xperia Compact X running 7.1.1, and a Samsung Galaxy S9 running Android 9. I included the Android versions in my report but not the device models -- I'm not sure how to edit the report I submitted, is that possible?

    For now I'll debug with the Mono version -- which is an acceptable workaround for me for now.

    I hope that helps!
     
  21. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Please reply to the original email you received with the bug number. Your email content will be added the case notes. Thanks!
     
  22. eylulatilgan

    eylulatilgan

    Joined:
    Jun 7, 2013
    Posts:
    12
    Hello, I have the similar issue like MikePage_Artrix's. I get a build with IL2CPP for Android and cannot see my device in Visual Studio when I try to debug. My device is Alcatel Idol 4.
     
  23. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    @eylulatilgan

    Is the device attached to the machine where the debugger is running via USB, or are they on the same Wifi network?

    Also, note that if the device has both Wifi and cellular data antennas, make sure only the Wifi antenna is enabled. If the device has more than one network interface, the debugger code in the Unity player might bind to the wrong network interface, and end up on a network which is different from the IDE.
     
  24. sotrosh

    sotrosh

    Joined:
    Dec 25, 2014
    Posts:
    13
    Trying to attach to debug to my iPad. The problem is that I don't see my device in "Attach to Process" list. But Profiler works perfect (using USB)

    P.S. I'm using Unity 2019.1.9 and Visual Studio for Mac 7.7.2, macOS 10.14.5
     
  25. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Does the iPad happen to have both cellular data and Wifi connections? If so, please enable only the Wifi connection by putting the device in airplane mode, then enabling Wifi.

    The debugger code in the player which connects to the IDE cannot determine which network interface to choose. It will sometimes choose the wrong one if more than one interface is present.
     
  26. sotrosh

    sotrosh

    Joined:
    Dec 25, 2014
    Posts:
    13
    Thank you for answer. Yes, airplane mode is turned on and iPad doesn't have any GPS module.
     
  27. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Can you submit a bug report for this issue? Maybe there is something specific to this project which prevents it from showing up properly.
     
  28. Wecica

    Wecica

    Joined:
    Jul 20, 2016
    Posts:
    27
    I've run into the same problem as you do with Unity 2018.3.11 and Visual Studio 2017.15.9.11 trying to attach debugger on Redmi Note 5A running with Android 7.1.2...(So much version...) Is there any progress or a solution for this problem now? It is quite annoying.
     
  29. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    I don't believe that we had a bug report for this issue, so we've not made any progress on it that I can recall. Can you submit a bug report for it?
     
  30. Wecica

    Wecica

    Joined:
    Jul 20, 2016
    Posts:
    27
    I don't know how to submit a bug report for this? Any documents for bug reporting?
     
  31. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
  32. smartinetz

    smartinetz

    Joined:
    Dec 8, 2017
    Posts:
    49
    JoshPeterson likes this.
  33. DrSpritz

    DrSpritz

    Joined:
    Oct 6, 2013
    Posts:
    29
    I had the same problem with attaching VS Code debugger to iOS player on the device.

    I solved it by switching the device to airplane mode, disabling wifi, Bluetooth, and disconnecting my mac from all network interfaces (wifi, ethernet, Bluetooth, etc) and then everything worked. The point is to leave only the USB connection, disabling everything else. I hope this will help someone.

    In my opinion, this is an actual problem that has not yet been solved.
     
    ju57m3 likes this.
  34. gdoai

    gdoai

    Joined:
    Apr 14, 2020
    Posts:
    11
    Hey @DrSpritz, can you elaborate how you solved your issue? By disabling all connections and keeping just the cable it shouldn't work (it has to be in Wifi for iOS player). Maybe you enabled only 1 interface on each?
     
  35. gdoai

    gdoai

    Joined:
    Apr 14, 2020
    Posts:
    11
    Hi @DrSpritz
    Your solution worked!
    - we have disconnected our MacMini from internet (no wifi, no ethernet)
    - same for our iPhone (airplane mode, no wifi)
    - plug the iPhone to the MacMini with USB
    => Visual Studio on the Mac can now see the iOS player running on our iPhone!
    So the Unity documentation is completely wrong and needs an update... @JoshPeterson
    Some comments: the managed debugger pops 3 different ports with different status with nmap:
    - 55000 opened
    - 55xxx FILTERED -> changes every time
    - 56000 opened
    On Android, the xxx port is displayed as OPENED and the debugger can properly attach to it.
    Looks like on iOS the FILTERED status is the problem.
     
  36. gdoai

    gdoai

    Joined:
    Apr 14, 2020
    Posts:
    11
    edit: only the iPhone needs to be disconnected from internet.
     
    ju57m3 likes this.
  37. justdizzy

    justdizzy

    Joined:
    Mar 8, 2016
    Posts:
    89
    Yeah, clearly a bug, seeing it with Visual Studio for macOS too. Unity 2020.3.18.

    [EDIT]

    And maybe I'm asking too much, but iOS app running natively (not simulator) on M1 MacBook
    is not showing up at all even if I turn the WiFi off.
     
    Last edited: Nov 30, 2021
  38. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,085
    Disable bluetooth and use .net api 4.0 for Unity 2020
     
  39. spider853

    spider853

    Joined:
    Feb 16, 2018
    Posts:
    42
    I'm on 2021.3.16f1 sadly doesn't work, I have two interfaces (without cellular on) 192.x and 168.x, the 1st one is wifi and 2nd one is MacBook one (not sure what network is that), Unity selects the 2nd one by default... but VS lists 1st one
     
  40. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    Can you manually enter the address that Unity uses in the IDE? If Unity is expecting the debugger connection on that address, I think that it should work.

    We have a bug report currently active about changes to iOS that modify the order of network interfaces, which can cause the broadcast of the debugger IP address to be incorrect. We're working on fixing that now, which should cause the proper address to show up in the IDE automatically. Until then, though, I believe manual entry of the IP address will work.
     
  41. spider853

    spider853

    Joined:
    Feb 16, 2018
    Posts:
    42
    I see,
    Actually I'm not sure how to connect by ip on Visual Studio Mac version. Attach to Process doesn't give any IP option (versus the PC one)
    Can't connect from the PC as 168.x is a different network than the wifi one.
     
  42. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    From a Microsoft developer who works on the Visual Studio/Unity integration:

    VS for Mac does not have the same "enter manual IP" button unfortunately. But as a workaround in Tools/Preferences/Tools for Unity, enter the ip/port like 192.168.1.1:56000 in the Saved debug targets text box, then make sure Use saved debug targets is checked. Then when clicking to Attach to Unity in the main debug bar, it will show this specific IP/port in the comboxbox so you can use it.
     
    spider853 likes this.
  43. spider853

    spider853

    Joined:
    Feb 16, 2018
    Posts:
    42
    Thanks for reply, just tried it, it attaches for 0.5 seconds then detaches without any errors or information,
    I can see the interface changing for a split second to the debug layout, then back to normal

    EDIT!

    Nvm found the right connection in the XCode log and seems to work now!

    So you'll see something like this:
    Broadcasting "[IP] 169.254.87.106 [Port] 55000 [Flags] 2 [Guid] 4254192893 [EditorId] 1215127279 [Version] 1048832 [Id] iPhonePlayer(8,YOUR-iPhone):56000 [Debug] 1 [PackageName] iPhonePlayer [ProjectName] SomeCoolGameName" to [169.254.255.255:54997]...

    The right connection is 169.254.87.106 with port 56000

    it's a bit confusing as the ip is listed with port 55000 and the right port is listed with phone name

    Thank you, hope it will get it sorted out, till then it will work like this
     
    Last edited: Mar 17, 2023
  44. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    I'm glad that worked! The 55000 port is used for the connection to the Unity profiler. This same broadcast message is shared by both the profiler and the debugger, so it can be confusion.
     
    spider853 likes this.