Fastlane Gym change provisioning profile only for one target

I am trying to setup Jenkins with fastlane. I got two targets in my project - main app and watch kit extension. When I try to change profile for Ad Hoc signing with xcargs, gym change profile for all targets and my builds fail.

This is my gym command.

gym(scheme: "MyApp", 
      workspace: "MyApp.xcworkspace",
      xcargs: "PROVISIONING_PROFILE_SPECIFIER='MyApp Ad Hoc'")

This is output.

Building MyApp/MyApp WatchKit App [Release]
[08:34:48]: ▸ Check Dependencies
[08:34:48]: ▸ ❌  Provisioning profile "MyApp Ad Hoc" doesn't match the entitlements file's value for the application-identifier entitlement.

How to change profile only for a specific target? Thank you.


You should use the provisioningProfiles option as follows:

gym(
  ...
  export_options:{
    signingStyle: "manual",
    provisioningProfiles:{
        "com.myapp.iosapp": "match AdHoc com.myapp.iosapp"
    }