CMake GUI to generate iOS project

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.

we can’t archive this goal by pure cmake scripts, and times ago I new an issue to ask CMake official, we get the “No” response.

for now, using the Xcode project supplied is more convenient than that cmake generated on iOS platform. mobile platform always have a complex project configs, I think cmake is powerful for native build, but not for project configs.

truly, we didn’t consider the code signing on iOS platforms in CMake. For cocos2d-x 3.17+ we expand cmake to other platforms, and meanwhile keep supplying the project build files, the most important reason is cmake build scripts is not so perfect.

also other ideas, we records it here, with a long discuss.

Any ideas about Sleicreider questions? @CrazyHappyGame

I am optimistic about cmake future on cocos2d-x, many other open-source projects use the cmake as the build tools, even on iOS platforms.

for example OpenCV, existing some cmake expend scripts

https://github.com/opencv/opencv/tree/3.4/platforms/ios

The resolution issue seems to be gone with 3.17.1.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.