针对 iOS 目标的 CMake xib 到 nib 编译
我的目标是 iOS(设备和模拟器)并设置 CMake 以添加捆绑包中所需的不同资源。 “xib”文件给我带来了一些问题。如果我不采取进一步操作,iPhone/iPad 模拟器运行将失败并显示错误:
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''
捆绑包中缺少 NIB 文件。 一个示例 (http://www.vtk.org/Wiki/CMake:OSX_InterfaceBuilderFiles) 显示,对于 OSX,您必须将 xib 文件编译为 nib 文件,并将这些文件作为构建后步骤添加到捆绑包中。 所以我的猜测是 iOS 也有类似的情况。 但我的问题是,...我在哪里添加编译好的 nib 文件?
我现在在 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()
但是我并不真正信任编译步骤的“目的地”,尤其是对于模拟器而言。
有谁能做到这一点或者看看我做错了什么?
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 iI don't really trust the "destination" of the compilation step, especially for the simulator.
Has anyone got this working or see what it is that I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它应该与 CMake Xcode 生成器“正常工作”,将 *.xib 文件作为源添加到 add_executable 中,然后将 RESOURCE 目标属性设置为 *.xib 文件列表。 xib 文件。
如 CMake/Tests/ 中所示iOSNavApp/CMakeLists.txt 文件。
此技术应适用于 CMake 2.8.5 及更高版本以及 Xcode 4 及更高版本。
编辑
链接中的代码复制/粘贴到此处,以防链接将来损坏:
It should "just work" with the CMake Xcode generator to add the *.xib files as sources to add_executable, and then set the RESOURCE target property to the list of *.xib files.
As shown in the CMake/Tests/iOSNavApp/CMakeLists.txt file.
This technique should work with CMake 2.8.5 and up, and Xcode 4 and up.
EDIT
Code from link copied/pasted here in case the link gets broken in the future: