最新消息:20210917 已从crifan.com换到crifan.org

【已解决】macOS中用XCode编译和运行WebDriverAgentRunner项目

Xcode crifan 1031浏览 0评论
折腾:
【已解决】Win中VMWare中macOS的wda直接用xcodebuild编译报错:error No profiles for were found Xcode couldn’t find any iOS App Development provisioning profiles
期间,去试试用XCode打开xcode项目,并去编译和最后测试运行:
也是None,没问题。
不过看到有Code Sign了:
然后去看看新的环境中Xcode中是否正常
果然是 code sign的问题
所以去:
【已解决】macOS中XCode登录苹果开发者账号
然后点击 
Download Manual Profiles
双击账号,显示弹框:
另外点击 Manage Certificates,和双击效果一样的弹框。
然后回去看看
显示正常了。自动code sign了。
然后再去执行:
把 Product-》Scheme-》切换到:WebDriverAgentRunner
此时 设备已选择了 识别出的 iPhone7P了:
然后去试试:
Product-》Test
开始 Building
结果报错:
-》
/Users/crifanli/dev/DevRoot/appcrawler/iOSAutomation/refer/WebDriverAgent/WebDriverAgentLib/Routing/FBWebServer.m:12:9: 'RoutingHTTPServer/RoutingConnection.h' file not found
很明显,缺少头文件
-》需要去 carthage 更新才可以。
参考之前的:
【已解决】XCode编译最新版WebDriverAgent
./Scripts/bootstrap.sh -d
结果:
●  ./Scripts/bootstrap.sh -d
zsh: permission denied: ./Scripts/bootstrap.sh
去加上可执行权限
✘ crifanli@crifanlideMac  ~/dev/DevRoot/appcrawler/iOSAutomation/refer/WebDriverAgent   master ●  ll Scripts/bootstrap.sh
-rw-r--r--  1 crifanli  staff   2.4K  6 23 09:14 Scripts/bootstrap.sh
crifanli@crifanlideMac  ~/dev/DevRoot/appcrawler/iOSAutomation/refer/WebDriverAgent   master ●  sudo chmod ugo+x Scripts/bootstrap.sh
Password:
crifanli@crifanlideMac  ~/dev/DevRoot/appcrawler/iOSAutomation/refer/WebDriverAgent   master ●  ll Scripts/bootstrap.sh
-rwxr-xr-x  1 crifanli  staff   2.4K  6 23 09:14 Scripts/bootstrap.sh
然后再去:
brew install carthage
./Scripts/bootstrap.sh -d
log
 brew install carthage
Updating Homebrew...
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/carthage-0.35.0.mojave.bottle.tar.gz
##############                                                            19.9%^C
✘ crifanli@crifanlideMac  ~/dev/DevRoot/appcrawler/iOSAutomation/refer/WebDriverAgent   master ●  brew install carthage
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/carthage-0.35.0.mojave.bottle.tar.gz
######################################################################## 100.0%
######################################################################## 100.0%
==> Pouring carthage-0.35.0.mojave.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d


zsh completions have been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
🍺  /usr/local/Cellar/carthage/0.35.0: 8 files, 5.3MB
crifanli@crifanlideMac  ~/dev/DevRoot/appcrawler/iOSAutomation/refer/WebDriverAgent   master ● 
crifanli@crifanlideMac  ~/dev/DevRoot/appcrawler/iOSAutomation/refer/WebDriverAgent   master ●  which carthage
/usr/local/bin/carthage
再去:
crifanli@crifanlideMac  ~/dev/DevRoot/appcrawler/iOSAutomation/refer/WebDriverAgent   master ●  ./Scripts/bootstrap.sh -d
Fetching dependencies
*** Checking out YYCache at "1.1.0"
*** Checking out RoutingHTTPServer at "v1.2.2"
*** Cloning RoutingHTTPServer
*** Cloning YYCache
A shell task (/usr/bin/env git clone --bare --quiet https://github.com/appium/YYCache.git /Users/crifanli/Library/Caches/org.carthage.CarthageKit/dependencies/YYCache) failed with exit code 128:
fatal: unable to access 'https://github.com/appium/YYCache.git/': Failed to connect to 127.0.0.1 port 51837: Connection refused
是当前代理没开。去开启代理。
✘ crifanli@crifanlideMac  ~/dev/DevRoot/appcrawler/iOSAutomation/refer/WebDriverAgent   master ●  ./Scripts/bootstrap.sh -d
Fetching dependencies
*** Checking out RoutingHTTPServer at "v1.2.2"
*** Checking out YYCache at "1.1.0"
*** Cloning RoutingHTTPServer
*** Cloning YYCache
A shell task (/usr/bin/env git clone --quiet https://github.com/appium/CocoaHTTPServer.git /Users/crifanli/dev/DevRoot/appcrawler/iOSAutomation/refer/WebDriverAgent/Carthage/Checkouts/RoutingHTTPServer/External/CocoaHTTPServer) failed with exit code 128:
fatal: unable to access 'https://github.com/appium/CocoaHTTPServer.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
好像是代理节点不够好?再去换个节点
✘ crifanli@crifanlideMac  ~/dev/DevRoot/appcrawler/iOSAutomation/refer/WebDriverAgent   master ●  ./Scripts/bootstrap.sh -d
Fetching dependencies
*** Checking out RoutingHTTPServer at "v1.2.2"
*** Checking out YYCache at "1.1.0"
*** Cloning YYCache
A shell task (/usr/bin/env git clone --bare --quiet https://github.com/appium/YYCache.git /Users/crifanli/Library/Caches/org.carthage.CarthageKit/dependencies/YYCache) failed with exit code 128:
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
再换个节点。可以继续了。
✘ crifanli@crifanlideMac  ~/dev/DevRoot/appcrawler/iOSAutomation/refer/WebDriverAgent   master ●  ./Scripts/bootstrap.sh -d
Fetching dependencies
*** Checking out YYCache at "1.1.0"
*** Checking out RoutingHTTPServer at "v1.2.2"
*** Cloning YYCache
*** xcodebuild output can be found in /var/folders/v1/7j6bkrx95nz239_l7q6p37440000gn/T/carthage-xcodebuild.nqvSSG.log
2020-06-29 16:58:20.884 carthage[7054:158181] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9816)
***  Skipped installing RoutingHTTPServer.framework binary due to the error:
    "GitHub API request failed: networkError(Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9816, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x7f817453b830 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9816, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9816}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://api.github.com/repos/appium/RoutingHTTPServer/releases/tags/v1.2.2?, NSErrorFailingURLStringKey=https://api.github.com/repos/appium/RoutingHTTPServer/releases/tags/v1.2.2?, _kCFStreamErrorDomainKey=3})"


    Falling back to building from the source
2020-06-29 16:58:20.899 carthage[7054:158359] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9816)
***  Skipped installing YYCache.framework binary due to the error:
    "GitHub API request failed: networkError(Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9816, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x7f81744460a0 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9816, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9816}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://api.github.com/repos/appium/YYCache/releases/tags/1.1.0?, NSErrorFailingURLStringKey=https://api.github.com/repos/appium/YYCache/releases/tags/1.1.0?, _kCFStreamErrorDomainKey=3})"


    Falling back to building from the source
*** Building scheme "RoutingHTTPServer iOS" in RoutingHTTPServer.xcodeproj
*** Building scheme "RoutingHTTPServer tvOS" in RoutingHTTPServer.xcodeproj
*** Building scheme "YYCache iOS" in YYCache.xcodeproj
*** Building scheme "YYCache tvOS" in YYCache.xcodeproj
终于结束了,完成了。
再去XCode中,先clean,再build
再去连接iPhone
虽然 clean后,问题依旧,但是在连接了iPhone7P后,直接去test试试
果然没了头文件找不到的错误了。
过了会,编译完成了,点击显示终端,可以看到希望的输出了:
2020-06-29 17:04:17.065903+0800 WebDriverAgentRunner-Runner[10283:4673599] Running tests...
Test Suite 'All tests' started at 2020-06-29 17:04:19.944
Test Suite 'WebDriverAgentRunner.xctest' started at 2020-06-29 17:04:19.945
Test Suite 'UITestingUITests' started at 2020-06-29 17:04:19.946
2020-06-29 17:04:19.949709+0800 WebDriverAgentRunner-Runner[10283:4673599] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2020-06-29 17:04:19.974427+0800 WebDriverAgentRunner-Runner[10283:4673785] [MC] Invalidating cache
2020-06-29 17:04:19.979307+0800 WebDriverAgentRunner-Runner[10283:4673599] [MC] Reading from public effective user settings.
2020-06-29 17:04:20.019229+0800 WebDriverAgentRunner-Runner[10283:4673599] [User Defaults] Couldn't write value for key KeyboardAutocorrection in CFPrefsPlistSource<0x2816e8700> (Domain: com.apple.Preferences, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
2020-06-29 17:04:20.037787+0800 WebDriverAgentRunner-Runner[10283:4673787] [MC] Invalidating cache
2020-06-29 17:04:20.040834+0800 WebDriverAgentRunner-Runner[10283:4673599] [MC] Reading from public effective user settings.
2020-06-29 17:04:20.042882+0800 WebDriverAgentRunner-Runner[10283:4673599] [User Defaults] Couldn't write value for key KeyboardPrediction in CFPrefsPlistSource<0x2816e8700> (Domain: com.apple.Preferences, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
2020-06-29 17:04:20.043675+0800 WebDriverAgentRunner-Runner[10283:4673599] [User Defaults] Couldn't write value for key KeyboardShowPredictionBar in CFPrefsPlistSource<0x2816e8700> (Domain: com.apple.Preferences, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
2020-06-29 17:04:20.073714+0800 WebDriverAgentRunner-Runner[10283:4673599] [User Defaults] Couldn't write value for key DidShowGestureKeyboardIntroduction in CFPrefsPlistSource<0x2816e8700> (Domain: com.apple.Preferences, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
Test Case '-[UITestingUITests testRunner]' started.
    t =     0.00s Start Test at 2020-06-29 17:04:20.075
    t =     0.00s Set Up
2020-06-29 17:04:20.105258+0800 WebDriverAgentRunner-Runner[10283:4673599] Built at Jun 29 2020 17:03:33
2020-06-29 17:04:20.130000+0800 WebDriverAgentRunner-Runner[10283:4673599] ServerURLHere->http://192.168.31.59:8100<-ServerURLHere
2020-06-29 17:04:20.141867+0800 WebDriverAgentRunner-Runner[10283:4673786] Using singleton test manager
被测wda的服务端的地址是:
http://192.168.31.59:8100
如此,即可。
【总结】
此处,macOS中用XCode去运行WebDriverAgent.xcodeproj的过程是:
(1)Xcode中登录Apple账号
-》后续打开的XCode项目属性中,才能 自动的code sign和获取到provision file。
(2)安装缺失的头文件
如果没安装过carthage,先要安装:
brew install carthage
如果脚本没可执行权限,要先加上可执行权限:
sudo chmod ugo+x Scripts/bootstrap.sh
去运行脚本,下载依赖的库(和头文件):
./Scripts/bootstrap.sh -d
(3)XCode中,选择Target设备:此处的真机iPhone7P,再去:
Product->Test
即可测试和运行处的wda的test manger,最终输出:
2020-06-29 17:04:20.105258+0800 WebDriverAgentRunner-Runner[10283:4673599] Built at Jun 29 2020 17:03:33
2020-06-29 17:04:20.130000+0800 WebDriverAgentRunner-Runner[10283:4673599] ServerURLHere->http://192.168.31.59:8100<-ServerURLHere
2020-06-29 17:04:20.141867+0800 WebDriverAgentRunner-Runner[10283:4673786] Using singleton test manager
即可。

转载请注明:在路上 » 【已解决】macOS中用XCode编译和运行WebDriverAgentRunner项目

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
92 queries in 0.180 seconds, using 23.42MB memory