[CMake] Interface Builder xib to nib compilation for iOS

Daniel Dekkers d.dekkers at cthrough.nl
Sun Sep 18 10:16:10 EDT 2011


Hi,

I'm targeting iOS (device and simulator) and setting up CMake to add the different resources needed in the bundle.
The "xib" file is giving me some problems.
If I take no further action, the iPhone/iPad simulator run fails with the error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/danieldekkers/Library/Application Support/iPhone Simulator/4.3.2/Applications/1C29638B-7593-4311-8F94-C8051AF90AD7/Discs.app> (loaded)' with name 'MainWindow''

A missing NIB file in the bundle. 
An example (http://www.vtk.org/Wiki/CMake:OSX_InterfaceBuilderFiles) shows that for OSX, you have to compile the xib files into nib files and add these to the bundle as a post-build step.
So my guess would be that something similar holds for iOS as well.
But my question is,... where do i add the compiled nib files?

I now do this in the CMakeLists.txt:

# We need to compile the interface builder *.xib files to *.nib files to add to the bundle
# Make sure we can find the 'ibtool' program. If we can NOT find it we skip generation of this project
FIND_PROGRAM( IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin" )
if ( ${IBTOOL} STREQUAL "IBTOOL-NOTFOUND" )
	MESSAGE( SEND_ERROR "ibtool can not be found" )
ENDIF()

# Compile the .xib files using the 'ibtool' program with the destination being the app package
FOREACH( xib ${RSRC_IOS_XIB_FILES} )
	ADD_CUSTOM_COMMAND( TARGET ${RT_APP_NAME} POST_BUILD
	COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text 
		--compile 
		${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${RT_APP_NAME}.app/Contents/Resources/${xib}.nib
		${RT_APP_ROOT}/rsrc/apple/ios/${xib}.xib
		COMMENT "Compiling ${RT_APP_ROOT}/rsrc/apple/ios/${xib}.xib")
ENDFOREACH()

But i don't really trust the "destination" of the compilation step, especially for the simulator.
Has anyone got this working?

Kind Regards,

Daniel Dekkers



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110918/d4b9d122/attachment.htm>


More information about the CMake mailing list