Tutorial 5 - Levando para o Mobile: iOS¶
To compile iOS applications we’ll need Xcode, which is available for free from the macOS App Store. Once Xcode is installed, launch it from Applications and accept the Xcode License Agreement. Next, Xcode will show which components are built-in, and which components you may download. Select the checkbox next to iOS (followed by the current version number), and then click «Download and Install» to install it. Xcode will install the system components, followed by the iOS Simulator.
Depois de instalar o Xcode, podemos pegar nosso aplicativo e implantá-lo como um aplicativo iOS.
O processo de implantação de um aplicativo no iOS é muito semelhante ao processo de implantação como um aplicativo de desktop. Primeiro, você executa o comando create
, mas, desta vez, especificamos que queremos criar um aplicativo iOS:
(beeware-venv) $ briefcase create iOS
[helloworld] Generating application template...
Using app template: https://github.com/beeware/briefcase-iOS-Xcode-template.git, branch v0.3.18
...
[helloworld] Installing support package...
...
[helloworld] Installing application code...
Installing src/helloworld... done
[helloworld] Installing requirements...
...
[helloworld] Installing application resources...
...
[helloworld] Removing unneeded app content...
...
[helloworld] Created build/helloworld/ios/xcode
Quando isso for concluído, teremos um diretório build/helloworld/ios/xcode
contendo um projeto Xcode, bem como as bibliotecas de suporte e o código do aplicativo necessários para o aplicativo.
Em seguida, você pode usar o Briefcase para compilar o aplicativo usando briefcase build iOS
:
(beeware-venv) $ briefcase build iOS
[helloworld] Updating app metadata...
Setting main module... done
[helloworld] Building Xcode project...
...
Building... done
[helloworld] Built build/helloworld/ios/xcode/build/Debug-iphonesimulator/Hello World.app
Agora estamos prontos para executar nosso aplicativo, usando o briefcase run iOS
. Será solicitado que você selecione um dispositivo para o qual compilar; se você tiver simuladores para várias versões do SDK do iOS instalados, também poderá ser perguntado qual versão do iOS deseja usar como alvo. As opções mostradas a você podem ser diferentes das opções mostradas nesta saída - no mínimo, a lista de dispositivos provavelmente será diferente. Para nossos propósitos, não importa qual simulador você escolherá.
(beeware-venv) $ briefcase run iOS
Select simulator device:
1) iPad (10th generation)
2) iPad Air (5th generation)
3) iPad Pro (11-inch) (4th generation)
4) iPad Pro (12.9-inch) (6th generation)
5) iPad mini (6th generation)
6) iPhone 14
7) iPhone 14 Plus
8) iPhone 14 Pro
9) iPhone 14 Pro Max
10) iPhone SE (3rd generation)
> 10
In the future, you could specify this device by running:
$ briefcase run iOS -d "iPhone SE (3rd generation)::iOS 16.2"
or:
$ briefcase run iOS -d 2614A2DD-574F-4C1F-9F1E-478F32DE282E
[helloworld] Starting app on an iPhone SE (3rd generation) running iOS 16.2 (device UDID 2614A2DD-574F-4C1F-9F1E-478F32DE282E)
Booting simulator... done
Opening simulator... done
[helloworld] Installing app...
Uninstalling any existing app version... done
Installing new app version... done
[helloworld] Starting app...
Launching app... done
[helloworld] Following simulator log output (type CTRL-C to stop log)...
===========================================================================
...
Isso iniciará o simulador do iOS, instalará seu aplicativo e o iniciará. Você deverá ver o simulador iniciar e, por fim, abrir seu aplicativo iOS:

While the app is running, you’ll see a series of Simulator log output messages in the console. Typing Ctrl+C into the terminal will halt the messages in the console, but it will not close the simulator. This is so you can test new changes without restarting the simulator.
Se você souber antecipadamente qual simulador de iOS deseja usar, poderá dizer ao Briefcase para usar esse simulador fornecendo uma opção -d
(ou --device
). Usando o nome do dispositivo que você selecionou ao criar o aplicativo, execute:
$ briefcase run iOS -d "iPhone SE (3rd generation)"
Se você tiver várias versões do iOS disponíveis, o Briefcase escolherá a versão mais alta do iOS; se você quiser escolher uma versão específica do iOS, diga a ele para usar essa versão específica:
$ briefcase run iOS -d "iPhone SE (3rd generation)::iOS 15.5"
Ou você pode nomear um UDID de dispositivo específico:
$ briefcase run iOS -d 2614A2DD-574F-4C1F-9F1E-478F32DE282E
Próximos passos¶
Agora temos um aplicativo em nosso telefone! Há algum outro lugar onde possamos implantar um aplicativo BeeWare? Consulte Tutorial 6 para descobrir…