CMake and Xcode: "Cannot find interface declaration for" NSObject ""

I am trying to create an Xcode project using CMake, but I ran into some problems.

CMake generates the project perfectly, but then it becomes obvious that it is not connected with the Foundation and UIKit frames. I am new to CMake and trying to overcome this, but without success.

CMake Output (Partial):

... Framework Foundation found at /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/System/Library/Frameworks/Foundation.framework Framework CoreGraphics found at /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/System/Library/Frameworks/CoreGraphics.framework Framework UIKit found at /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/System/Library/Frameworks/UIKit.framework Configuring done Generating done 

Below is my CMakeLists.txt file (from several answers to SO):

 cmake_minimum_required(VERSION 2.8) macro(ADD_FRAMEWORK fwname appname libpath) find_library(FRAMEWORK_${fwname} NAMES ${fwname} PATHS ${libpath} PATH_SUFFIXES Frameworks NO_DEFAULT_PATH) if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND) MESSAGE(ERROR ": Framework ${fwname} not found") else() TARGET_LINK_LIBRARIES(${appname} ${FRAMEWORK_${fwname}}) MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}") endif() endmacro(ADD_FRAMEWORK) project(test) set(NAME test) set (libpath /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/System/Library) file(GLOB headers *.h) file(GLOB sources *.m) set(CMAKE_OSX_SYSROOT iphoneos4.2) set(CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD_32_BIT)) set(CMAKE_CXX_FLAGS "-x objective-c++") set(CMAKE_EXE_LINKER_FLAGS "-framework AudioToolbox -framework CoreGraphics -framework QuartzCore -framework UIKit -framework Foundation" ) set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.mycompany.\${PRODUCT_NAME:identifier}") set(APP_TYPE MACOSX_BUNDLE) add_executable(${NAME} ${APP_TYPE} ${headers} ${sources} ) ADD_FRAMEWORK(Foundation ${NAME} ${libpath}) ADD_FRAMEWORK(CoreGraphics ${NAME} ${libpath}) ADD_FRAMEWORK(UIKit ${NAME} ${libpath}) # code signing set_target_properties(${NAME} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer: Some Name") 
+2
iphone xcode cmake
Mar 29 '11 at 13:38
source share
2 answers

I have a few suggestions:

  • do not use add_framework . This allows CMake to set the project property FRAMEWORK_SEARCH_PATHS , which somehow screwed everything up. Use the -framework command line -framework
  • for CMAKE_OSX_SYSROOT you can just use iphoneos
  • you do not need CMAKE_CXX_FLAGS

With them, you may have more luck. So far I have managed to overcome most link errors.

+4
May 23 '11 at 12:00
source share

Try the following rule in CMakeLists.txt :

 link_directories(\${HOME}/\${SDKROOT}/lib) 
+1
Apr 26 '11 at 15:03
source share



All Articles