Tuist 4.79.0 supports excluding files from buildable folders and setting compiler flags

As you might know, we added support for buildable folders not too long ago, but some of you couldn’t migrate because it lacked certain features or had bugs in other areas like the resource interfaces we generate based on target sources and resources.

I’m happy to share that we’ve tackled a couple of key needs:

  • Excluding files
  • Setting compiler flags

The API is already available in Tuist 4.79.0:

I’m working on fixing the issues that you reported too.

3 Likes

And in 4.79.4 you can now also set headers in buildable folders as public or private (they have the project access level by default):

let target: Target = .target(
          name: "Framework",
          destinations: .iOS,
          product: .staticFramework,
          bundleId: "dev.tuist.Framework",
          buildableFolders: [
              "Framework/Resources",
              .folder("Framework/Sources", exceptions: .exceptions([
                  .exception(
                     publicHeaders: ["Framework.h", "include/bar.h", "include/baz.h"]
                  ),
              ])),
          ]
      )

Hello, was reading through the docs related to “excluded” an it’s an absolute path
excluded: An array of absolute paths to files that should be excluded from the buildable folder.

Why not ignore like extension “*.json" or *.plist” or “*.xcassets

The excluded items are relative paths to the buildable folder’s directory, and it’s not a glob because we mimicked Xcode projects’ API which doesn’t support globs. We could add support for it such that we resolve the glob at generation time, but I’d rather stay close to Xcode and avoid globing, which translates to an increased generation time. Do you have a lot of files to exclude?

I have lot of .json files in the Test target and .xcassets folders in normal target. The way i was expecting was similar to Xcode, when you have buildable folder in xcode and if you add any file in the folder (from finder) and Xcode works fine. I was expecting the same for tuist as well. Not matter the files present it in folder it should have added it. But I understand that it might not be possible that’s why i was thinking if I could ignore these files in buildable folder then I can add them in resources using glob

I’ve created a sample here as well

Hey @inder

The implementation maps 1-to-1 Xcode’s behavior. A buildable folder is:

  • A path to a directory in your system
  • A set of exceptions for excluding files or overriding attributes (e.g. a header access level)

Xcode’s UI might make it convenient to define exceptions for a group of files (e.g. an entire folder), and we could bring that convenience to the generation process, but this makes buildable folders dependent on re-generation, defeating the value of buildable folders in the first place because this is something that’s already solved by Target.sources, & Target.resources. So my advise is:

  • If you want to use globs, use Target.sources and Target.resources
  • Otherwise, use Target.buildableFolders and list the exclusions. If your list is long, you can move your files around in the file-system to group them in folders and exclude the whole folder.

I’m not finding that excluding a whole folder works?

It seems there is anexplicitFoldersattribute (https://swiftpackageindex.com/tuist/xcodeproj/9.0.2/documentation/xcodeproj/pbxfilesystemsynchronizedrootgroup/explicitfolders) missing inside the pbxproj if I compare the tuist generated project with a project modified inside Xcode. This is only needed for folders not files

You’re right, let us work on a fix.

This should fix the issue @Jon889 fix(cli): populate explicitFolders for excluded directories in buildable folders by fortmarek · Pull Request #9578 · tuist/tuist · GitHub

Oh wow that was amazingly quick, thank you! :star_struck:

1 Like