首页 > 解决方案 > 如何为工作区设置 Jenkins Xcode 插件?

问题描述

我对 iOS 应用程序开发领域很陌生。我需要在 Jenkins 中为我构建的新 Swift 应用程序设置构建。作为其中的一部分,我使用 Cocoapods 来管理依赖项,这反过来意味着我现在有了一个工作区,而不是一个简单的项目。

我现在正在尝试将此应用程序构建为我们管道的一部分并遇到以下错误:

FATAL: Since there are multiple projects in the workspace, you must be specify the location of the target project as Xcode Project File.
Build step 'Xcode' marked build as failure
Finished: FAILURE

我的项目的根如下所示:

$ ls -la
total 32
drwxr-xr-x  14 mcbint  staff  448 15 Jan 15:16 .
drwxr-xr-x   3 mcbint  staff   96 15 Jan 14:33 ..
drwxr-xr-x  13 mcbint  staff  416 16 Jan 11:11 .git
-rw-r--r--   1 mcbint  staff  108 15 Jan 14:56 .gitignore
-rw-r--r--   1 mcbint  staff  501 15 Jan 14:56 Podfile
-rw-r--r--   1 mcbint  staff  379 15 Jan 14:56 Podfile.lock
drwxr-xr-x   9 mcbint  staff  288 15 Jan 15:16 Pods
-rw-r--r--   1 mcbint  staff  666 15 Jan 14:56 README.md
drwxr-xr-x  10 mcbint  staff  320 15 Jan 14:56 mcb-phoneagent-ios
drwxr-xr-x   5 mcbint  staff  160 15 Jan 15:16 mcb-phoneagent-ios.xcodeproj
drwxr-xr-x   4 mcbint  staff  128 15 Jan 14:56 mcb-phoneagent-ios.xcworkspace
drwxr-xr-x   4 mcbint  staff  128 15 Jan 14:56 mcb-phoneagent-iosTests
drwxr-xr-x   4 mcbint  staff  128 15 Jan 14:56 mcb-phoneagent-iosUITests
drwxr-xr-x   2 mcbint  staff   64 15 Jan 15:07 test-reports

我在 xcode 中设置了项目,如下所示: 詹金斯 ios 工作区配置

在我的开发机器上,我可以使用以下命令成功构建应用程序:

xcodebuild -workspace mcb-phoneagent-ios.xcworkspace -scheme mcb-phoneagent-ios

有人看到我设置不正确的东西吗?

标签: iosxcodejenkins

解决方案


当我遇到这个问题时,这就是我解决这个问题的方法:

  1. 确保您将方案容器设置为工作区(而不是项目。这可以在 Xcode 中的 Product -> Scheme -> Manage Schemes 中检查,然后查看标题为“Container”的列)

  2. 确认 xcshareddata 位于 Jenkins 正在使用的工作区目录中。

  3. 在 Jenkins Xcode 的 General build settings 下有一个“Settings”按钮设置按钮

单击它并找到 Xcode 模式文件文本框。架构文本框

在该框中填写您要用于作为 Xcode 工作区文件输入的给定工作区的 xcsheme 文件的名称(在您的情况下,我猜它是 mcb-phoneagent-ios)。


推荐阅读