Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 使用NSTask启动Ruby脚本(深圳)_Objective C_Ruby_Xcode - Fatal编程技术网

Objective c 使用NSTask启动Ruby脚本(深圳)

Objective c 使用NSTask启动Ruby脚本(深圳),objective-c,ruby,xcode,Objective C,Ruby,Xcode,我正在尝试使用以下脚本生成IPA: 以下是我目前拥有的代码: -(void)startBuildIPAForProject:(NSString*)path { task = [[NSTask alloc] init]; [task setLaunchPath:@"/bin/bash"]; [task setCurrentDirectoryPath:path]; [task setArguments:@[@"ipa build",@"-c",@"Release"]]

我正在尝试使用以下脚本生成IPA:

以下是我目前拥有的代码:

-(void)startBuildIPAForProject:(NSString*)path
{
    task = [[NSTask alloc] init];
    [task setLaunchPath:@"/bin/bash"];
    [task setCurrentDirectoryPath:path];
    [task setArguments:@[@"ipa build",@"-c",@"Release"]];

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

    NSFileHandle *file;
    file = [pipe fileHandleForReading];

    [task launch];

    NSData *data;
    data = [file readDataToEndOfFile];

    NSString *string;
    string = [[NSString alloc] initWithData: data
                                   encoding: NSUTF8StringEncoding];
    NSLog(@"task output: %@",string);

    [task waitUntilExit];
}
执行[task launch]时,我从控制台获得以下输出:

/bin/bash: ipa build: No such file or directory
当我使用常规终端时,ipa构建正在工作(也就是说,它告诉我当前目录中不存在Xcode项目)


我有点迷路了,所以非常感谢您的帮助。

ipa脚本需要位于应用程序的
路径
环境变量中(或与二进制文件位于同一目录中)。一个简单的解决方法是在参数中指定
ipa
的完整绝对路径。i、 e.改变:

[task setArguments:@[@"ipa build",@"-c",@"Release"]];


或者,如果您没有使用bash进行任何其他操作,只需使用setLaunchPath直接调用ipa实用程序即可。您也可以将ipa与应用程序捆绑在一起。这样你就不必依赖用户来安装它了。
[task setArguments:@[@"/full/path/to/ipa build",@"-c",@"Release"]];