xcode xcodebuild 命令行挂起

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34123017/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:17:42  来源:igfitidea点击:

xcodebuild command line hangs

xcodecordovaxcodebuild

提问by Tal

The following command hangs on my osx:

以下命令挂在我的 osx 上:

xcodebuild -scheme myscheme clean archive -archivePath /tmp  

This command yields two output lines, and then hangs:

此命令产生两个输出行,然后挂起:

User defaults from command line:
    IDEArchivePathOverride = /tmp

Now, this project does NOT have a workspace generated as it was created from a cordova command line (cordova build ios). The only way around it is to open xcode and close it. this generates a workspace and then the above command succeeds.

现在,该项目没有生成工作区,因为它是从cordova 命令行 ( cordova build ios) 创建的。解决它的唯一方法是打开 xcode 并关闭它。这将生成一个工作区,然后上述命令成功。

Did anyone experience something similar and know a way out of this? Any way to generate that workspace from the command line?

有没有人经历过类似的事情并知道解决办法?有什么方法可以从命令行生成该工作区?

回答by Anytoe

I had the same problem and the only way of fixing it was to open the project from the command line, wait, and close it again after a certain time.

我遇到了同样的问题,解决它的唯一方法是从命令行打开项目,等待一段时间后再次关闭它。

open "My Project.xcodeproj"
sleep 10
killall Xcode
xcodebuild -scheme "My Project" clean archive "build/MyProject"

Not nice, but works for me.

不好,但对我有用。

回答by danB

Try setting the scheme to be 'shared'.

尝试将方案设置为“共享”。

This can be done by going to the 'Manage Schemes...' and checking the 'Shared' checkbox.

这可以通过转到“管理方案...”并选中“共享”复选框来完成。

Apple documents this process here: https://developer.apple.com/library/ios/recipes/xcode_help-scheme_editor/Articles/SchemeShare.html

Apple 在此处记录此过程:https: //developer.apple.com/library/ios/recipes/xcode_help-scheme_editor/Articles/SchemeShare.html

回答by toxaq

If you're already have, or are willing to make, Ruby available to your build system then you could use this solution.

如果您已经拥有或愿意让 Ruby 可用于您的构建系统,那么您可以使用此解决方案

Install the xcodeproj gem on your build system

在你的构建系统上安装 xcodeproj gem

sudo gem install xcodeproj

and then integrate the following ruby script into your project (renaming your xcodeproj path).

然后将以下 ruby​​ 脚本集成到您的项目中(重命名您的 xcodeproj 路径)。

#!/usr/bin/env ruby
require 'xcodeproj' 
xcproj = Xcodeproj::Project.open("platforms/ios/schemedemo.xcodeproj")
xcproj.recreate_user_schemes
xcproj.save

The article explains how to make it part of a cordova hook if you're doing that, I simply called ruby directly from my Jenkins build.

这篇文章解释了如何让它成为cordova hook的一部分,如果你这样做的话,我只是直接从我的Jenkins构建中调用ruby。

This works because when you recreate the proj files, you destroy the schemes, so you need to recreate them.

这是有效的,因为当您重新创建 proj 文件时,您会破坏方案,因此您需要重新创建它们。

回答by camomileCase

I believe xcodebuild hangs because some data is missing from the project. You can make a template for what this data looks like and use a hook to populate it if necessary.

我相信 xcodebuild 挂起是因为项目中缺少一些数据。您可以为这些数据的外观制作一个模板,并在必要时使用钩子来填充它。

  1. cordova add platform ios
  2. cordova build ...
  3. open platforms/ios/Whatever.xcodeproj in xcode
  4. create xcuserdata_template
  5. cp -R platforms/ios/Whatever.xcodeproj/xcuserdata xcuserdata_template/
  6. replace the unique id in that template with XXXXXXXXXX
  7. update your hook that runs xcodebuild
  1. 科尔多瓦添加平台ios
  2. 科尔多瓦建...
  3. 在 xcode 中打开平台/ios/Whatever.xcodeproj
  4. 创建 xcuserdata_template
  5. cp -Rplatforms/ios/Whatever.xcodeproj/xcuserdata xcuserdata_template/
  6. 用 XXXXXXXXXX 替换该模板中的唯一 ID
  7. 更新运行 xcodebuild 的钩子

Step 7 example:

步骤 7 示例:

XCODE_PROJ=path/to/Whatever.xcodeproj

# get the mysterious id
ID=`grep "Whatever \*\/ = {" $XCODE_PROJ/project.pbxproj | \
    grep -io "[-A-Z0-9]\{24\}"`

mkdir -p $XCODE_PROJ/xcuserdata

XCUSERDATAD=$XCODE_PROJ/xcuserdata/`whoami`.xcuserdatad

if [ ! -d "$XCUSERDATAD" ]; then
    cp -R path/to/xcuserdata_template/username.xcuserdatad \
        $XCUSERDATAD
    find $XCUSERDATAD -type f -exec sed -i '' -e "s/XXXXXXXXXX/$ID/g" {} \;
fi

xcodebuild ...