Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't compile plcrashreporter in Xcode 4

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.)

like image 386
titaniumdecoy Avatar asked Jul 01 '11 00:07

titaniumdecoy


1 Answers

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

like image 77
Andrew Avatar answered Sep 24 '22 07:09

Andrew