**
我不会为任何命令“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。 我如何从项目中设置路径?