puls / objc-codegenutils

Three small tools to help you meet Xcode halfway.
Other
507 stars 26 forks source link

Xcode plugin support #4

Open luosky opened 10 years ago

luosky commented 10 years ago

These code generation utils are great. Any chance these can be install as an Xcode plugin so that they can be used directly in Xcode?

puls commented 10 years ago

Maybe. If you make the tools project a dependency of your project and build them on demand, it keeps your codebase more portable and doesn't make assumptions about the development environment of others working on the project.

mman commented 10 years ago

Could anybody please chime in how to properly invoke the objc-* scripts when objc-codegenutils are added as Xcode subproject? I'd be happy then to add it to the README. I have been able to hack around to write down custom Run Script phase that refreshes all generated header files by invoking the freshly compiled objc-* binaries. It works for regular build and archive build and although it works I'm not sure this is the cleanest way to do it... Here is the code...

https://gist.github.com/mman/9410268

puls commented 10 years ago

The test app in the repository shows you how.

mman commented 10 years ago

Yep, the test app shows a nice RunScript that works well when the main app target is for the Mac but fails when the main target is for iOS, the env variables do not work for the "Archive" command after that...

I think this has something to do with the fact that env variables and directory structure created for the objc-codegenutils subproject when in archive mode for the Mac do not match that of archive for the iOS... please see the images attached... the tools are actually archived to /usr/local/bin under DSTROOT and invoked from somewhere else... screenshot 2014-03-10 11 54 36 screenshot 2014-03-10 11 54 13

mman commented 10 years ago

The issue appears to be that Xcode always archives the subproject targets using the "Release" configuration regardless what the main project configuration is... thus changing the Run Script to the code below makes it work (note... just hardcoding the TOOL_PATH path to "Release")...

DERIVED_SOURCES="$SRCROOT/DerivedSources"
TOOL_PATH=$BUILD_ROOT/Release
$TOOL_PATH/objc-assetgen -f "$SRCROOT" -o "$DERIVED_SOURCES"
$TOOL_PATH/objc-colordump -f "$SRCROOT" -o "$DERIVED_SOURCES"
$TOOL_PATH/objc-identifierconstants -f "$SRCROOT" -o "$DERIVED_SOURCES"