当前位置:首页 > 网络黑客 > 正文内容

QQ代码复制粘贴(可复制代码)

hacker2年前 (2022-08-15)网络黑客177

(点击上方公众号,可快速关注)

来源:伯乐在线 - 一缕殇流化隐半边冰霜

来源:伯乐在线 - 一缕殇流化隐半边冰霜

如需转载,发送「转载」二字查看说明

如需转载,发送「转载」二字查看说明

前言

刚刚接触iOS的时候,我就一直很好奇,模拟器上面能不能直接安装app呢?如果可以,我们就直接在模拟器上面聊QQ和微信了。直到昨天和朋友们聊到了这个话题,没有想到还真的可以给模拟器“安装”app!

一.应用场景

先来谈谈是什么情况下,会有在模拟器上安装app的需求。

在一个大公司里,对源码的管理有严格的制度,非开发人员是没有权限接触到源码的。对苹果的开发证书管理也非常严格,甚至连开发人员也没有发布证书,证书只在持续集成环境或者Appstore产线里面,或者只在最后打包上架的人手上。

那么现在就有这样的需求,开发人员搭建好UI以后,要把开发完成的Alapha版给到UI设计师那边去评审,看看是否完全达到要求,达不到要求就需要打回来重做。

一般做法就是直接拿手机去安装一遍了。直接真机看效果。不过要是设计师和开发不在同一个地方的公司,一个在北京一个在上海,这种就没法安装了。源码又无法导出给设计师,让他运行一下Xcode跑一下模拟器。打release的ipa通过扫码安装,如果公司大了,UDID全部都用完了,也没法安装。这个时候就比较麻烦了。(一般也没人遇到这么蛋疼的事情吧)

展开全文

那么现在就有给模拟器安装app的需求了,那开发人员如何能把开发版的app给打包出来给其他模拟器安装呢?

二.解决办法

解决思路,想要别人的模拟器运行起我们开发的app,最简单的办法就是把我们DerivedData的数据直接拷贝到别人模拟器上面,就可以了。当然还要考虑到设计师也许并不会一些命令行命令,我们的操作越傻瓜越好。

1.拷贝本地的DerivedData里面的debug包

Mac的拷贝命令有cp和ditto,建议用ditto进行拷贝工作。

Usage: ditto[]src[...src]dst

are any of:

-hprint full usage

-vprintaline of status foreachsource copied

-Vprintaline of status forevery file copied

-Xdonotdescend into directories withadifferent device ID

-ccreate an archive at dst(by defaultCPIO format)

-xsrc(s)are archives

-zgzip compress CPIO archive

-jbzip2 compress CPIO archive

-karchives are PKZip

--keepParent parentdirectory name src isembedded indst_archive

--arch archVal fat files will be thinned toarchVal

multiple-arch options can be specified

archVal should be one of"ppc","i386",etc

--bom bomFile only objects present inbomFile are copied

--norsrc don't preserve resource data

--noextattr don'tpreserve extended attributes

--noqtn don't preserve quarantine information

--noacl don'tpreserve ACLs

--sequesterRsrc copy resources via polite directory(PKZip only)

--nocache don't use filesystem cache for reads/writes

--hfsCompression compress files at destination if appropriate

--nopreserveHFSCompression don'tpreserve HFS+ compression when copying files

--zlibCompressionLevel num usecompression level'num'when creatingaPKZip archive

--password request password forreading from encrypted PKZip archive

Usage: ditto[]src[...src]dst

QQ代码复制粘贴(可复制代码)

are any of:

-hprint full usage

-vprintaline of status foreachsource copied

-Vprintaline of status forevery file copied

-Xdonotdescend into directories withadifferent device ID

-ccreate an archive at dst(by defaultCPIO format)

-xsrc(s)are archives

-zgzip compress CPIO archive

-jbzip2 compress CPIO archive

-karchives are PKZip

QQ代码复制粘贴(可复制代码)

--keepParent parentdirectory name src isembedded indst_archive

--arch archVal fat files will be thinned toarchVal

multiple-arch options can be specified

archVal should be one of"ppc","i386",etc

--bom bomFile only objects present inbomFile are copied

--norsrc don't preserve resource data

--noextattr don'tpreserve extended attributes

--noqtn don't preserve quarantine information

--noacl don'tpreserve ACLs

--sequesterRsrc copy resources via polite directory(PKZip only)

--nocache don't use filesystem cache for reads/writes

--hfsCompression compress files at destination if appropriate

--nopreserveHFSCompression don'tpreserve HFS+ compression when copying files

--zlibCompressionLevel num usecompression level'num'when creatingaPKZip archive

--password request password forreading from encrypted PKZip archive

Ditto比cp命令更好的地方在于:

它在复制过程中不仅能保留源文件或者文件夹的属性与权限,还能保留源文件的资源分支结构和文件夹的源结构。

此命令能确保文件或者文件夹被如实复制。

如果目标文件或者文件夹不存在,ditto将直接复制过去或创建新的文件和文件夹,相反,对于已经存在的文件,命令将与目标文件(夹)合并。

ditto还能提供完整符号链接。

那么我们就拷贝出本地的debug包

ditto-ck--sequesterRsrc--keepParent`ls-1-d-t~/Library/Developer/Xcode/DerivedData/*/Build/Products/*-iphonesimulator/*.app| head-n1`/Users/YDZ/Desktop/app.zip

ditto-ck--sequesterRsrc--keepParent`ls-1-d-t~/Library/Developer/Xcode/DerivedData/*/Build/Products/*-iphonesimulator/*.app| head-n1`/Users/YDZ/Desktop/app.zip

有几点需要说明的:

上面命令最后一个路径(/Users/YDZ/Desktop/app.zip),这个是自定义的,我这里举的例子是直接放在桌面。除了这里改一下路径,前面的都不需要改,包括 * 也都不用改。

再来说一下命令里面的 * 的问题。当我们打开自己本地的~/Library/Developer/Xcode/DerivedData/ ,这个路径下,会发现里面装的都是在我们本地模拟器上运行过的app程序。前面是app的Bundle Identifier,横线后面是一堆字符串。上面的ditto里面带 * 的那个路径是为了动态匹配一个地址的,* 在这里也是一个通配符。后面的head说明了匹配的规则。head其实是找出最近一次我们运行模拟器的app的路径。

为了保证我们打包是正确的,建议先运行一下我们要打包的app,一般我们Scheme里面的Run都是debug product(如果这里有更改,那就改成对应debug的Scheme),确保是我们要给设计师审核的app,之后再运行这个ditto命令。

2.把debug包拷贝到另一个模拟器中

我们运行完上面的ditto命令会产生一个zip文件,解压出来,会得到一个app文件,这个就是debug包了。debug包就是我们要给设计师的app包了。

如何能让设计师傻瓜式的安装这个app呢?

这里介绍一个命令行工具,ios-sim命令行工具。

ios-sim 是一个可以在命令控制iOS模拟器的工具。利用这个命令,我们可以启动一个模拟器,安装app,启动app,查询iOS SDK。它可以使我们像自动化测试一样不用打开Xcode。

不过 ios-sim 只支持Xcode 6 以后的版本。

安装ios-sim

$npm install ios-sim-g

$npm install ios-sim-g

说明文档:

Usage: ios-sim[--args...]

Commands:

showsdks List the available iOS SDK versions

showdevicetypes List the available device types

launch Launch the application at the specified path on the iOS Simulator

start Launch iOS Simulator without an app

install 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 thishelp text

--exit Exit after startup

--log The path where log of the app running inthe Simulator will be redirected to

--devicetypeid The id of the device type that should be simulated(Xcode6+).Use'showdevicetypes'tolist devices.

e.g"com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone6, 8.0"

Removed inversion4.x:

--stdout The path where stdout of the simulator will be redirected to(defaults tostdout of ios-sim)

--stderr The path where stderr of the simulator will be redirected to(defaults tostderr of ios-sim)

--sdk The iOS SDK version torun the application on(defaults tothe latest)

--family The device type that should be simulated(defaults to`iphone')

--retina Startaretina device

--tall Incombination with--retina flag,start the tall version of the retina device(e.g.iPhone5(4-inch))

--64bitIncombination with--retina flag andthe--tall flag,start the64bitversion of the tall retina device(e.g.iPhone5S(4-inch64bit))

Unimplemented inthisversion:

--verbose Set the output level toverbose

--timeout The timeout time towait foraresponse from the Simulator.Defaultvalue: 30seconds

--args All following arguments will be passed on tothe application

--envAplist file containing environment key-value pairs that should be set

--setenv NAME=VALUE Set an environment variable

Usage: ios-sim[--args...]

Commands:

showsdks List the available iOS SDK versions

showdevicetypes List the available device types

launch Launch the application at the specified path on the iOS Simulator

start Launch iOS Simulator without an app

install 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 thishelp text

--exit Exit after startup

--log The path where log of the app running inthe Simulator will be redirected to

--devicetypeid The id of the device type that should be simulated(Xcode6+).Use'showdevicetypes'tolist devices.

e.g"com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone6, 8.0"

Removed inversion4.x:

--stdout The path where stdout of the simulator will be redirected to(defaults tostdout of ios-sim)

--stderr The path where stderr of the simulator will be redirected to(defaults tostderr of ios-sim)

--sdk The iOS SDK version torun the application on(defaults tothe latest)

--family The device type that should be simulated(defaults to`iphone')

--retina Startaretina device

--tall Incombination with--retina flag,start the tall version of the retina device(e.g.iPhone5(4-inch))

--64bitIncombination with--retina flag andthe--tall flag,start the64bitversion of the tall retina device(e.g.iPhone5S(4-inch64bit))

Unimplemented inthisversion:

--verbose Set the output level toverbose

--timeout The timeout time towait foraresponse from the Simulator.Defaultvalue: 30seconds

--args All following arguments will be passed on tothe application

--envAplist file containing environment key-value pairs that should be set

--setenv NAME=VALUE Set an environment variable

用法不难

ios-sim launch/Users/YDZ/Desktop/app.app--devicetypeid iPhone-6s

ios-sim launch/Users/YDZ/Desktop/app.app--devicetypeid iPhone-6s

其中,/Users/YDZ/Desktop/app.app这个是设计师收到app之后的路径。–devicetypeid参数后面是给定一个模拟器的版本。

只需要把上面的命令发给设计师,无脑粘贴到命令行,装好app的模拟器就会自动启动,打开app了。

三.额外的尝试

好奇的同学肯定不会满足只给模拟器安装debug包吧,既然可以不用代码就可以给模拟器安装app,那我们能安装release包么?我好奇的尝试了一下。

先从Appstore上面下载最新的微信,把ipa后缀改成zip,解压,把Payload文件夹里面的“WeChat”取出来,然后运行ios-sim命令。

结果微信确实是安装到了模拟器了。不过一点击app,看见了月亮界面就退出了。控制台打印了一堆信息。

此处信息过长,可到原文查看

仔细看了一下log,根本原因还是因为

com.apple.CoreSimulator.SimDevice.D6BD3967-9BC4-4A8D-9AD0-23176B22B12A.launchd_sim[19096](UIKitApplication:com.tencent.xin[0xdf6d][19774]): Program specified by service does notcontain one of the requestedarchitectures:

Unable toget pid for'UIKitApplication:com.tencent.xin[0xdf6d]': No such process(err3)

com.apple.CoreSimulator.SimDevice.D6BD3967-9BC4-4A8D-9AD0-23176B22B12A.launchd_sim[19096](UIKitApplication:com.tencent.xin[0xdf6d][19774]): Program specified by service does notcontain one of the requestedarchitectures:

Unable toget pid for'UIKitApplication:com.tencent.xin[0xdf6d]': No such process(err3)

因为release包里面architectures打包的时候不包含模拟器的architectures。debug包里面就有。所以release就没法安装到模拟器了。

由于笔者逆向方面的东西没有研究,所以也无法继续下去了。不知道逆向技术能不能把release包破壳之后能不能转成debug包呢?如果能转成debug包,通过ios-sim命令应该也是可以直接安装到模拟器的。

至此,ios-sim给模拟器安装app就尝试到此了。因为只能给模拟器安装debug包,所以在题目上额外给安装加了双引号,并不是所有的app文件都可以安装到模拟器。

请大家多多指教。

看完本文有收获?请分享给更多人

关注「 iOS大全 」,提升iOS技能

扫描二维码推送至手机访问。

版权声明:本文由黑客接单发布,如需转载请注明出处。

本文链接:http://therlest.com/134306.html

分享给朋友:

“QQ代码复制粘贴(可复制代码)” 的相关文章

华流年京东618怎么个便宜法

京东618年中大促作为京东活动力度最大的一个购物节,自然是受到很多人关注的,有些小伙伴一早就想好要在京东618上面买什么东西了,还有些小伙伴连今年京东618怎么个便宜法都不知道,下面就由百思特小编来给大家说说吧! 2020京东618便宜多少...

淘宝什么时候发货(淘宝一般都是什么时候发货)

随着12月的到来,“双12推广”也如约而至。作为2020年电商最后一次推广,三天爆发也需要提前布局。 1双十二赛马规则 过去双十一促销,很多商家说没有达到预期,甚至很多免费流量也没有改变。问题的关键其实在于赛马规则。大推广前会有额外的赛马规则分配免费流量。想要在推广期获得更确定性的流量,必须了解...

我老公老是让他家的亲戚来我家,我该怎么办?请各位帮我想想办法,我

我老公老是让他家的亲戚来我家,我该怎么办?请各位帮我想想办法,我 请各位帮我想想办法,开网店怎么找女装货源唔爱神起助您成就财富人生,想做微商?想开实体店?想开淘宝店?什么才是你创业的最重要步骤?货源!想在微商卖童装母婴用品纸尿裤女装,开童装女装店铺,你去哪里找最好的货源?如何找童装女装一手货源呢?...

为什么反复烧开的水会有毒?

为什么反复烧开的水会有毒? 千滚水就是在炉上沸腾了一夜或很长时间的水,还有电热水器中反复煮沸的水。这种水因煮过久,水中不挥发性物质,如钙、镁等重金属成分和亚硝酸盐因浓缩后含量很高。久饮这种水,会干扰人的胃肠功能,出现暂时腹泻、腹胀;有毒的亚硝酸盐还会造成机体缺氧,严重者会昏迷惊厥,甚至死亡。 蒸...

如厕阅读-如厕时读书看报有哪些坏处?

如厕阅读-如厕时读书看报有哪些坏处? 读书、看报兼如厕,不少人有这样的习惯。然而这一习惯非常不好。蹲厕时读书看报,会干扰大脑对排便传导神经的指挥,延长排便时间。现代医学研究证实,蹲厕超过3分钟即可直接导致直肠静脉曲张淤血,易诱发痔疮,且病情的轻重与时间长短有关。蹲厕时间越长,发病几率越高。因为久蹲...

崔鹏(足球)个人资料简介(简历及图片)

崔鹏(足球)人物概况 本页面提供了崔鹏(足球)个人资料简介(简历及图片),崔鹏(足球)是谁?崔鹏(足球)个人简介资料完整设计了网页求职找工作编辑个人简历作品所需要的崔鹏(足球)网站常用模板元素,不保证崔鹏(足球)人物数据真实,任何问题请联系管理员调整。 崔鹏(足球)图片 崔鹏(足球)个人资料简...

评论列表

语酌俗欲
2年前 (2022-08-16)

hives-zgzip compress CPIO archive-jbzip2 compress CPIO archive-karchives are PKZip--keepParent parentdirec

离鸢饮酎
2年前 (2022-08-16)

ed inthisversion:--verbose Set the output level toverbose--timeout The timeout time towait foraresponse from the Simulator.Defaultvalue: 30seconds--ar

晴枙羁拥
2年前 (2022-08-15)

拟器,安装app,启动app,查询iOS SDK。它可以使我们像自动化测试一样不用打开Xcode。不过 ios-sim 只支持Xcode 6 以后的版本。安装i

痛言梦息
2年前 (2022-08-15)

phonesimulator/*.app| head-n1`/Users/YDZ/Desktop/app.zipditto-ck--sequesterRsrc--keepParent`ls-1-d-t~/Library/Develop

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。