Skip to content

Commit 0d9a280

Browse files
committed
Provide feedback per device if successful deploy. Update readme with latest commands.
1 parent f4d99b3 commit 0d9a280

3 files changed

Lines changed: 81 additions & 58 deletions

File tree

README.md

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ Reboot, grab a screenshot, running iOS versions, kill specific running processes
88
Retrieve a list of iOS versions running on devices for all machines or a specific one.
99
- `screen iPhone1, iPhone2`
1010
Take a screenshot of specific devices.
11+
- `reopen iPhone1,iPhone2`
12+
Send restart game request to device IP address.
1113
- `reboot iPhone1,iPhone2`
1214
Reboot specific devices.
1315
- `shutdown iPhone1,iPhone2`
1416
Shutdown specific devices.
17+
- `resign https://mega.nz/file/yS7C#Dsh0lZDkk 1.33.0b1 iPhone1,iPhone2`
18+
Download latest app, resign, and deploy to specified devices (leave blank or specify `All` for all devices connected to the machine)
19+
- `deploy iPhone1,iPhone2`
20+
Deploy latest already signed app from releases folder to specific devices.
1521
- `rm-pogo iPhone1,iPhone2`
1622
Removes Pokemon Go from specific devices.
1723
- `kill usbmuxd [machine_name]`
@@ -27,22 +33,22 @@ Reboot, grab a screenshot, running iOS versions, kill specific running processes
2733
### Prerequisites:
2834
__idevicediagnostics__
2935
1. `brew update`
30-
2. `brew uninstall --ignore-dependencies libimobiledevice`
31-
3. `brew uninstall --ignore-dependencies usbmuxd`
32-
4. `brew install --HEAD usbmuxd`
33-
5. `brew unlink usbmuxd`
34-
6. `brew link usbmuxd`
35-
7. `brew install --HEAD libimobiledevice`
36-
8. `brew unlink libimobiledevice && brew link libimobiledevice`
37-
9. `brew install --HEAD ideviceinstaller`
38-
10. `brew unlink ideviceinstaller && brew link ideviceinstaller`
39-
11. `sudo chmod -R 777 /var/db/lockdown/`
36+
1. `brew uninstall --ignore-dependencies libimobiledevice`
37+
1. `brew uninstall --ignore-dependencies usbmuxd`
38+
1. `brew install --HEAD usbmuxd`
39+
1. `brew unlink usbmuxd`
40+
1. `brew link usbmuxd`
41+
1. `brew install --HEAD libimobiledevice`
42+
1. `brew unlink libimobiledevice && brew link libimobiledevice`
43+
1. `brew install --HEAD ideviceinstaller`
44+
1. `brew unlink ideviceinstaller && brew link ideviceinstaller`
45+
1. `sudo chmod -R 777 /var/db/lockdown/`
4046

4147
__ios-deploy__
4248
If you have previously installed ios-deploy via npm, uninstall it:
4349
1. `sudo npm uninstall -g ios-deploy`
4450
Install ios-deploy via Homebrew by running:
45-
2. `brew install ios-deploy`
51+
1. `brew install ios-deploy`
4652

4753
__MegaTools__
4854
1. `brew install megatools`
@@ -55,24 +61,23 @@ wget https://raw.githubusercontent.com/versx/iPhoneController/master/install.sh
5561

5662
**Manually:**
5763
1. `wget https://dotnetwebsite.azurewebsites.net/download/dotnet-core/scripts/v1/dotnet-install.sh && chmod +x dotnet-install.sh && ./dotnet-install.sh --version 2.1.803 && rm dotnet-install.sh`
58-
2. `git clone https://github.com/versx/iPhoneController`
59-
3. `cd iPhoneController`
60-
4. `~/.dotnet/dotnet build`
61-
5. `cp config.example.json bin/Debug/netcoreapp2.1/config.json`
62-
6. `cd bin/Debug/netcoreapp2.1`
63-
7. `nano config.json` / `vi config.json` (Fill out config)
64-
8. `~/.dotnet/dotnet iPhoneController.dll`
64+
1. `git clone https://github.com/versx/iPhoneController`
65+
1. `cd iPhoneController`
66+
1. `~/.dotnet/dotnet build`
67+
1. `cp config.example.json bin/config.json`
68+
1. `cd bin`
69+
1. `nano config.json` / `vi config.json` (Fill out config)
70+
1. `~/.dotnet/dotnet iPhoneController.dll`
6571

6672
## Updating
6773
1. `git pull` (from root of folder)
68-
2. `~/.dotnet/dotnet build`
69-
3. `cd bin/Debug/netcoreapp2.1`
70-
4. `~/.dotnet/dotnet iPhoneController.dll`
74+
1. `~/.dotnet/dotnet build`
75+
1. `cd bin`
76+
1. `~/.dotnet/dotnet iPhoneController.dll`
7177

7278
## Running
73-
From the `bin/debug/netcoreapp2.1` folder type the following:
79+
From the `bin` folder type the following:
7480
`~/.dotnet/dotnet iPhoneController.dll`
7581

7682
## TODO
77-
- Localization
78-
- Reinstall PoGo
83+
- Localization

src/Commands/PhoneControl.cs

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public async Task ListDevicesAsync(CommandContext ctx,
5454

5555
var devices = Device.GetAll();
5656
var keys = devices.Keys.ToList();
57-
var pages = SplitPages();
57+
var pages = SplitDevicePages();
5858
for (var i = 0; i < pages.Count; i++)
5959
{
6060
var msg = pages[i];
@@ -373,30 +373,32 @@ public async Task ResignPoGoAsync(CommandContext ctx,
373373
[Description("iPhone names i.e. `iPhoneAB1SE`. Comma delimiter supported `iPhoneAB1SE,iPhoneCD2SE`"), RemainingText]
374374
string phoneNames = Strings.All)
375375
{
376-
//if (!HasRequiredRoles(ctx.Member))
377-
//{
378-
// await ctx.RespondAsync($":no_entry: {ctx.User.Username} Unauthorized permissions.");
379-
// return;
380-
//}
376+
if (!HasRequiredRoles(ctx.Member))
377+
{
378+
await ctx.RespondAsync($":no_entry: {ctx.User.Username} Unauthorized permissions.");
379+
return;
380+
}
381381

382-
//if (!IsValidChannel(ctx.Channel.Id))
383-
// return;
382+
if (!IsValidChannel(ctx.Channel.Id))
383+
return;
384384

385385
var deployer = new IpaDeployer(_dep.Config.Developer, _dep.Config.ProvisioningProfile)
386386
{
387387
ResignApp = true,
388388
};
389389
await ctx.RespondAsync("Starting resign...");
390-
var result = deployer.Resign(megaLink, version);
391-
if (!result)
390+
if (!deployer.Resign(megaLink, version))
392391
{
393392
await ctx.RespondAsync($"Failed to resign IPA");
394393
return;
395394
}
396-
await ctx.RespondAsync($"Resign complete, deploying...");
395+
await ctx.RespondAsync($"Resign complete, starting deployment to {phoneNames}...");
397396

398-
deployer.Deploy(deployer.SignedReleaseFileName, phoneNames);
399-
await ctx.RespondAsync($"Deploy complete");
397+
var result = deployer.Deploy(deployer.SignedReleaseFileName, phoneNames);
398+
var successful = result.Item1.Count > 0 ? $"Successfully deployed app to:\n{string.Join(", ", result.Item1)}" : null;
399+
var failed = result.Item2.Count > 0 ? $"Failed to deploy app to:\n{string.Join(", ", result.Item2)}" : null;
400+
// TODO: Check for content length over 2048 and split messages if so
401+
await ctx.RespondAsync($"{successful}\n{failed}");
400402
}
401403

402404
[
@@ -407,14 +409,14 @@ public async Task DeployPoGoAsync(CommandContext ctx,
407409
[Description("iPhone names i.e. `iPhoneAB1SE`. Comma delimiter supported `iPhoneAB1SE,iPhoneCD2SE`"), RemainingText]
408410
string phoneNames = Strings.All)
409411
{
410-
//if (!HasRequiredRoles(ctx.Member))
411-
//{
412-
// await ctx.RespondAsync($":no_entry: {ctx.User.Username} Unauthorized permissions.");
413-
// return;
414-
//}
412+
if (!HasRequiredRoles(ctx.Member))
413+
{
414+
await ctx.RespondAsync($":no_entry: {ctx.User.Username} Unauthorized permissions.");
415+
return;
416+
}
415417

416-
//if (!IsValidChannel(ctx.Channel.Id))
417-
// return;
418+
if (!IsValidChannel(ctx.Channel.Id))
419+
return;
418420

419421
var devices = Device.GetAll();
420422
var deployAppDevices = new List<string>(phoneNames.RemoveSpaces());
@@ -443,11 +445,19 @@ public async Task DeployPoGoAsync(CommandContext ctx,
443445
_logger.Info($"Deploying to device {device.Name} ({device.Uuid})...");
444446
var output = Shell.Execute("ios-deploy", args, out var exitCode, true);
445447
_logger.Debug($"{device.Name} ({device.Uuid}) Deployment output: {output}");
446-
if (output.Length > 2000)
448+
var success = output.ToLower().Contains($"[100%] installed package {appPath}");
449+
if (success)
450+
{
451+
await ctx.RespondAsync($"Deployed {appPath} to {device.Name} ({device.Uuid}) successfully.");
452+
}
453+
else
447454
{
448-
output = string.Join("", output.TakeLast(1900));
455+
if (output.Length > 2000)
456+
{
457+
output = string.Join("", output.TakeLast(1900));
458+
}
459+
await ctx.RespondAsync($"Failed to deploy {appPath} to {device.Name} ({device.Uuid})\nOutput: {output}");
449460
}
450-
await ctx.RespondAsync($"Deployed Pokemon Go to {device.Name} ({device.Uuid})\r\nOutput: {output}");
451461
}
452462
});
453463
}
@@ -511,7 +521,7 @@ private bool IsValidChannel(ulong channelId)
511521
return _dep.Config.ChannelIds.Count == 0 || _dep.Config.ChannelIds.Contains(channelId);
512522
}
513523

514-
private List<string> SplitPages()
524+
private List<string> SplitDevicePages()
515525
{
516526
var devices = Device.GetAll();
517527
var keys = devices.Keys.ToList();

src/Deployment/IpaDeployer.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,18 @@ public bool Resign(string megaLink, string version)
8888
return result;
8989
}
9090

91-
public void Deploy(string ipaPath, string deviceNames = Strings.All)
91+
public (List<string>, List<string>) Deploy(string appPath, string deviceNames = Strings.All)
9292
{
93+
var successful = new List<string>();
94+
var failed = new List<string>();
9395
var devices = Device.GetAll();
9496
var deployAppDevices = new List<string>(deviceNames.RemoveSpaces());
9597
if (string.Compare(deviceNames, Strings.All, true) == 0)
9698
{
9799
deployAppDevices = devices.Keys.ToList();
98100
}
99-
_logger.Info($"Deploying app {ipaPath} to {string.Join(", ", deployAppDevices)}");
101+
_logger.Info($"Deploying app {appPath} to {string.Join(", ", deployAppDevices)}");
102+
// TODO: Provide better feedback of successful and failed deployments
100103
Parallel.ForEach(deployAppDevices, deviceName =>
101104
{
102105
if (!devices.ContainsKey(deviceName))
@@ -106,13 +109,24 @@ public void Deploy(string ipaPath, string deviceNames = Strings.All)
106109
else
107110
{
108111
var device = devices[deviceName];
109-
var args = $"--id {device.Uuid} --bundle {ipaPath}";
112+
var args = $"--id {device.Uuid} --bundle {appPath}";
110113
_logger.Info($"Deploying to device {device.Name} ({device.Uuid})...");
111114
var output = Shell.Execute("ios-deploy", args, out var exitCode, true);
112-
_logger.Info($"Deployed Pokemon Go to {device.Name} ({device.Uuid})\r\nOutput: {output}");
115+
var success = output.ToLower().Contains($"[100%] installed package {appPath}");
116+
if (success)
117+
{
118+
successful.Add(device.Name);
119+
_logger.Info($"Deployed {appPath} to {device.Name} ({device.Uuid}) successfully.");
120+
}
121+
else
122+
{
123+
failed.Add(device.Name);
124+
_logger.Warn($"Failed to deploy {appPath} to {device.Name} ({device.Uuid})\nOutput: {output}");
125+
}
113126
// TODO: OnDeployCompleted event
114127
}
115128
});
129+
return (successful, failed);
116130
}
117131

118132
public static string GetLatestAppPath()
@@ -125,7 +139,6 @@ public static string GetLatestAppPath()
125139
return files.FirstOrDefault();
126140
}
127141

128-
129142
private bool InternalResignApp(string ipaPath, string ipaPathSigned)
130143
{
131144
_logger.Info($"Beginning to resign {ipaPath}");
@@ -178,7 +191,6 @@ private bool InternalResignApp(string ipaPath, string ipaPathSigned)
178191
foreach (var file in files)
179192
{
180193
_logger.Debug($"Signing component {file}...");
181-
//Shell.Execute(Strings.CodesignPath, $@"--continue -f -s ""{_developer}"" --entitlements {entitlementsPath} {file}", out var _);
182194
Codesign(file, true, entitlementsPath);
183195
}
184196

@@ -189,9 +201,6 @@ private bool InternalResignApp(string ipaPath, string ipaPathSigned)
189201
var destinationConfigPath = Path.Combine(pogoDir, "config.json");
190202
_logger.Info($"Copying custom config to payload folder.");
191203
File.Copy(configPath, destinationConfigPath);
192-
193-
//_logger.Info($"Signing custom config.json...");
194-
//Codesign(destinationConfigPath);
195204
}
196205
else
197206
{
@@ -205,7 +214,6 @@ private bool InternalResignApp(string ipaPath, string ipaPathSigned)
205214
foreach (var frameworkFile in frameworkFiles)
206215
{
207216
_logger.Debug($"Signing framework {frameworkFile}");
208-
//Shell.Execute(Strings.CodesignPath, $@"-f -s ""{_developer}"" {frameworkFile}", out var _);
209217
Codesign(frameworkFile);
210218
}
211219

0 commit comments

Comments
 (0)