Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,808
    • Issues 3,808
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 11
    • Merge requests 11
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #19588

Closed
Open
Created Aug 11, 2019 by Steve Robinson@ssrobinsContributor

Xcode: Enable CMake to create folder references

If CMake were able to add folder references in an Xcode project, I wouldn't have to add icons to the Xcode project after generation in order to submit an iOS app to the App Store. It would also be handy to add directories of assets so they can be easily packaged in the app.

A folder reference is shown as a blue folder in Xcode and indicates a reference to an actual folder in the file system. It's needed to properly add all the required icons into the app. I'm able to use source_group to add yellow folders, but those are only for organizational purposes and won't add the icons.

I've found that the location of the icon folder within a given target's folder doesn't seem to matter. Aside from dragging the icon folder into Xcode, the icon files must be added to target_sources and that same icon file list must be referenced in the RESOURCE target property. Based on that, I think the folder reference could be added in CMake with a new FOLDER_REFERENCE target property whose value is the folder being referenced.

From here on out, I'll use the following project to make the discussion more concrete:
https://github.com/ssrobins/sdl2-example.git

The Rectangles target is my sample iOS app:
https://github.com/ssrobins/sdl2-example/blob/main/Rectangles/CMakeLists.txt

Here's my environment

  • CMake 3.15.2
  • Conan 1.18.1
  • Xcode 10.3 (10G8)
  • macOS 10.14.4

Here are the steps I currently go through to add the folder reference:

  1. git clone https://github.com/ssrobins/sdl2-example.git
  2. cd sdl2-example
  3. ./build_ios.sh
  4. Open the generated project in Xcode
  5. In Finder, double-click on the Rectangles folder to show the Rectangles.xcassets folder
  6. Drag the Rectangles.xcassets folder into the Rectangles folder in the Xcode project
  7. It should pop up a window indicating that it's creating a folder reference for target Rectangles. Click Finish.

If you go to Product > Scheme > Choose Scheme, it'll now show the red icon next to the Rectangles target, indicating a successful icon install.

So, in the example above, the proposed new CMake code would be:

set_target_properties(Rectangles PROPERTIES
    FOLDER_REFERENCE "Rectangles.xcassets"
)

Removing these manual steps would make it much easier to fully automate the iOS app build, package, and submission process. I'm happy to help with any additional design and implementation of this feature!

Hope to see some CMake people at CppCon again this year :)

Edited Oct 10, 2020 by Steve Robinson
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking