IOS: How to add a Settings.bundle with cmake?
-
For my application I'm developing for iOS, beside other OSs, I need to add a
Settings.bundle
. It contains the settings menu necessary to configure the app. With qmake it was no problem but now with cmake it seems impossible. At least I found not a single example to adapt.
I found out, that I can add theSettings.bundle
this way:# Settings bundle set(settings_bundle "ios/Settings.bundle") file(GLOB_RECURSE settings CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${settings_bundle}") target_sources(tpanel PRIVATE ${settings} ${settings_bundle}) set_source_files_properties(${settings} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/${settings_bundle}") set_target_properties(tpanel PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER org.qtproject.theosys MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/ios/Info.plist" XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME AppIcon QT_IOS_LAUNCH_SCREEN "${bundles}" )
But then I can not add the individual launch screen any more. The launch screen appears as a blck screen. Beside this, the application does not start any more when I change something in the settings. This makes the app crash immediately when I try to restart it.
Is there another variable available to add theSettings.bundle
? Or must I do it completely different?A.T.
-
I must answer my own question. Sometimes I miss the obvious. A
Settings.bundle
is simply a resource and must be copied to theResources
. Since Apple changed the directory chirarchy in the app bundle, all Resources are files or directories in the root directory. After I realized this, it was simple. Here is a small excerpt of myCMakeLists.txt
file:set(settings_bundle "Settings.bundle") qt_add_executable(tpanel MANUAL_FINALIZATION ${PROJECT_SOURCES} "${settings_bundle}" ) target_sources(tpanel PRIVATE "${settings_bundle}") set_source_files_properties(${settings_bundle} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
The above code assume, that the
Settings.bundle
is in the root of the distribution. If this is not the case, then the relative path must be defined as part of the variablesettings_bundle
.That's it!
-