无法使脚本 'run-sonar-swift' 工作

Can not make script 'run-sonar-swift' works

我正在尝试 运行 声纳 swift。 我已经有了带插件的 sonarQube,我可以使用 url http://localhost:9000 在本地访问它。我已经安装了您可以在这里找到的所有先决条件:

https://github.com/Backelite/sonar-swift

但是当我启动 运行-sonar-swift.sh.

时,我不知道这个错误是什么

如果有人能给我带来光明,我将不胜感激。

这是我在终端命令 中 运行 时的日志 ./运行-sonar-swift.sh -v :

MacBook-Air:streamus-phoenix-ios oboujaouane$ ./run-sonar-swift.sh -v

Running run-sonar-swift.sh...

Project count is [1]

Xcode project file is: Streamus.xcodeproj

Xcode workspace file is: Streamus.xcworkspace

Xcode application scheme is: Streamus Alpha

Destination simulator is: platform=iOS Simulator,name=iPhone 6,OS=11.3

Excluded paths from coverage are: .Tests.

Creating directory sonar-reports/

Running tests + xcodebuild clean build test -workspace Streamus.xcworkspace -scheme 'Streamus Alpha' -configuration Debug -enableCodeCoverage YES -destination 'platform=iOS Simulator,name=iPhone 6,OS=11.3' -destination-timeout 60

2018-05-12 10:34:14.031 xcodebuild[32149:775290] IDETestOperationsObserverDebug: Writing diagnostic log for test session to: /var/folders/9v/vdbbf4j96hxgcxmtpntznytr0000gn/T/com.apple.dt.XCTest/IDETestRunSession-9A7EF764-6391-4C7D-9F34-066A9DFEC5E9/StreamusUITests-87E838E0-4F8F-4C19-B2AC-C2C0A274E8EC/Session-StreamusUITests-2018-05-12_103414-jhm3wz.log

2018-05-12 10:34:14.032 xcodebuild[32149:769805] [MT] IDETestOperationsObserverDebug: (98FB295E-FE60-46AA-8589-015B0DD2E617) Beginning test session StreamusUITests-98FB295E-FE60-46AA-8589-015B0DD2E617 at 2018-05-12 10:34:14.031 with Xcode 9E145 on target { SimDevice: iPhone 6 (672DE879-E48B-45DA-BFD9-D0412F51A706, iOS 11.3, Booted) } (11.3 (15E217))

2018-05-12 10:34:14.061 xcodebuild[32149:769805] [MT] IDETestOperationsObserverDebug: (458F86F6-1492-40F1-9F72-A88FC23BD985) Beginning test session StreamusTests-458F86F6-1492-40F1-9F72-A88FC23BD985 at

2018-05-12 10:34:14.061 with Xcode 9E145 on target { SimDevice: iPhone 6 (672DE879-E48B-45DA-BFD9-D0412F51A706, iOS 11.3, Booted) } (11.3 (15E217))

2018-05-12 10:34:14.061 xcodebuild[32149:770075] IDETestOperationsObserverDebug: Writing diagnostic log for test session to: /var/folders/9v/vdbbf4j96hxgcxmtpntznytr0000gn/T/com.apple.dt.XCTest/IDETestRunSession-9A7EF764-6391-4C7D-9F34-066A9DFEC5E9/StreamusTests-4F203461-1372-49B7-A806-F130F168079E/Session-StreamusTests-2018-05-12_103414-MfIreE.log 2018-05-12 10:34:30.016 xcodebuild[32149:769805]

Error Domain=IDETestOperationsObserverErrorDomain Code=14 "Test operation was canceled. If you believe this error represents a bug, please attach the log file at /var/folders/9v/vdbbf4j96hxgcxmtpntznytr0000gn/T/com.apple.dt.XCTest/IDETestRunSession-9A7EF764-6391-4C7D-9F34-066A9DFEC5E9/StreamusUITests-87E838E0-4F8F-4C19-B2AC-C2C0A274E8EC/Session-StreamusUITests-2018-05-12_103414-jhm3wz.log"

UserInfo={NSLocalizedDescription=Test operation was canceled. If you believe this error represents a bug, please attach the log file at /var/folders/9v/vdbbf4j96hxgcxmtpntznytr0000gn/T/com.apple.dt.XCTest/IDETestRunSession-9A7EF764-6391-4C7D-9F34-066A9DFEC5E9/StreamusUITests-87E838E0-4F8F-4C19-B2AC-C2C0A274E8EC/Session-StreamusUITests-2018-05-12_103414-jhm3wz.log}

2018-05-12 10:34:30.016 xcodebuild[32149:769805] Error Domain=IDETestOperationsObserverErrorDomain Code=14 "Test operation was canceled. If you believe this error represents a bug, please attach the log file at /var/folders/9v/vdbbf4j96hxgcxmtpntznytr0000gn/T/com.apple.dt.XCTest/IDETestRunSession-9A7EF764-6391-4C7D-9F34-066A9DFEC5E9/StreamusTests-4F203461-1372-49B7-A806-F130F168079E/Session-StreamusTests-2018-05-12_103414-MfIreE.log" UserInfo={NSLocalizedDescription=Test operation was canceled. If you believe this error represents a bug, please attach the log file at /var/folders/9v/vdbbf4j96hxgcxmtpntznytr0000gn/T/com.apple.dt.XCTest/IDETestRunSession-9A7EF764-6391-4C7D-9F34-066A9DFEC5E9/StreamusTests-4F203461-1372-49B7-A806-F130F168079E/Session-StreamusTests-2018-05-12_103414-MfIreE.log}

Testing failed: Linker command failed with exit code 1 (use -v to see invocation) ** TEST FAILED **

The following build commands failed:

Ld /Users/oboujaouane/Library/Developer/Xcode/DerivedData/Streamus-gwtdwpbaxrfgafdtejzjtpxyhhhq/Build/Intermediates.noindex/Streamus.build/Alpha-iphonesimulator/StreamusTests.build/Objects-normal/x86_64/StreamusTests normal x86_64

Ld /Users/oboujaouane/Library/Developer/Xcode/DerivedData/Streamus-gwtdwpbaxrfgafdtejzjtpxyhhhq/Build/Intermediates.noindex/Streamus.build/Alpha-iphonesimulator/StreamusTests.build/Objects-normal/i386/StreamusTests normal i386

(2 failures)

  • returnValue=65

  • set +x

ERROR - Command 'xcodebuild clean build test -workspace Streamus.xcworkspace -scheme Streamus Alpha -configuration Debug -enableCodeCoverage YES -destination platform=iOS Simulator,name=iPhone 6,OS=11.3 -destination-timeout 60' failed with error code: 65

提前谢谢你,

  1. 似乎错误是由于配置文件引起的。当我添加我的配置文件并再次尝试时,问题就解决了。

  2. 然后我又遇到了MessageKit的问题:“Segmentation fault: 11” 这是 CocoaPods Podfile 配置问题。 因此,我必须通过单击 Xcode 项目导航器中的 Pods,然后单击 [=83= 的目标中的 select MessageKit,将 Debug 的编译模式从 "Single File" 切换到“整个模块” ] 然后构建设置选项卡,然后在搜索器中点击“编译模式”并将“单个文件”切换为“整个模块”并重新 运行 脚本 运行-sonar-swift.sh

⚠️ 每次你进行 pod 安装/更新或可以更改的东西时 pods 你必须将 Debug 的编译模式从 "Single File" 切换到 pod 的“Whole Module”,这给你使用 -v 启动 运行-sonar.swift.sh 时出错。

  1. 之后我的问题还没有结束!事实上,我遇到了最后一个问题,它是 SwipeCellKit pod 的错误:“没有这样的模块 SwipeCellKit”。要解决此问题,请按照此处给出的说明进行操作

  2. 然后我又试了一次,脚本的其余部分开始了(SwiftLint、Tailor & Lizard),我认为这次终于好了,但是又一次发生了错误,最后出现了一条新的错误消息关于蜥蜴的脚本是:

ERROR: Error during SonarQube Scanner execution

ERROR: File MyprojectName/Domains/Repositories/Local/cacheManager.swift can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files

ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.

为了解决这个问题 inclusion/exclusion 我遵循了此处给出的答案: 通过将这些添加到 sonar.swift.excludedPathsFromCoverage 行下方的 sonar-project.properties 文件中的行:

sonar.test.inclusions=**/*Test*/**

sonar.exclusions=**/*Test*/**

我再次尝试但使用了参数 -notailor(运行 脚本并跳过 Tailor):

./run-sonar-swift.sh -notailor -v

只是为了节省一点时间因为裁缝需要时间

  1. 启动脚本后...出现新错误...但这是一个已知问题:

Error: Caused by: org.sonar.api.measures.PersistenceMode

这里解释了这个问题https://github.com/Backelite/sonar-swift/issues/118

所以我下载了这个 .jar 文件“backelite-sonar-swift-plugin-0.4-sonar-7-quick-fix.jar” 在这里找到 https://github.com/Hugal31/sonar-swift/releases/tag/0.4-sonar-7-quick-fix 并将其替换为我本地 SonarQube 的插件,然后重试。

......这次在无数次发射后我终于看到了曙光

希望这个回答对您有所帮助,如果您有任何疑问,请不要犹豫。 祝你好运,玩得开心:)

PS:您会在此处找到 运行 带有参数的脚本的一些选项:

./run-sonar-swift.sh -noswiftlint -v (run script with verbose option and skip SwiftLint)

./run-sonar-swift.sh -notailor -v (run script with verbose option and skip Tailor)

./run-sonar-swift.sh -nounittests -v (if your project does not have scheme configured to be tested launch with this parameter)

如果您想了解更多信息,请查看 运行-sonar-swift.sh 脚本并查看第 125 行 ## 命令行选项

PS2:我也在sonar-swiftGitHub中开了一个issue,如果有帮助的话:https://github.com/Backelite/sonar-swift/issues/138

我对 oclint 有一个额外的问题:oclint: Not enough positional command line arguments specified!。所以我不得不稍微修改 run-sonar-swift.sh 脚本以使其正常工作:https://gist.github.com/Edudjr/79a2379842357c33709aecf040d9ae77#file-run-sonar-swift-sh

这是我的声纳模型-project.properties: https://gist.github.com/Edudjr/db51907068ea76b116d11d9a9b13f05f#file-sonar-project-properties