给iOS 模拟器“安装”app文件

上传人:油条 文档编号:31775944 上传时间:2018-02-09 格式:DOC 页数:9 大小:59KB
返回 下载 相关 举报
给iOS 模拟器“安装”app文件_第1页
第1页 / 共9页
给iOS 模拟器“安装”app文件_第2页
第2页 / 共9页
给iOS 模拟器“安装”app文件_第3页
第3页 / 共9页
给iOS 模拟器“安装”app文件_第4页
第4页 / 共9页
给iOS 模拟器“安装”app文件_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《给iOS 模拟器“安装”app文件》由会员分享,可在线阅读,更多相关《给iOS 模拟器“安装”app文件(9页珍藏版)》请在金锄头文库上搜索。

1、给 iOS 模拟器“安装”app 文件前言刚刚接触 iOS 的时候,我就一直很好奇,模拟器上面能不能直接安装 app 呢?如果可以,我们就直接在模拟器上面聊 QQ 和微信了。直到昨天和朋友们聊到了这个话题,没有想到还真的可以给模拟器“安装”app!一.应用场景先来谈谈是什么情况下,会有在模拟器上安装 app 的需求。在一个大公司里,对源码的管理有严格的制度,非开发人员是没有权限接触到源码的。对苹果的开发证书管理也非常严格,甚至连开发人员也没有发布证书,证书只在持续集成环境或者 Appstore 产线里面,或者只在最后打包上架的人手上。那么现在就有这样的需求,开发人员搭建好 UI 以后,要把开发

2、完成的 Alapha版给到 UI 设计师那边去评审,看看是否完全达到要求,达不到要求就需要打回来重做。一般做法就是直接拿手机去安装一遍了。直接真机看效果。不过要是设计师和开发不在同一个地方的公司,一个在北京一个在上海,这种就没法安装了。源码 又无法导出给设计师,让他运行一下 Xcode 跑一下模拟器。打 release 的 ipa通过扫码安装,如果公司大了,UDID 全部都用完了,也没法安装。这 个时候就比较麻烦了。(一般也没人遇到这么蛋疼的事情吧)那么现在就有给模拟器安装 app 的需求了,那开发人员如何能把开发版的 app给打包出来给其他模拟器安装呢?二.解决办法解决思路,想要别人的模拟器

3、运行起我们开发的 app,最简单的办法就是把我们 DerivedData 的数据直接拷贝到别人模拟器上面,就可以了。当然还要考虑到设计师也许并不会一些命令行命令,我们的操作越傻瓜越好。1.拷贝本地的 DerivedData 里面的 debug 包Mac 的拷贝命令有 cp 和 ditto,建议用 ditto 进行拷贝工作。Usage: ditto src . src dst are any of:-h print full usage-v print a line of status for each source copied-V print a line of status for eve

4、ry file copied-X do not descend into directories with a different device ID-c create an archive at dst (by default CPIO format)-x src(s) are archives-z gzip compress CPIO archive-j bzip2 compress CPIO archive-k archives are PKZip-keepParent parent directory name src is embedded in dst_archive-arch a

5、rchVal fat files will be thinned to archValmultiple -arch options can be specifiedarchVal should be one of ppc, i386, etc-bom bomFile only objects present in bomFile are copied-norsrc dont preserve resource data-noextattr dont preserve extended attributes-noqtn dont preserve quarantine information-n

6、oacl dont preserve ACLs-sequesterRsrc copy resources via polite directory (PKZip only)-nocache dont use filesystem cache for reads/writes -hfsCompression compress files at destination if appropriate-nopreserveHFSCompression dont preserve HFS+ compression when copying files-zlibCompressionLevel num u

7、se compression level num when creating a PKZip archive-password request password for reading from encrypted PKZip archiveDitto 比 cp 命令更好的地方在于:1. 它在复制过程中不仅能保留源文件或者文件夹的属性与权限,还能保留源文件的资源分支结构和文件夹的源结构。2. 此命令能确保文件或者文件夹被如实复制。3. 如果目标文件或者文件夹不存在,ditto 将直接复制过去或创建新的文件和文件夹,相反,对于已经存在的文件,命令将与目标文件(夹)合并。4. ditto 还能提供

8、完整符号链接。那么我们就拷贝出本地的 debug 包ditto -ck -sequesterRsrc -keepParent ls -1 -d -t /Library/Developer/Xcode/DerivedData/*/Build/Products/*-iphonesimulator/*.app | head -n 1 /Users/YDZ/Desktop/app.zip有几点需要说明的:1.上面命令最后一个路径(/Users/YDZ/Desktop/app.zip),这个是自定义的,我这里举的例子是直接放在桌面。除了这里改一下路径,前面的都不需要改,包括 * 也都不用改。2.3.再来

9、说一下命令里面的 * 的问题。当我们打开自己本地的/Library/Developer/Xcode/DerivedData/ ,这个路径下,会发现里面装的都是在我们本地模拟器上运行过的 app 程序。前面是 app 的 Bundle Identifier,横线后面是一堆字符串。上面的 ditto 里面带 * 的那个路径是为了动态匹配一个地址的,* 在这里也是一个通配符。后面的 head 说明了匹配的规则。head 其实是找出最近一次我们运行模拟器的 app 的路径。4.为了保证我们打包是正确的,建议先运行一下我们要打包的 app,一般我们Scheme 里面的 Run 都是 debug prod

10、uct(如果这里有更改,那就改成对应 debug的 Scheme),确保是我们要给设计师审核的 app,之后再运行这个 ditto 命令。2.把 debug 包拷贝到另一个模拟器中我们运行完上面的 ditto 命令会产生一个 zip 文件,解压出来,会得到一个 app文件,这个就是 debug 包了。 debug 包就是我们要给设计师的 app 包了。如何能让设计师傻瓜式的安装这个 app 呢?这里介绍一个命令行工具,ios-sim 命令行工具。ios-sim 是一个可以在命令控制 iOS 模拟器的工具。利用这个命令,我们可以启动一个模拟器,安装 app,启动 app,查询 iOS SDK。它

11、可以使我们像自动化测试一样不用打开 Xcode。不过 ios-sim 只支持 Xcode 6 以后的版本。安装 ios-sim$ npm install ios-sim -g说明文档:Usage: ios-sim -args .Commands:showsdks List the available iOS SDK versionsshowdevicetypes List the available device typeslaunch Launch the application at the specified path on the iOS Simulatorstart Launch i

12、OS Simulator without an appinstall Install the application at the specified path on the iOS Simulator without launching the app Options:-version Print the version of ios-sim-help Show this help text-exit Exit after startup-log The path where log of the app running in the Simulator will be redirected

13、 to-devicetypeid The id of the device type that should be simulated (Xcode6+). Use showdevicetypes to list devices.e.g com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone6, 8.0Removed in version 4.x:-stdout The path where stdout of the simulator will be redirected to (defaults to stdout of ios-si

14、m)-stderr The path where stderr of the simulator will be redirected to (defaults to stderr of ios-sim)-sdk The iOS SDK version to run the application on (defaults to the latest)-family The device type that should be simulated (defaults to iphone)-retina Start a retina device-tall In combination with -retina flag, start the tall version of the retina device (e.g. iPhone 5 (4-i

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号