在 php 中运行 xcodebuild

发布于 2024-12-19 11:47:40 字数 284 浏览 4 评论 0原文

我试图从 php 中运行 xcodebuild 命令,但它似乎没有被调用。我没有从 exec 命令得到任何输出,也没有抛出任何错误。其他命令运行良好,例如 xcrun(我正在使用它来准备应用程序以进行临时分发)。这是我正在调用的代码;

exec('/usr/bin/xcodebuild -version', $output);
print_r($output);

预先感谢您的任何帮助!

编辑:我应该添加,该命令从命令行运行良好,以与 php 脚本相同的用户身份运行。

I'm trying to run the xcodebuild command from within php, and it just doesn't seem to even get called. I get no output from the exec command, and no errors are thrown. Other commands are working just fine, such as xcrun (which I'm using to prepare the app for ad-hoc distribution). Here is the code I'm calling;

exec('/usr/bin/xcodebuild -version', $output);
print_r($output);

Thanks in advance for any help!

Edit: I should add, this command runs fine from the command line, running as the same user as the php script.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

秋凉 2024-12-26 11:47:40

你的代码对我来说完美运行。

也许您可以将其更改为这样,并确保命令的返回值为 0:

exec('/usr/bin/xcodebuild -version', $output, $rv);
echo "Command returned: $rv\n";
print_r($output);

如果 $rv 不是 0,那么至少您知道您的 exec() 调用正在运行,只是 xcodebuild 命令行由于某种原因失败。

Your code runs perfectly for me.

Perhaps you can change it to this and make sure the return value from the command is 0:

exec('/usr/bin/xcodebuild -version', $output, $rv);
echo "Command returned: $rv\n";
print_r($output);

If $rv is something other than 0, then at least you know your exec() call is working and it's just that the xcodebuild command-line is failing for some reason.

攒一口袋星星 2024-12-26 11:47:40

我也有这个问题...您是否尝试向用户 nobody 授予完全权限?

I have also this problem... did you tried to give full permissions to user nobody ?

各自安好 2024-12-26 11:47:40

经过 1 天的调试并尝试一切之后,我终于可以使用 php 为我的 ios 应用程序构建一个构建服务器。我在这里列出了我所做的所有事情,以便其他有相同问题的人也可以解决他们的问题。

使用 shell_exec() 而不是 exec(),这样您就可以看到所有输出。

我有这样的东西要测试##

$output = shell_exec("xcodebuild -showsdks 2>&1");
print_r($output);

当我第一次运行上面的代码时,我在浏览器上有这个问题

您尚未同意 Xcode 许可协议,请从终端窗口中独立运行 xcodebuild 以查看并同意 Xcode 许可协议。
构建步骤“XCode”将构建标记为失败
完成:失败

所以我运行

sudo xcodebuild -license

以同意系统范围内的许可证

再次运行代码,我遇到了这个问题

xcodebuild:错误:工作区“xxx”不包含名为“xxx”的方案。

要解决此问题:尝试检查此问题的答案:使用 xcodebuild 构建等待/"runContextManager.runContexts"

修复问题后,我的构建脚本现在可以正常运行。

希望我能帮助您解决您的问题。

After 1 day debug and try everything, i can finally build a build server for my ios app using php. I list all the things i have done here so that others can also fix their problems if they have the same ones.

Use shell_exec() instead of exec(), so that you can see all the output.

I have something like this to test ##

$output = shell_exec("xcodebuild -showsdks 2>&1");
print_r($output);

When i first run the above codes, i have this probem on browser

You have not agreed to the Xcode license agreements, please run xcodebuild standalone from within a Terminal window to review and agree to the Xcode license agreements.
Build step 'XCode' marked build as failure
Finished: FAILURE

So i run

sudo xcodebuild -license

to agree the license system wide

Run the code again, i have this problem

xcodebuild: error: The workspace 'xxx' does not contain a scheme named 'xxx'.

To solve this: try the checked answer of this question: Building with xcodebuild Timed out waiting for <IDEWorkspace, 0x2004cebc0>/"runContextManager.runContexts"

After fixing the issue, my build script now run normally.

Hope i can help you solving your issues.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文