Re: Build Rule to Call the Google Protocol Buffer Compiler
Re: Build Rule to Call the Google Protocol Buffer Compiler
- Subject: Re: Build Rule to Call the Google Protocol Buffer Compiler
- From: David Frantz <email@hidden>
- Date: Sat, 27 Aug 2011 21:22:53 -0400
I know many will not like this but Bash and Python are your friends. XCode is far to screwed up to behave in a rational manner, with Python you can write a clear and maintainable script that works through every revision to XCode.
Xcode boggles my mind in so many ways that I often spend more time beating on XCode than the projects code. For example I've been working on a bit of legacy code (library) to run an old X app. To get it to build and run was easy at first. Even getting the library to build as an XCode project has gone fairly well too but building the included test apps is a struggle under XCode. At least trying to set up XCode to build them as another target is a joke.
As you note the documentation is terrible or so well hidden nobody can find it. Even then there seems to be little in the way of accessible debug info to tell you what is going on. I've had issues with this facility since very early in the iOS SDK days so I really don't expect it to get better. So Python or Bash can solve many problems for you.
Well most of the time. In one project done some time ago I had XCode supposedly running a Python script early in a build followed by a copy phase of a plist built by that script. For whatever reason I had to build twice to get the revised plist built into the code. This with the script and copy being done well before building the rest of the app. Never did figure that one out. I can only assume that the implied sequential behavior isn't real and that XCode does as it damn well pleases. In the end I've learned that trusting XCode is often a big mistake.
Sent from my iPhone
On Aug 27, 2011, at 8:24 PM, Thomas Wetmore <email@hidden> wrote:
> I've been struggling trying to get a build rule working on Xcode 4.0.2 today, while awaiting Irene's visit. The documentation and Google have not been much help.
>
> My case is simple. I wish to compile some Google protocol buffer specifications into Objective-C classes and then compile those classes into an application. I have a version of the protocol buffer compiler, protoc, that generates Objective-C code as output, and I have a static protocol buffer library that provides all the infrastructure. I have added a build rule to the project that needs the proto files converted into classes and then compiled. The term compile is over loaded here as the first step is to compile the proto files into Objective-C files, and the second step is to use the compiler we know and love. Here is the rule:
>
> http://bartonstreet.com/buildrule/BuildRule.jpg
>
> This means that I want to run the protoc compiler on all out of date source files with a .proto suffix. The script works correctly. If, for example, there is a file named alpha.proto in the project, this rule will create two files, alpha.pb.m and alpha.pb.h, and place them in the DERIVED_FILES_DIR. This happens correctly. The files are there and exactly right.
>
> My understanding (the documentation is abysmal) is that the files that are listed in the Output Files area, as they are toward the bottom of this grab, should then be treated by Xcode using the proper rules for files with their given suffixes. I have a number of projects with yacc files, and this is how the builtin build rule for yacc seem to work. However, instead of compiling these generated Objective-C classes, Xcode instead moves them to the Resources directory. Here is an example build log that shows this. I didn't expand the custom shell script execution step since it runs correctly, but I did expand one of the two copies of the generated files to the resource directory.
>
> http://bartonstreet.com/buildrule/BuildLog.jpg
>
> Any advice out there? Why is Xcode moving these two files to the resources directory instead of compiling them? I'm guessing that it may be the use of .pb.m and .pb.h, instead of vanilla .m and .h as the file suffixes that might be confusing Xcode. But since the generated .pb.m files have include lines that name the .pb.h files explicitly, I can't just willy nilly change the names of the files.
>
> I am also going to try to implement this requirement as a build phase instead of a build rule, to see if I have any more luck. However, the documentation for creating build phases is just as abysmal.
>
> Hope someone has an idea or two. Has anyone seen a discussion or a technical note that might explain what's going on?
>
> Thanks.
>
> Tom Wetmore, Chief Bottle Washer, DeadEnds Software _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden