无法在 Xcode 4 中编译 plcrashreporter

发布于 2024-11-18 11:53:40 字数 909 浏览 1 评论 0原文

在为设备进行编译时,我可以使用 plcrashreporter 项目页面上提供的预构建框架,但不能用于模拟器。我有同样的此处描述的问题


我假设预构建的框架不支持模拟器的体系结构,因此我下载了 plcrashreporter 源代码。我打开 Xcode 项目并选择 CrashReporter-iOS-Simulator > iPhone 4.3 模拟器 目标。当我尝试构建项目时,我收到此错误:

libtool: unknown option character `D' in: -D__IPHONE_OS_VERSION_MIN_REQUIRED=30000

当我尝试构建大多数其他目标(例如设备)时,我收到相同的错误。


我的下一步是尝试将源文件添加到我的项目中。我不再有上述问题;但是,当我尝试编译时,出现此错误:

fatal error: 'crash_report.pb-c.h' file not found [2]
 #import "crash_report.pb-c.h"
         ^
1 error generated.
Command clang failed with exit code 1

错误消息中提到的 crash_report.pb-ch 文件根本不存在;我搜索了 plcrashreporter 源代码树和互联网。因此,我必须假设这个文件应该以某种方式生成,但我不知道如何生成。

(注释掉 PLCrashReport.m 中包含 crash_report.pb-ch 的行会导致许多其他编译错误。)

I can use the prebuilt framework provided on the plcrashreporter project page when compiling for the device, but not for the simulator. I have the same problem described here.


I assume the prebuilt framework does not support the simulator's architecture, so I downloaded out the plcrashreporter source. I opened the Xcode project and selected the CrashReporter-iOS-Simulator > iPhone 4.3 Simulator target. When I try to build the project, I get this error:

libtool: unknown option character `D' in: -D__IPHONE_OS_VERSION_MIN_REQUIRED=30000

I get the same error when I try to build most of the other targets (such as for device).


My next step was to try adding the source files to my project. I no longer have the aforementioned problem; however, I get this error when I try to compile:

fatal error: 'crash_report.pb-c.h' file not found [2]
 #import "crash_report.pb-c.h"
         ^
1 error generated.
Command clang failed with exit code 1

The crash_report.pb-c.h file which is mentioned in the error message simply does not exist; I've searched the plcrashreporter source tree and the internet. Therefore, I have to assume that this file is supposed to be generated somehow, but I cannot figure out how.

(Commenting out the line in PLCrashReport.m on which crash_report.pb-c.h is included results in numerous other compilation errors.)

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

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

发布评论

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

评论(1

七婞 2024-11-25 11:53:40

您是正确的,因为该文件通常不存在,也不存在 crash_report.pb-cc ,这将是您在此错误之后的下一个错误。

crash_report.pb.hcrash_report.pb.c 文件是在编译时通过构建规则生成的。您需要将自定义脚本添加到构建过程中才能制作它们。

首先,确保项目的 plcrashreporter 文件夹中有 protoc-c (plcrashreporter-1.0/Dependencies/protobuf-2.0.3/bin/protoc-c)。他们把它埋得很深。这就是您的脚本将运行的内容。

然后找到您的 crash_report.proto 文件。这是 protoc-c 将用于创建丢失文件的主要输入。您可以获取此目录并将其手动放入脚本中,或者您可以制定规则以在每个 *.proto 文件上运行脚本。我做后者。

然后编辑您的构建规则以包含运行带有标记 --c_out="${DERIVED_FILES_DIR}"protoc-c 的脚本和您的 crash_report.proto< /code> 文件作为两个输入,这会将 crash_report.pb-chcrash_report.pb-cc 输出到与您所在目录相同的目录中crash_report.proto 文件是,它应该已经可以在您的项目中访问。

Xcode 4(及更高版本)中的构建规则位于项目目标的构建规则选项卡下。您可以在所有其他构建规则之前添加一个构建规则。这是我的在 Xcode 中的样子:

Here's what my Looks like in Xcode.

您可能需要摆弄该目录

You are correct in that the file does not exist normally, nor does crash_report.pb-c.c exist, which will be your next error after this one.

The crash_report.pb.h and crash_report.pb.c files are generated at compile time through a build rule. You need to add a custom script to your build process to make them.

First, make sure you have protoc-c in the plcrashreporter folder of your project (plcrashreporter-1.0/Dependencies/protobuf-2.0.3/bin/protoc-c). They buried it deep. This is what your script will be running.

Then find your crash_report.proto file. This is the main input that protoc-c will be using to create your missing files. You can take this directory and put it manually into your script, OR you can make a rule to run the script on every *.proto file. I do the latter.

Then edit your build rules to include a script that runs protoc-c with the flag --c_out="${DERIVED_FILES_DIR}" and your crash_report.proto file as two inputs, this will output crash_report.pb-c.h and crash_report.pb-c.c into the same directory as where your crash_report.proto file is, which should already be accessible in your project.

The build rules in Xcode 4 (and above) are under your project's target's build rules tab. You add a build rule before all your other build rules. Here's what mine looks like in Xcode:

Here's what mine looks like in Xcode.

You'll probably have to fiddle with the directory

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