publish an xcodebuild iOS app with an healthkit based watchOS extension

I am using the xcodebuild for creating a package for publishing The app bundle contains: the iOS app itself, the push notification extension, the watchos app with its extension.

The watchOS app is using the healthkit for retrieving heart rate data.

xcodebuild archive -configuration Release -workspace $(system.defaultworkingdirectory)/MyApp/MyApp.xcworkspace -scheme MyApp -archivePath $(system.defaultworkingdirectory)/MyAppArchive CODE_SIGNING_ALLOWED=NO

xcodebuild -exportArchive -archivePath $(system.defaultworkingdirectory)/MyAppArchive.xcarchive -exportPath $(system.defaultworkingdirectory)/Final -exportOptionsPlist $(system.defaultworkingdirectory)/MyApp/ExportOptions.plist

The ExportOptions.plist contains the info for signing the app

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>provisioningProfiles</key>
    <dict>
        <key>fit.myapp.watchkitapp.watchkitextension</key>
        <string>ProvisioningProfileGUID1</string>
        <key>fit.myapp.watchkitapp</key>
        <string>ProvisioningProfileGUID2</string>
        <key>fit.myapp.notification</key>
        <string>ProvisioningProfileGUID3</string>
        <key>fit.myapp</key>
        <string>ProvisioningProfileGUID4</string>
    </dict>
    <key>signingCertificate</key>
    <string>Apple Distribution: MY COMPANY</string>
    <key>signingStyle</key>
    <string>manual</string>
    <key>method</key>
    <string>app-store</string>
    <key>teamID</key>
    <string>MYTEAMID</string>
    <key>uploadBitcode</key>
    <false/>
</dict>
</plist>

The ipa file is successfully created but when the ipa file is uploaded (by Transporter app) the package analysis fails with the following errors:

Asset validation failed (90701) Missing entitlement. watchOS app bundle 'MyApp.app/Watch/MyAppWatch.app/PlugIns/MyAppWatch Extension.appex' uses 'UIBackgroundModes' value 'workout-processing' without the required entitlement 'com.apple.developer.healthkit' signed into the bundle. (ID: cc87a6cd-2084-4712-9f45-b22b35e9574a)

Asset validation failed (90334) Invalid Code Signature Identifier. The identifier "com.apple.WK" in your code signature for "MyAppWatch" must match its Bundle Identifier "fit.myapp.watchkitapp" (ID: bb9a56d3-949c-4b49-ad86-3cf7a26a91a2)

Extra note: If the build has performed directly in Xcode/Organizer then the issue is not present.

What am I missing? How can I debug this kind of issues?

publish an xcodebuild iOS app with an healthkit based watchOS extension
 
 
Q