make App Clip work with different main app build configurations

I have two different build configurations (Debug & Release), backed by their respective *.xcconfig file.

The app also embeds an App Clip.

Both build configs have a different Bundle ID, which are both registered properly in the dev center. Everything worked fine (I could have both configs installed and running on my phone as two separately identified apps) before I added the App Clip.

Now since I added the App Clip, I cannot anymore compile my app properly in both configurations. I get different issues in either scenario and it has to do with my App Clip not matching either of the main app's build configurations.

I think my problem boils down to my inability of making the App Clip's "Parent Application Identifiers" work both ways.

If I set that to my main app's ID $(AppIdentifierPrefix)com.my.app I can build Release fine - which is what I currently fall back to - I live with the fact I can only debug with the Release config for now.

If I set it to my debug app's ID $(AppIdentifierPrefix)com.my.app.staging I get

The com.apple.developer.parent-application-identifiers entitlement ('["TEAMID.com.my.app"]') of an App Clip must match the application-identifier entitlement ('TEAMID.com.my.app.staging') of its containing parent app.

If I just add both app ids there - since it's an array in the plist file, I get

There can only be one parent application identifier associated with an app clip, but multiple parent application identifiers were found in the entitlement plist.

I had tried to add different build configurations for the App Clip and setting its "Parent Application Identifiers" dynamically as $(AppIdentifierPrefix)com.my.app$(BUNDLE_ID_SUFFIX) where BUNDLE_ID_SUFFIX would be either empty or staging but that also didnt' work for a reason I don't really remember right now.

The thing is - I don't even really need the App Clip in Debug, since it won't run anyway. Debug is never pushed to Apple, so the App Clip wouldn't ever work anyway.

So maybe my actual question is: How can I just not include the App Clip at all in my Debug build?

Were you able to figure this out? I'm in the same boat right now.

We've been trying to do the same for the last weeks and I find no way to properly configure it. In our case we have Beta and Release. Both configurations with different bundle identifiers: com.demo.app and com.demo.app.beta. I've tried to configure the project to use different entitlement files for both the app and the appClip. After a call with an Apple Engineer they told me the way we should use to trick Xcode is using xcconfig files and set user-defined variables to setup the bundle identifiers and to set the parent app bundle id in the entitlement files; and use only entitlement file per target. After configuring everything the same signing errors appear. I feel like it may be a bug in Xcode. A valid alternative for me would be to be able to configure Xcode to avoid assigning an appClip for the beta configuration, as dmrschmidt2 is pointing out but I think that would be even harder to accomplish.

You can solve your issue as follows: The following steps assume that

  • You have two configurations files defined as debug.xcconfig and release.xcconfig in your Xcode project.
  • You have set up the Debug configuration to debug.xcconfig for both your app and App Clip in the Info pane of your Xcode project.
  • You have set up the Release configuration to release.xcconfig for both your app and App Clip in the Info pane of your Xcode project.
  1. Define a new value in both of your xcconfig files. We use this value to switch between product identifiers for your app and App Clips when building for your various build configurations.

    In debug.xcconfig

     BASE_IDENTIFIER =  com.demo.app
    

    In release.xcconfig

     BASE_IDENTIFIER =  com.demo.app.beta
    
  2. Verify that BASE_IDENTIFIER appears as set above for the various build configurations under the User-Defined section of the Build Settings pane of both your app and App Clips.

  3. In the Build Settings pane of the target building your app, set the product bundle identifier (PRODUCT_BUNDLE_IDENTIFIER) setting to $(BASE_IDENTIFIER) for all of your configurations.

  4. In the Build Settings pane of the target building your App Clip, set the product bundle identifier (PRODUCT_BUNDLE_IDENTIFIER) setting to $(BASE_IDENTIFIER).Clip for all of your configurations.

  5. In your App Clip's entitlement file, set the Parent Application Identifier entry under Parent Application Identifiers to $(AppIdentifierPrefix)$(BASE_BUNDLE_IDENTIFIER). There should only be an entry under Parent Application Identifiers.

I tried this approach after a meeting with an engineer (maybe it was you? :D) last week and sadly it doesn't work, same error appears. Here are some screenshots with the steps I followed:

  1. Added xcconfig files for Debug, Beta and Release configs and add a user-defined variable (in my case called BASE_BUNDLE_IDENTIFIER and PARENT_APP_BUNDLE_IDENTIFIER in the AppClip xcconfigs):

And set these xcconfig files as the configuration files for each configuration of the target:

  1. Verify that BASE_BUNDLE_IDENTIFIER appears as set above the various build configurations under the user-defined section of the build settings pane of both your app and app clips:

  1. In the Build Settings pane of the target building your app, set the product bundle identifier (PRODUCT_BUNDLE_IDENTIFIER) setting to $(BASE_IDENTIFIER) for all of your configurations:

  1. In the Build Settings pane of the target building your App Clip, set the product bundle identifier (PRODUCT_BUNDLE_IDENTIFIER) setting to $(PARENT_APP_BUNDLE_IDENTIFIER).Clip for all of your configurations:

  1. In your App Clip's entitlement file, set the Parent Application Identifier entry under Parent Application Identifiers to $(AppIdentifierPrefix)$(PARENT_APP_BUNDLE_IDENTIFIER). There should only be an entry under Parent Application Identifiers.

  1. Also in the main target's entitlement make sure that the app associated appclip identifier matches the bundle identifier of the AppClip using the user-defined variable:

Any idea about this? am I doing something wrong or might it be an Xcode issue, @DTS Engineer?

I still haven't resolved this issue. My problem is that our main app has an enterprise configuration. Even when I have the Xcode scheme configured not to build the enterprise configuration, it still validates the certificates for both the release and enterprise configuration of the parent app. Is there any way to prevent it from trying to embed and validate the app clip for an enterprise configuration? The only way I've been able to get around it so far is to manually set all the configurations in the parent app to use the app store release bundle ID and certificate when I need to build and embed the app clip.

I was able to get it working borrowing from @DTS Engineer 's approach but with specific entitlements files per build configuration. So using the xcconfig files he mentions do something like:

APP_CLIP_ENTITILEMENTS = myProject/myProject.entitlements then specify $(APP_CLIP_ENTITLEMENTS) under Code Signing Entitlements in Build Settings

and just create different entitlements files for each project.

I also tried the full suggestion above beforehand and couldn't get it to work as it doesn't seem like Xcode interpolates the variables in the entitlements file (but it would be nice if it did! certainly nicer than copying entitlement files in this specific case).

make App Clip work with different main app build configurations
 
 
Q