Skip to content

Commit 8fa40bf

Browse files
committed
refactor(cli): finalize mobile platform integration
1 parent 2a8b1a1 commit 8fa40bf

1 file changed

Lines changed: 28 additions & 18 deletions

File tree

‎src/commands/MobileCommand.cpp‎

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,11 +1199,6 @@ namespace
11991199
return 1;
12001200
}
12011201

1202-
const std::string installTask =
1203-
options.release
1204-
? ":app:installRelease"
1205-
: ":app:installDebug";
1206-
12071202
out.banner("Vix Mobile \u00b7 run");
12081203
out.row("project", options.projectDirectory.string());
12091204
out.row("package", options.packageName, out.theme.cyan());
@@ -1213,20 +1208,33 @@ namespace
12131208
{
12141209
out.info_line("Installing Android mobile shell...");
12151210

1216-
const int installResult =
1217-
run_system_command(
1218-
make_gradle_command(
1219-
options.projectDirectory,
1220-
installTask,
1221-
options.gradleCommand));
1211+
vix::ui::AndroidProject project;
1212+
if (!options.gradleCommand.empty())
1213+
{
1214+
project.set_gradle_command(options.gradleCommand);
1215+
}
12221216

1223-
if (installResult != 0)
1217+
const vix::ui::Result<fs::path> built = project.build(
1218+
options.projectDirectory,
1219+
options.release
1220+
? vix::ui::AndroidBuildType::Release
1221+
: vix::ui::AndroidBuildType::Debug,
1222+
vix::ui::AndroidArtifact::Apk);
1223+
if (built.is_failed())
12241224
{
1225-
out.error("Android mobile install failed.");
1226-
out.error_hint("Make sure Gradle, Android SDK, and adb are installed.");
1227-
out.error_hint("Make sure an Android device or emulator is connected.");
1225+
out.error("Android mobile build failed.");
1226+
out.error_hint(built.error_message());
12281227
out.error_hint("You can pass --gradle <command> if Gradle is not in PATH.");
1229-
return installResult;
1228+
return 1;
1229+
}
1230+
1231+
const int install_result = run_system_command(
1232+
"adb install -r " + shell_quote(built.value().string()));
1233+
if (install_result != 0)
1234+
{
1235+
out.error("Android mobile install failed.");
1236+
out.error_hint("Make sure adb is installed and a device or emulator is connected.");
1237+
return install_result;
12301238
}
12311239
}
12321240

@@ -1484,6 +1492,7 @@ namespace
14841492
return 0;
14851493
}
14861494

1495+
#if defined(__APPLE__)
14871496
bool resolve_ios_bundle_identifier(
14881497
const fs::path &directory,
14891498
std::string &bundle,
@@ -1520,6 +1529,7 @@ namespace
15201529
error = "cannot resolve iOS bundle identifier from generated Xcode project";
15211530
return false;
15221531
}
1532+
#endif
15231533

15241534
int run_build_ios(const std::vector<std::string> &args)
15251535
{
@@ -1976,8 +1986,8 @@ namespace
19761986

19771987
out.success("Android mobile shell generated.");
19781988

1979-
out.hint("Next: cd " + options.outputDirectory.string() + " && gradle :app:assembleDebug");
1980-
out.hint("Later this will be wrapped by: vix mobile build android");
1989+
out.hint("Next: vix mobile build android --project " +
1990+
options.outputDirectory.string());
19811991

19821992
return 0;
19831993
}

0 commit comments

Comments
 (0)