feat:doric run ios support devices
This commit is contained in:
parent
130461769a
commit
6eee43df9b
@ -25,5 +25,8 @@
|
|||||||
"@rollup/plugin-image": "^2.0.5",
|
"@rollup/plugin-image": "^2.0.5",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^8.4.0"
|
"@rollup/plugin-node-resolve": "^8.4.0"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"ios-deploy": "^1.11.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import { glob } from "./util";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import xml2js, { Element } from "xml-js";
|
import xml2js, { Element } from "xml-js";
|
||||||
import inquirer from "inquirer";
|
import inquirer from "inquirer";
|
||||||
import { constants } from "buffer";
|
|
||||||
import { blue } from "colors";
|
|
||||||
|
|
||||||
export async function run(platform: string) {
|
export async function run(platform: string) {
|
||||||
switch (platform.toLowerCase()) {
|
switch (platform.toLowerCase()) {
|
||||||
@ -183,7 +181,7 @@ async function runiOS() {
|
|||||||
[
|
[
|
||||||
"-workspace", workspace,
|
"-workspace", workspace,
|
||||||
"-scheme", scheme,
|
"-scheme", scheme,
|
||||||
"-sdk", "iphonesimulator",
|
...selectedDevice.isSimulator ? ["-sdk", "iphonesimulator",] : [],
|
||||||
"-derivedDataPath", "build"
|
"-derivedDataPath", "build"
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
@ -197,8 +195,9 @@ async function runiOS() {
|
|||||||
console.log("Compile error".red);
|
console.log("Compile error".red);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const iOSAPPs = await glob("**/*.app", { cwd: path.resolve(iOSDir, "build") });
|
const iOSAPPs = await glob(
|
||||||
|
`**/*${selectedDevice.isSimulator ? "iphonesimulator" : "iphoneos"}/*.app`,
|
||||||
|
{ cwd: path.resolve(iOSDir, "build") });
|
||||||
if (iOSAPPs?.length !== 1) {
|
if (iOSAPPs?.length !== 1) {
|
||||||
console.log("Cannot find built app".red);
|
console.log("Cannot find built app".red);
|
||||||
return;
|
return;
|
||||||
@ -207,8 +206,23 @@ async function runiOS() {
|
|||||||
|
|
||||||
console.log("Built iOS APP".green, iOSAPP.blue);
|
console.log("Built iOS APP".green, iOSAPP.blue);
|
||||||
console.log("====================");
|
console.log("====================");
|
||||||
await Shell.exec("xcrun", ["instruments", "-w", selectedDevice.deviceId])
|
|
||||||
console.log("Installing APP to".green, selectedDevice.name.blue);
|
console.log("Installing APP to".green, selectedDevice.name.blue);
|
||||||
await Shell.exec("xcrun", ["simctl", "install", selectedDevice.deviceId, iOSAPP]);
|
if (selectedDevice.isSimulator) {
|
||||||
await Shell.exec("xcrun", ["simctl", "launch", selectedDevice.deviceId, "pub.doric.ios.hellodoric"]);
|
const pxjFile = path.resolve(iOSDir, (await glob("**/project.pbxproj", { cwd: iOSDir }))[0]);
|
||||||
|
const pxjContent = await fs.promises.readFile(pxjFile, "utf-8");
|
||||||
|
const bundleId = /PRODUCT_BUNDLE_IDENTIFIER\s=\s(\S*?);/g.exec(pxjContent)?.[1];
|
||||||
|
await Shell.exec("xcrun", ["instruments", "-w", selectedDevice.deviceId])
|
||||||
|
await Shell.exec("xcrun", ["simctl", "install", selectedDevice.deviceId, iOSAPP]);
|
||||||
|
await Shell.exec("xcrun", ["simctl", "launch", selectedDevice.deviceId, bundleId || `pub.doric.ios.${scheme.toLowerCase()}`]);
|
||||||
|
} else {
|
||||||
|
const iosDeploy = path.resolve("node_modules", ".bin", "ios-deploy")
|
||||||
|
await Shell.exec(
|
||||||
|
iosDeploy,
|
||||||
|
[
|
||||||
|
"--id", selectedDevice.deviceId,
|
||||||
|
"--justlaunch",
|
||||||
|
"--debug",
|
||||||
|
"--bundle", iOSAPP
|
||||||
|
])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user