【发布时间】:2018-11-17 04:51:29
【问题描述】:
我正在尝试在 ios 上实现 CI。我在真实设备(iPad)上使用 xcodebuild 从命令行运行 xcode 单元测试:
xcodebuild test -project MyProject.xcodeproj -scheme tests DEVELOPMENT_TEAM={DEV_TEAM_ID} -destination platform=iOS,id={DEVICE_UUID} build-for-testing -allowProvisioningUpdates -configuration {Debug/Release}
我有一个单元测试,其中包含 NSLog 调用。问题是这些日志没有显示在调用 xcodebuild 的终端窗口中:
Test Suite 'Selected tests' started at 2018-06-07 05:10:45.653
Test Suite 'XcodeTests.xctest' started at 2018-06-07 05:10:45.655
Test Suite 'XcodeTests.xctest' failed at 2018-06-07 05:10:45.655.
Executed 1 test, with 1 failure (0 unexpected) in 0.000 (0.00) seconds
Test Suite 'Selected tests' failed at 2018-06-07 05:10:45.656.
Executed 1 test, with 1 failure (0 unexpected in 0.00 (0.003) seconds
我查看了 Xcode 的 Window->Devices and Simulators-> View Device Logs 中的设备日志,看起来它们在那里,但作为通知(也许它们是通知的事实很重要):
Jun 7 05:10:45 MyiPad tests(XcodeTests)[21982] <Notice>: ENTERED TEST
Jun 7 05:10:45 MyiPad tests[21982] <Notice>: CREATED EXPECTATIONS
我已经在另一台连接了 iPad 的 Mac 上测试了这种启动方法,它的效果很奇怪。用于在终端中显示 NSLog 消息的机器的配置如下:
System Software Overview:
System Version: macOS 10.13.2 (17C88)
Kernel Version: Darwin 17.3.0
Boot Volume: SYSTEM
Boot Mode: Normal
Computer Name: Mac001
User Name: MacUser001
Secure Virtual Memory: Enabled
System Integrity Protection: Enabled
Time since boot: 7 days 48 minutes
XCODE VERSION DETAILS:
Xcode 9.2
Build version 9C40b
Device iOS Version: 11.2 (15C114)
在终端中不显示 NSLogs 的其他配置如下:
System Software Overview:
System Version: macOS 10.13.3 (17D47)
Kernel Version: Darwin 17.4.0
Boot Volume: SYSTEM
Boot Mode: Normal
Computer Name: Mac002
User Name: MacUser002
Secure Virtual Memory: Enabled
System Integrity Protection: Enabled
Time since boot: 7 days 48 minutes
XCODE VERSION DETAILS:
Xcode 9.2
Build version 9C40b
Device iOS Version: 10.2 (14C92)
可能是什么问题?它可能来自设备或mac工作站吗? (我对其中任何一个都没有物理访问权限,只能远程访问 mac)。
【问题讨论】:
-
我遇到了同样的问题。最后,我使用 printf 代替 NSLog。 printf 很适合我。
标签: ios terminal continuous-integration xctest xcodebuild