我的目标是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()
但是我真的不相信编译步骤的“目标”,尤其是对于模拟器。
有没有人做这个工作或看看我做错了什么?
[它应该与CMake Xcode生成器一起“正常工作”,将* .xib文件作为源添加到add_executable,然后将RESOURCE目标属性设置为* .xib文件的列表。] >
如CMake/Tests/iOSNavApp/CMakeLists.txt文件中所示。
此技术应与CMake 2.8.5及更高版本以及Xcode 4及更高版本一起使用。
编辑
从链接中复制/粘贴的代码,以防将来链接断开:
cmake_minimum_required(VERSION 2.8.5)
project(NavApp3)
set(CMAKE_OSX_SYSROOT iphoneos4.3)
set(CMAKE_OSX_ARCHITECTURES "armv6;armv7;i386")
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator")
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/Classes
)
add_library(Functions STATIC TotalFunction.c TotalFunction.h)
set(M_SRCS main.m Classes/NavApp3AppDelegate.m Classes/RootViewController.m)
set(HEADERS Classes/NavApp3AppDelegate.h Classes/RootViewController.h)
set(RESOURCES MainWindow.xib RootViewController.xib)
add_executable(NavApp3 MACOSX_BUNDLE ${M_SRCS} ${HEADERS} ${RESOURCES})
target_link_libraries(NavApp3
Functions
"-framework CoreGraphics"
"-framework Foundation"
"-framework UIKit"
)
set_target_properties(NavApp3 PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER "com.yourcompany.NavApp3"
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
RESOURCE "${RESOURCES}"
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym"
XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER YES
XCODE_ATTRIBUTE_GCC_PREFIX_HEADER ${CMAKE_CURRENT_LIST_DIR}/NavApp3_Prefix.pch
XCODE_ATTRIBUTE_INFOPLIST_PREPROCESS YES
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 3.0
)