CMake GUI to generate iOS project

I’ve tried this again.
This time i managed get the toolchain running with the cmake gui, by adding the toolchain file in the configure step for cross compilation.

I still have some issues with the required code signing since it doesn’t seem to find my provisioning profile in the Library profile cache path and I somehow can’t find a cmake option for automatic manage signing (which i would use for the non cmake project)

if(IOS)

    set(SIGN_ID "iOS Developer")
    set(TEAM_ID "myteamid")

    #https://stackoverflow.com/questions/40664125/cmake-and-code-signing-in-xcode-8-for-ios-projects

    SET_XCODE_PROPERTY(${APP_NAME} CODE_SIGN_IDENTITY ${SIGN_ID})
    SET_XCODE_PROPERTY(${APP_NAME} DEVELOPMENT_TEAM ${TEAM_ID})
    SET_XCODE_PROPERTY(${APP_NAME} PROVISIONING_PROFILE_SPECIFIER "xxxxxxxx")


endif()

This above seems not to work for the provisioning profile, therefore I currently have to manually tick Automatic signing everytime I execute cmake, which is really annoying. If anyone has knows how to handle the code signing stuff please help :slight_smile:

Additionally I have some issues with adding external frameworks like SDKBOX to the project via cmake.
I’ve tried to play around with t target_link_libraries but it somehow doesn’t find the .framework.

Let me know if anyone has any idea of those 2 issues.

@drelaptop might have ideas and we could document.

firstly, you need find_library to found the libs, and then link it. you can refer to this file, it found system libs for cocos2d.

https://github.com/cocos2d/cocos2d-x/blob/v3/cmake/Modules/CocosConfigDepend.cmake

didn’t know it clear for now, may research it next.

refer this, it add external libs, and then you can link

https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin/blob/v3/png/CMakeLists.txt

To integrate SDKBOX, refer to this post:

I did get it working in CMake for Android, and it may work for iOS too, just haven’t had the time try it out.

@R101 Yeah i already used this post for my Android project, but not 100% sure if this gonna work for iOS ans mentioned I already had issues with finding the sdkbox.framework

@drelaptop

I’m not a cmake pro maybe I’m doing it wrong?

I’ve tried to use the find_library and add library stuff for the .framework files from sdkbox
for example the sdkbox stuff is in the .proj.ios_mac src folder:

find_library(F_IAP PluginIAP HINTS "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac")

I’ve tried some examples from stackoverflow for custom frameworks:

   find_library(F_LIB
   NAMES sdkbox
   PATHS ${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac
   PATH_SUFFIXES Frameworks
   NO_DEFAULT_PATH)

but it always says NOTFOUND as output somehow it simply cannot find the .framework files from the proj. ios folder

I’ve found one post which at least lets me now find the header files etc.

using:

target_link_libraries(${APP_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/sdkbox.framework/sdkbox")

target_link_libraries(${APP_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/PluginIAP.framework/PluginIAP")

but now i’m getting other linker issues for the sdkbox

as I concerned you don’t need to link .../sdkbox.framework/sdkbox, you need set directories before you find a library.

please refer to this official wiki.

Hmm, I’ve already tried stuff from this link before, I’ll try it again.

@drelaptop

ok I’ve tried the following:

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/PluginIAP)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/sdkbox)

find_library(F_IAP PluginIAP)
find_library(F_SDKBOX sdkbox)

the issue is it simply doesn’t find the libs

include dir should be

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac)

similar with this

image

yeah i’ve tried this as well.

I’ve even tried to find one of the frameworks in the Library/Frameworks folder and it doesn’t find them.
Not sure if the CMake version is an issue? I’m on 3.13.1

sorry, I should try it earlier, now I found the reason, iOS toolchain files changes the find_library default behavior.

after comment this line, above methods works.

ok, I’m now able to find libs from the /Library/Frameworks folder, but there are still some issues with the custom project folder, but for now i’ve just moved the 2 frameworks into the Library/Frameworks folder and it works.

But now I get the issue I had with directly adding the sdkbox.framework/sdkbox file

currently my cmake part for this looks like this:

include_directories(System/Library/Frameworks)

find_library(F_IAP PluginIAP)

find_library(F_SDKBOX sdkbox)

MARK_AS_ADVANCED(F_IAP F_SDKBOX)


target_link_libraries(${APP_NAME} ${F_SDKBOX})

target_link_libraries(${APP_NAME} ${F_IAP})

not sure if I’m missing anything since the cmake lines now look exactly like the ones from the guide

ok, i thought I only had to add the sdkbox and iap frameworks , since i did the same with the non cmake project, but it seems like you manually have to add the SystemConfiguration and StoreKit framework:

include_directories(System/Library/Frameworks)

find_library(F_IAP PluginIAP)

find_library(F_SDKBOX sdkbox)

find_library(F_SYSCONF SystemConfiguration)

find_library(F_STOREKIT StoreKit)

MARK_AS_ADVANCED(F_IAP F_SDKBOX)



target_link_libraries(${APP_NAME} ${F_SYSCONF})

target_link_libraries(${APP_NAME} ${F_STOREKIT})

target_link_libraries(${APP_NAME} ${F_SDKBOX})

target_link_libraries(${APP_NAME} ${F_IAP})

please let me know, if there is better way for doing this. Obviously the target_link_libraries can be used once for all libs instead of 4 times…

now the game starts on iOS and sdkbox frameworks

For the running app I’ve still got an issue. For some reason on my iPad the game is displayed with a smaller width and height for some reason.

For example i have a iPad mini 2 and the GLView assigns a screen size 1334 x 750 to it for the CMake project. for the non Cmake project it uses the 2048 x 1536, are this some CMake settings?

CMake scripts didn’t change any C++ code files, for iOS project, I think the only part may have effects on it is iOS info.plist files, this file is different from non CMake project.

when you generate an iOS Xcode project, you can compare the difference. For CMake, the info.plist come from a template with some values changed.

template:
https://github.com/cocos2d/cocos2d-x/blob/v3/cmake/Modules/iOSBundleInfo.plist.in

I think this is a better solution, not comment this line, just change default value for tmp @Sleicreider

ok thanks I’ll look into that.

is it actually possible have both, osx and ios in one xcode project, similar to the non cmake project provided by default? as far as i know there you just have schemes for each platform.

Also…
Not sure if I read this somewhere on the forums before, but is it actually generally a good advice to use cmake for ios? For me it’s the first time using it for mobile products. For desktop (even osx for dev only) its awesome and for Android its also great since you still have to do the configuration in Android Studio (signing and settings, so cmake only somewhat replaces the .mk files), but for iOS it’s not that easy to work with, unlike for Android, CMake generates the whole project setup for XCode, like code signing is already a problem for me right now(as mentiond above with enabling automatic signing) and I guess making the product release read with additional app resource which you can set through XCode might be not so easy?

As already mentioned I think someone in the forums already made this point for CMake on iOS.

For fast development itself (where I don’t care about shipping conrigurations etc) it still feals great tho.