Mac OS程序,命令adb

时间:2017-10-24 19:33:42

标签: objective-c macos adb

**

我不会为任何命令“adb”创建程序 但我对Path adb有疑问。 Xcode无法使用我的本地adb。

**

@implementation ViewController

NSString *adbPath = @"/Users/marchello/.nexustools";

NSString* runADBCommand(NSString *cmd)
{
    NSTask *adbDevices = [[NSTask alloc] init];
    [adbDevices setLaunchPath:@"/bin/sh"];
    [adbDevices setLaunchPath:adbPath];


    adbDevices.arguments = @[cmd];

    NSPipe *pipe;
    pipe = [NSPipe pipe];
    [adbDevices setStandardOutput:pipe];

    NSFileHandle *file;
    file = [pipe fileHandleForReading];

    [adbDevices launch];

    NSData *data;
    data = [file readDataToEndOfFile];

    NSString *adbComOutput;
    adbComOutput = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

    return adbComOutput;
}


- (void)viewDidLoad {
    [super viewDidLoad];


}



-(IBAction)run:(id)sender{

    runADBCommand(@"adb devices");
}

如果我在项目中插入adb。 我如何从项目中设置路径?

enter image description here

0 个答案:

没有答案