Hello everyone.
I have setup a custom build rule for google protobuf (the protoc compiler) on an Xcode target that builds a Mac Framework.
The protoc compiler takes an input file with .proto extension (e.g. foofoo.proto) , and generates a foofoo.pb.cc and foofoo.pb.h source pair, in the Derived sources directory.
The rule looks basically like this:
Process Source files with names matching: *.proto Using Custom Script:
#!/bin/bash proto_dir=${SRCROOT}/protobuf-2.6.1/proto dllexport_def="__attribute__((visibility (\"default\")))" cd ${INPUT_FILE_DIR} /usr/bin/protoc -I${proto_dir} --proto_path=${INPUT_FILE_DIR} --cpp_out=dllexport_decl="${dllexport_def}":${DERIVED_FILE_DIR} ${INPUT_FILE_PATH}
Output files: $(DERIVED_FILE_DIR)/$(INPUT_FILE_BASE).pb.cc $(DERIVED_FILE_DIR)/$(INPUT_FILE_BASE).pb.h
Indeed the rule works, sources are generated, and are then automatically compiled (using C++ compiler) into my framework target.
1. Creating a framework, I would like to make the generated headers (.pb.h files) public - so they’re automatically copied to the framework’s headers directory. Unfortunately, I only found a way to set the visibility scope of header files (Pritave/Project/Public) via Xcode UI, when they are manually added to the project, and I see their references. Is there a decent way to do this?
2. Is it possible to setup my rule to generate code outside the ${DERIVED_FILE_DIR}? in such case, will Xcode continue to compile the generated sources? My attempts have failed so far.
Generally, I just can’t find any official documentation of Xcode custom build rules.
Thank you very much Motti Shneor. |