"README.md" did not exist on "c0bf4c3cb43abb90945591f5c3edb6ac45be2afd"
Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// LogViewController.m
// xchighlight
//
// Created by EthanRDoesMC on 3/18/21.
//
#import "LogViewController.h"
#import <Foundation/Foundation.h>
#import "NSTask.h"
@interface LogViewController ()
@property (strong, nonatomic) IBOutlet UITextView *logField;
@end
@implementation LogViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSLog(@"Hello, World!");
NSMutableArray *arguments = [[NSMutableArray alloc] init];
//[arguments addObject:@"/Users/ethanrdoesmc/Downloads/mautrix-imessage-amd64/mautrix-imessage"];
[arguments addObject:@"-c/User/Documents/mautrix-imessage-armv7/config.yaml"]; // Any arguments you want here...
[arguments addObject:@"-r/User/Documents/mautrix-imessage-armv7/registration.yaml"]; // Any arguments you want here...
NSTask* task = [[NSTask alloc] init];
task.launchPath = @"/User/Documents/mautrix-imessage-armv7/mautrix-imessage";
task.arguments = arguments;
task.currentDirectoryPath = @"/User/Documents/mautrix-imessage-armv7/";
NSLog(@"tell me about %@", task);
NSMutableDictionary *defaultEnv = [[NSMutableDictionary alloc] initWithDictionary:[[NSProcessInfo processInfo] environment]];
[defaultEnv setObject:@"YES" forKey:@"NSUnbufferedIO"];
// [defaultEnv setObject:@"/Users/ethanrdoesmc/" forKey:@"HOME"];
task.environment = defaultEnv;
task.standardOutput = [NSPipe pipe];
[[task.standardOutput fileHandleForReading] setReadabilityHandler:^(NSFileHandle *file) {
NSData *data = [file availableData]; // this will read to EOF, so call only once
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"Task output! %@", string);
dispatch_async(dispatch_get_main_queue(), ^{
self->_logField.text = [self->_logField.text stringByAppendingString: string];
[self->_logField scrollRangeToVisible: NSMakeRange(self->_logField.text.length, 0)];
});
}];
[task launch];
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end