Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Distribuzione con un clic

Che cos'è la distribuzione con un clic?

One-click deploy is a feature that is available once a platform is properly configured and a supported device is connected to the computer. Since things can go wrong at many levels (platform may not be configured correctly, SDK may be incorrectly installed, device may be improperly configured, etc.), it's good to let the user know that it exists.

Dopo aver aggiunto una preimpostazione di esportazione Android segnata come Eseguibile, Godot è in grado di rilevare quando un dispositivo USB è collegato al computer e di offrire all'utente la possibilità di esportare, installare ed eseguire automaticamente il progetto (in modalità debug) sul dispositivo. Questa funzionalità è chiamata distribuzione con un clic.

Nota

One-click deploy is only available once you've added an export template marked as Runnable in the Export dialog. You can mark several export presets as runnable, but only one preset per platform may be marked as runnable. If you mark a second preset in a given platform as runnable, the other preset will no longer be marked as runnable.

Piattaforme supportate

  • Android: Exports the project with debugging enabled and runs it on the connected device.

    • Make sure to follow the steps described in Esportazione per Android. Otherwise, the one-click deploy button won't appear.

    • If you have more than one device connected, Godot will ask you which device the project should be exported to.

  • iOS: Exports the project with debugging enabled and runs it on the connected device.

    • Make sure to follow the steps described in Esportazione per iOS. Otherwise, the one-click deploy button won't appear.

    • For each new bundle identifier, export the project, open it in the Xcode, and build at least once to create new provisioning profile or create a provisioning profile in the Apple Developer account dashboard.

    • If you have more than one device connected, Godot will ask you which device the project should be exported to.

  • Desktop platforms: Exports the project with debugging enabled and runs it on the remote computer via SSH.

  • Web: Starts a local web server and runs the exported project by opening the default web browser. This is only accessible on localhost by default. See Troubleshooting for making the exported project accessible on remote devices.

Utilizzo della distribuzione con un clic

  • Android:
    • Enable developer mode on your mobile device then enable USB debugging in the device's settings.

    • After enabling USB debugging, connect the device to your PC using a USB cable.

    • It's also possible to one-click deploy via wireless ADB instead of with a USB cable. In order to do this, it is necessary to:
      • Enable wireless debugging on the device: Settings > Developer options > Debugging

      • Connect to the same Wi-Fi network on your mobile device and PC.

      • Click Pair device with pairing code: (can be accessed via long press on wireless debugging) to display IP, port, and pairing code.

      • On your PC, enter the command adb pair <ip address>:<port> and provide the pairing code when prompted. If adb is not recognized, you may need to add the android-sdk's platform-tools folder to your PATH or execute this command from there.

      • You can verify the ADB device is successfully connected by entering adb devices in the terminal.

  • iOS:
    • Install Xcode, accept Xcode license and login with your Apple Developer account.

    • If you are using Xcode 14 or earlier, install ios-deploy and set path to ios-deploy in the Editor Settings (see Export ⇾ iOS ⇾ iOS Deploy).

    • For running on device:
      • Associare il dispositivo mobile a un Mac.

      • Abilitare la modalità sviluppatore sul dispositivo.

      • Il dispositivo può essere collegato tramite USB o rete locale.

      • Assicurarsi che il dispositivo sia sulla stessa rete locale e che sia selezionata l'interfaccia di rete corretta nelle impostazioni dell'editor (vedere Rete ⇾ Debug ⇾ Host remoto). Per impostazione predefinita, l'editor è in ascolto solo per le connessioni su localhost.

    • Lo schermo del dispositivo dovrebbe essere sbloccato.

  • Piattaforme desktop:
    • Abilitare Distribuzione SSH in remoto e configurare le impostazioni di connessione nelle impostazioni di esportazione del progetto.

  • Assicurarsi che sia presente una preimpostazione di esportazione segnata come Eseguibile per la piattaforma di destinazione (Android, iOS o Web).

  • Se tutto è configurato correttamente e senza errori, nell'angolo in alto a destra dell'editor appariranno le icone specifiche della piattaforma.

  • Cliccare sul pulsante per esportare sulla piattaforma desiderata con un clic.

../../_images/remote_debug.webp

Risoluzione dei problemi

Android

If you can't see the device in the list of devices when running the adb devices command in a terminal, it will not be visible by Godot either. To resolve this:

  • Check if USB debugging is enabled and authorized on the device. Try unlocking your device and accepting the authorization prompt if you see any. If you can't see this prompt, running adb devices on your PC should make the authorization prompt appear on the device.

  • Try revoking the debugging authorization in the device's developer settings, then follow the steps again.

  • Try using USB debugging instead of wireless debugging or vice versa. Sometimes, one of those can work better than the other.

  • Su Linux, potrebbero mancare le regole udev necessarie affinché il dispositivo sia riconosciuto.

Web

Normalmente, il server web avviato dall'editor è accessibile solo da localhost. Ciò significa che il server web non può essere raggiunto da altri dispositivi sulla rete locale o su Internet (se è configurato il port forwarding sul router). Questo viene fatto per motivi di sicurezza, poiché potresti non voler consentire ad altri dispositivi di accedere al progetto esportato durante la fase di test. Il collegamento a localhost impedisce inoltre il popup del firewall quando si utilizza la distribuzione con un clic per la piattaforma web.

Per rendere il server web locale accessibile tramite la rete locale, è necessario modificare l'impostazione dell'editor Esporta > Web > Host HTTP in 0.0.0.0. È inoltre necessario abilitare Esporta > Web > Usa TLS poiché SharedArrayBuffer richiede una connessione sicura per funzionare, a meno che non ci si connetta a localhost. Tuttavia, poiché altri client si connetteranno a un dispositivo remoto, l'uso di TLS è assolutamente necessario in questo caso.

Per rendere il server web locale accessibile tramite Internet, è necessario inoltrare la porta Esporta > Web > Porta HTTP specificata nelle impostazioni dell'editor (predefinita su 8060) in TCP sul router. Solitamente si fa accedendo all'interfaccia web del router e aggiungendo una regola NAT per la porta in questione. Per le connessioni IPv6, è invece necessario consentire la porta nel firewall IPv6 del router. Come per i dispositivi di rete locale, è inoltre necessario abilitare Esporta > Web > Usa TLS.

Nota

Quando Usa TLS è abilitato, il browser web visualizzerà un avviso poiché Godot utilizzerà un certificato autofirmato temporaneo. È possibile ignorarlo e bypassare l'avviso cliccando su Avanzate e quindi su Procedi a (indirizzo).

Se si dispone di un certificato SSL/TLS considerato attendibile dai browser, è possibile specificare i percorsi dei file della chiave e del certificato in Esporta > Web > Chiave TLS e Esporta > Web > Certificato TLS. Questa opzione funziona solo se il progetto è accessibile tramite un nome di dominio incluso nel certificato TLS.

Avvertimento

Quando si utilizza la distribuzione con un clic su progetti diversi, è possibile che venga visualizzato un progetto precedentemente modificato. Ciò è dovuto al fatto che la cache del service worker non viene svuotata automaticamente. Consultare Risoluzione dei problemi per istruzioni su come annullare la registrazione del service worker, operazione che svuoterà la cache e risolverà il problema.