-
-
Save trond-agens/3961db548f74d1e05153a2041d92fa98 to your computer and use it in GitHub Desktop.
Workaround for Visual Studio for Mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on https://stackoverflow.com/a/64067297 | |
# Run this on your dev machine (computer where Visual Studio for Mac is running) | |
import socket | |
from time import sleep | |
def main(): | |
interfaces = socket.getaddrinfo(host=socket.gethostname(), port=None, family=socket.AF_INET) | |
# Adjust IPs to match your local network. | |
deviceIp = "192.168.1.40" | |
devicePort = 56000 | |
broadcastIp = "192.168.1.255" | |
broadcastPort = 54997 | |
# Look for similar message in the XCode output log, and adjust accordingly. | |
# It looks like it's sufficient to change IP and port. Visual Studio for Mac seems to use | |
# info in the message, and not the actual source IP of the broadcast message, so it connects | |
# to the device even though the message doesn't strictly come from it. | |
# | |
# | |
# Multi-casting "[IP] 20.62.180.11 [Port] 55000 [Flags] 2 [Guid] 2249384309 [EditorId] 2324418647 [Version] 1048832 [Id] iPhonePlayer(8,Someones-iPhone):56000 [Debug] 1 [PackageName] iPhonePlayer [ProjectName] UnityProject" to [225.0.0.222:54997]... | |
# Starting managed debugger on port 56000 | |
message = "[IP] " + deviceIp +" [Port] " + str(devicePort) + " [Flags] 2 [Guid] 1741584310 [EditorId] 2311285316 [Version] 1048832 [Id] iPhonePlayer(8,Someones-iPhone):" + str(devicePort) + " [Debug] 1 [PackageName] iPhonePlayer [ProjectName] UnityProject" | |
print("Sending message: '" + message + "' to " + broadcastIp + ":" + str(broadcastPort)) | |
msg = bytes(message, 'utf-8') | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) # UDP | |
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) | |
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | |
sock.bind(("0.0.0.0",0)) | |
# TODO: Nice shutdown | |
while True: | |
sock.sendto(msg, (broadcastIp, broadcastPort)) | |
sleep(2) | |
sock.close() | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment