Use xcconfig to specify the targets app group value

While I do realize that this question is not Tuist specific, I do hope that someone can give advice anyways …

We are using Tuist for a project with 3 developers that have individual developer accounts. For the bundle identifier, we are using an xcconfig file, in which everyone is filling in their team id. Tuist setup is fine, so on tuist generate, it’ll fill in the respective bundle id correctly.

We are now on a branch where we’re trying to implement a Widget. To be able to share resources between targets, we need to add an app group to the targets.

We are currently failing to find an answer to the question of how we can achieve providing individual app group ids in our respective xcconfig files.

Is this even the way to go or is this not possible?

Hi @appfrosch, and welcome to the forum.

Apologies for the misleading LLM-generated response in Slack. We are playing with a new technology to help us a bit with the support load (the team is small), but it’s not yielding accurate respones in some cases.

App groups are defined in entitlement files. You can create an .entitlements files for the target for which you are setting the group, and then set it to the target:

let target = Target(..., entitlements: "MyTarget.entitlements")

Once you do that, you can generate the project, and modify the entitlements through Xcode’s UI. All the changes done through the UI should get automatically persisted to the entitlements file that you referenced from your target.

Let me know if that answers your question :slight_smile:

Good morning,

definitely no need to apologise–I appreciate your efforts!

I think it’s a good idea to leverage AI to be used for stuff like that–even though the answer wasn’t accurate. It makes sense for a small team like yours.

(Having said that, I’d totally understand if you’d prefer to relax on this beautiful Sunday and would answer some time next week :raised_hands: )

Now, here’s what I tried just now, trying to comprehend what you just told me:

  • opened the manifest with tuist edit
  • changed my entitlements definition in Target to reference a file called AppTarget.entitlements
  • did a touch AppTarget.entitlements at the top level of my project, cause it seems as though the file needs to be there already
  • opened the project with tuist generate

Now, if I understand correctly, if I now add the “App Group” capability in Xcode to the target, this change should be reflected in AppTarget.entitlements, right?

If so, behavior on my machine right now is that upon trying to add the capability in Xcode, nothing happens …

Where’s my mistake?

I think I see now where my mistake is.

I thought that the entitlements file will be populated on adding the app group entitlement.

What worked now for me was to

  • stash above mentioned steps
  • add the entitlement to the project
  • copy the entitlements file this produced to a Resources folder

After that, I did the steps mentioned above, specifying the file path to the entitlement–which works like a charm now.