- Home /
iOS Script Debugging not working
I have Visual Studio 2019 for Mac. I have an iPhone Max XS with the latest iOS. I am using Unity 2018.3.11f.
I created a brand new project and just have a single script with very little in it.
I am trying to debug on iOS. I checked Development Build, Script debugging and wait for manage debugger. I also selected run xcode as Debug, but also tried as Release and both did the same thing.
I tried the Build and Run button. After opening xcode and building the console output says the buld was complete, but then after several seconds it gives the following:
Socket: connect failed, error: Operation now in progress(36) connect failed Failed to connect to player ip: 10.48.21.111, port: 55000
That is the IP address of my iPhone on the wifi.
I also tried running the app from xcode in debug. It runs and shows a dialog saying that I can connect the managed debugger.
I have Visual Studio open so I select Run / Attach to process. The iPhone process shows up with an ip address of 192.0.0.1, 56000. Not sure where that is coming from, but if I don't have the app running on the iPhone it doesn't show up at all, so I suspect it is the right thing.
If I select to attach to it the dialog goes away, but after several seconds I get a dialog in VS saying:
Debugger operation failed.
Operation is not valid due to the current state of the object.
I have tried all kinds of gymnastics in trying to start things at certain times and waiting here and there and connecting faster or slower and nothing changes.
I have also tried all of this with both the iPhone connected via USB and wifi. I have turned off and turned on wifi debugging in xcode for this device.
I have tried just running the app on the iPhone and not by using xcode and it does show up in the VS attach to process dialog, but still fails with the above message.
If I do run it in the debugger over USB I get the following output:
PlayerConnection initialized from /var/containers/Bundle/Application/359CFD90-51F6-4BBA-B2B6-347C1A1F4B5F/evaluation2d.app/Data (debug = 0)
PlayerConnection initialized network socket : 0.0.0.0 55000
Multi-casting "[IP] 192.0.0.1 [Port] 55000 [Flags] 3 [Guid] 1916711904 [EditorId] 1338261848 [Version] 1048832 [Id] iPhonePlayer(Tonys-iPhone):56000 [Debug] 1 [PackageName] iPhonePlayer" to [225.0.0.222:54997]...
Waiting for connection from host on [0.0.0.0:55000]...
PlayerConnection accepted from [10.48.21.31] handle:0x6
Started listening to [0.0.0.0:55000]
PlayerConnection already initialized - listening to [0.0.0.0:55000]
2019-04-18 09:43:19.140200-0600 evaluation2d[1824:557382] Metal GPU Frame Capture Enabled
2019-04-18 09:43:19.140779-0600 evaluation2d[1824:557382] Metal API Validation Disabled
2019-04-18 09:43:19.364326-0600 evaluation2d[1824:557382] [Warning] Trying to set delaysTouchesBegan to NO on a system gate gesture recognizer - this is unsupported and will have undesired side effects
-> applicationDidBecomeActive()
GfxDevice: creating device client; threaded=1
Initializing Metal device caps: Apple A12 GPU
Initialize engine version: 2018.3.11f1 (5063218e4ab8)
If I disconnect USB and just debug in xcode over wifi I get the following output:
PlayerConnection initialized from /var/containers/Bundle/Application/B1C0D8B3-4EA6-4F91-AB0D-D228CFD277C7/evaluation2d.app/Data (debug = 0)
PlayerConnection initialized network socket : 0.0.0.0 55000
Multi-casting "[IP] 192.0.0.1 [Port] 55000 [Flags] 3 [Guid] 3570588543 [EditorId] 1338261848 [Version] 1048832 [Id] iPhonePlayer(Tonys-iPhone):56000 [Debug] 1 [PackageName] iPhonePlayer" to [225.0.0.222:54997]...
Waiting for connection from host on [0.0.0.0:55000]...
PlayerConnection accepted from [10.48.21.31] handle:0x6
Started listening to [0.0.0.0:55000]
PlayerConnection already initialized - listening to [0.0.0.0:55000]
2019-04-18 09:48:54.066179-0600 evaluation2d[1838:559292] Metal GPU Frame Capture Enabled
2019-04-18 09:48:54.066749-0600 evaluation2d[1838:559292] Metal API Validation Disabled
2019-04-18 09:48:55.006351-0600 evaluation2d[1838:559292] [Warning] Trying to set delaysTouchesBegan to NO on a system gate gesture recognizer - this is unsupported and will have undesired side effects
-> applicationDidBecomeActive()
GfxDevice: creating device client; threaded=1
Initializing Metal device caps: Apple A12 GPU
Initialize engine version: 2018.3.11f1 (5063218e4ab8)
You can see how in that one it waits for a connection and gets it from xcode because I haven't done the attach yet from VS. Also notice how the port is 55000 and not 56000 like VS is using.
All I want to do is be able to do managed script debugging on iOS. Can someone tell me how to get this to work?
Answer by ThinhHB · Jul 11, 2019 at 06:17 AM
I faced the same error "Debugger operation failed. Operation is not valid due to the current state of the object." Try this:
Go to Unity/Preferences/External tools
Check the "Editor Attaching"
Then restart both Unity and Visual Studio, hope it will help
Answer by kwikdev · Jun 30, 2020 at 06:28 PM
I am seeing this in Unity 2019.4.f1 today just trying to attach Unity Editor for debugging in the Mac environment.
The 'Editor Attaching' is checked, I have reinstalled both Unity and VS, multiple Mac restarts.
Stuck! What else can fix this?
Answer by faveris_dt · Mar 04, 2021 at 10:11 AM
I fixed error "Socket: connect failed, error: Operation now in progress(36)" with turning cellular data off on my iPhone.
Your answer
![](https://koobas.hobune.stream/wayback/20220612195725im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can't debug an iOS game. 1 Answer
How do I debug a crash in mscorlib.dll.s with Strip-assemblies turned on? 1 Answer
unity 5- IOS works only in development build 0 Answers
ios script debugging using Visual Studio 0 Answers
IOS Script Debugging gives XCode Error: Unable to insert branch island 2 Answers