Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. IOS: How to add a Settings.bundle with cmake?
QtWS25 Last Chance

IOS: How to add a Settings.bundle with cmake?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
qt6ioscmake
2 Posts 1 Posters 664 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheoSys
    wrote on 14 Oct 2023, 10:42 last edited by TheoSys
    #1

    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 the Settings.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 the Settings.bundle? Or must I do it completely different?

    A.T.

    T 1 Reply Last reply 15 Oct 2023, 16:29
    0
    • T TheoSys
      14 Oct 2023, 10:42

      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 the Settings.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 the Settings.bundle? Or must I do it completely different?

      A.T.

      T Offline
      T Offline
      TheoSys
      wrote on 15 Oct 2023, 16:29 last edited by
      #2

      I must answer my own question. Sometimes I miss the obvious. A Settings.bundle is simply a resource and must be copied to the Resources. 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 my CMakeLists.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 variable settings_bundle.

      That's it!

      1 Reply Last reply
      0
      • T TheoSys has marked this topic as solved on 15 Oct 2023, 16:30

      1/2

      14 Oct 2023, 10:42

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved