美文网首页工程架构
基于xcrun的工程构建

基于xcrun的工程构建

作者: 平谦 | 来源:发表于2018-04-17 17:47 被阅读80次

1.使用NSTask调用shell

- (NSString *)cmd:(NSString *)cmd
{
    // 初始化并设置shell路径
    NSTask *task = [[NSTask alloc] init];
    [task setLaunchPath: @"/bin/bash"];
    // -c 用来执行string-commands(命令字符串),也就说不管后面的字符串里是什么都会被当做shellcode来执行
    NSArray *arguments = [NSArray arrayWithObjects: @"-c", cmd, nil];
    [task setArguments: arguments];
    
    // 新建输出管道作为Task的输出
    NSPipe *pipe = [NSPipe pipe];
    [task setStandardOutput: pipe];
    
    // 开始task
    NSFileHandle *file = [pipe fileHandleForReading];
    [task launch];
    
    // 获取运行结果
    NSData *data = [file readDataToEndOfFile];
    return [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
}`

### 2.一些shell命令
真机安装:

fruitstrap  -b  UCWEB.app/XXX.ipa

模拟器安装:

xcrun simctl install booted <XXX.app/XXX.ipa>

卸载应用(万能法,杀伤力极大,直接重置设备):


The solution that I came up with is to use the command

xcrun simctl erase [device ID]
只是卸载应用(删除设备的安装数据)

rm -rf  

  ~/Library/Developer/CoreSimulator/Devices/

       <device id>/data/Containers/Data/Application/* 

查看设备:

instruemtns -s  devices

更加详细:

The device ID can be obtained from running

xcrun simctl list

### 3.xcrun simctl openurl booted "alipays://"
这个命令唤起支付宝,是schememanager的底层实现原理。
https://github.com/daryl5/iScheme 作者:凌万

相关文章

网友评论

    本文标题:基于xcrun的工程构建

    本文链接:https://www.haomeiwen.com/subject/muepkftx.html