fix(build/ios): prompt user for device rather than failing (#1702)

This commit is contained in:
Tommy Nguyen 2022-06-29 11:34:54 +02:00 коммит произвёл GitHub
Родитель 76b6fb70f2
Коммит 565b308286
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 46 добавлений и 13 удалений

Просмотреть файл

@ -0,0 +1,5 @@
---
"@rnx-kit/build": patch
---
iOS: Prompt user for device rather than failing

2
.github/workflows/rnx-build.yml поставляемый
Просмотреть файл

@ -102,7 +102,7 @@ jobs:
security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${RUNNER_TEMP}/${KEYCHAIN_FILE}"
security import "${RUNNER_TEMP}/${CERTIFICATE_FILE}" -k "${RUNNER_TEMP}/${KEYCHAIN_FILE}" -t cert -f pkcs12 -P "${P12_PASSWORD}" -A -T '/usr/bin/codesign' -T '/usr/bin/security'
security set-key-partition-list -S apple-tool:,apple: -k ${KEYCHAIN_PASSWORD} "${RUNNER_TEMP}/${KEYCHAIN_FILE}"
security set-key-partition-list -S apple-tool:,apple: -k ${KEYCHAIN_PASSWORD} "${RUNNER_TEMP}/${KEYCHAIN_FILE}" 1> /dev/null
security list-keychain -d user -s "${RUNNER_TEMP}/${KEYCHAIN_FILE}" login.keychain
- name: Build iOS app
run: |

Просмотреть файл

@ -36,11 +36,21 @@ An experimental tool for building your apps in the cloud.
npm run rnx-build --platform <platform>
```
| Flag | Description |
| :------------- | :---------------------------------------------------------------------- |
| -p, --platform | Supported platforms are `android`, `ios`, `macos`, `windows` |
| --device-type | [Optional] Supported device types are `device`, `emulator`, `simulator` |
| --project-root | [Optional] Path to the root of the project |
| Flag | Description |
| :----------------- | :---------------------------------------------------------------------- |
| `-p`, `--platform` | Supported platforms are `android`, `ios`, `macos`, `windows` |
| `--device-type` | [Optional] Supported device types are `device`, `emulator`, `simulator` |
| `--project-root` | [Optional] Path to the root of the project |
### Android: Install Android Studio
In order to launch the build artifact on device, you need to install Android
Studio. Once installed, go into **Preferences****Appearance & Behavior**
**System Settings** ❭ **Android SDK**, and install **Android SDK Build-Tools**
and **Android SDK Platform-Tools**.
If you want to run apps on the Android Emulator, follow the instructions here:
[Run apps on the Android Emulator](https://developer.android.com/studio/run/emulator).
### iOS: Install Signing Certificate and Provisioning Profile

Просмотреть файл

@ -1,5 +1,6 @@
import * as os from "node:os";
import * as path from "node:path";
import * as readline from "node:readline";
import type { Ora } from "ora";
import { untar } from "../archive";
import { retry } from "../async";
@ -195,7 +196,14 @@ async function install(device: Device, app: string): Promise<Error | null> {
async function launch(device: Device, app: string): Promise<Error | null> {
const { type, udid } = device;
if (type === "device") {
const launch = iosDeploy("--id", udid, "--bundle", app, "--justlaunch");
const launch = iosDeploy(
"--id",
udid,
"--bundle",
app,
"--justlaunch",
"--noinstall"
);
const { stderr, status } = await launch;
if (status !== 0) {
return new Error(stderr);
@ -230,11 +238,21 @@ async function selectDevice(
: (device) => device.type === "device";
const physicalDevice = devices.find(search);
if (!physicalDevice) {
const message = deviceName
? `Failed to find device: ${deviceName}`
: "Failed to find a physical device";
spinner.fail(message);
return null;
// Device detection can sometimes be flaky. Prompt the user to make sure
// a device is properly plugged in, and try again.
const prompt = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const device = deviceName ? `device: ${deviceName}` : "a physical device";
await new Promise((resolve) =>
prompt.question(
`Failed to find ${device} - please make sure it is properly plugged in.\n\nPress any key to try again`,
resolve
)
);
prompt.close();
return selectDevice(deviceName, deviceType, spinner);
}
const { name, osVersion } = physicalDevice;

Просмотреть файл

@ -102,7 +102,7 @@ jobs:
security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${RUNNER_TEMP}/${KEYCHAIN_FILE}"
security import "${RUNNER_TEMP}/${CERTIFICATE_FILE}" -k "${RUNNER_TEMP}/${KEYCHAIN_FILE}" -t cert -f pkcs12 -P "${P12_PASSWORD}" -A -T '/usr/bin/codesign' -T '/usr/bin/security'
security set-key-partition-list -S apple-tool:,apple: -k ${KEYCHAIN_PASSWORD} "${RUNNER_TEMP}/${KEYCHAIN_FILE}"
security set-key-partition-list -S apple-tool:,apple: -k ${KEYCHAIN_PASSWORD} "${RUNNER_TEMP}/${KEYCHAIN_FILE}" 1> /dev/null
security list-keychain -d user -s "${RUNNER_TEMP}/${KEYCHAIN_FILE}" login.keychain
- name: Build iOS app
run: |