opened
gtatgh
username_0
### Issue Description

I'am new to `fastlane` and I think, i have a build problem with `xcodebuild`, not `fastlane` itself. So I am trying to exort my project with `fastlane gym`, but it fails on building a _WatchKit Extension_ target. There is missing provisioning profile created by Xcode itself. This PP is not listed at Apple Dev Portal, it exists **only** local on my developer machine. This PP is generic one, also does not contains an app id. So i tried to create one by `match` and build again, but it fails. Only specific PP created by Xcode is able to build _WatchKit Extension_ target.

[PP created by Xcode](http://prnt.sc/el07i0)
[PP created by match](http://prnt.sc/el07nq)

So my question is it possible to add this PP created by Xcode to provisioning provile repo? And how can i do that?

<details><summary>✅ Matchfile ✅</summary>
git_url "ssh://***/ios_certificates.git"
type "adhoc" # The default type, can be: appstore, adhoc or development
app_identifier ["*", "com.app.MyApp"]
</details>

##### Complete output when running fastlane, including the stack trace and command used

<details><summary>✅ fastlane log output ✅</summary>

08:39 username_0:MyApp-ios-app$ fastlane gym
[08:39:26]: Successfully loaded '/Users/username_0/projects/ios/apps/MyApp-ios-app/fastlane/Gymfile' 📄

+---------------------+---------------------+
| Detected Values from './fastlane/Gymfile' |
+---------------------+---------------------+
| workspace           | MyApp.xcworkspace    |
| scheme              | MyApp               |
| export_method       | ad-hoc              |
| output_directory    | output              |
| clean               | true                |
+---------------------+---------------------+

[08:39:26]: Successfully loaded '/Users/username_0/projects/ios/apps/MyApp-ios-app/fastlane/Gymfile' 📄
[08:39:26]: No values defined in './fastlane/Gymfile'
[08:39:27]: $ xcodebuild -list -workspace MyApp.xcworkspace
[08:39:27]: $ xcodebuild clean -showBuildSettings -workspace MyApp.xcworkspace -scheme MyApp

+----------------------+-------------------------+
|             Summary for gym 2.20.0             |
+----------------------+-------------------------+
| workspace            | MyApp.xcworkspace        |
| scheme               | MyApp                   |
| export_method        | ad-hoc                  |
| output_directory     | output                  |
| clean                | true                    |
| destination          | generic/platform=iOS    |
| output_name          | MyApp                   |
| silent               | false                   |
| use_legacy_build_api | false                   |
| buildlog_path        | ~/Library/Logs/gym      |
| xcode_path           | /Applications/Xcode.app |
+----------------------+-------------------------+

[08:39:28]: $ set -o pipefail && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -destination 'generic/platform=iOS' -archivePath /Users/username_0/Library/Developer/Xcode/Archives/2017-03-17/MyApp\ 2017-03-17\ 08.39.28.xcarchive clean archive | tee /Users/username_0/Library/Logs/gym/MyApp-MyApp.log | xcpretty
[08:39:29]: ▸ Cleaning Pods/MGSwipeTableCell [Debug]
[08:39:29]: ▸ Check Dependencies
[08:39:29]: ▸ Cleaning Pods/iToast [Debug]
[08:39:29]: ▸ Check Dependencies
[08:39:29]: ▸ Cleaning Pods/IQKeyboardManager [Debug]
[08:39:29]: ▸ Check Dependencies
[08:39:29]: ▸ Cleaning MyApp/MyAppWatch Extension [Debug]
[08:39:29]: ▸ Check Dependencies
[08:39:29]: ▸ Cleaning Pods/FMDB-iOS8.0 [Debug]
[08:39:29]: ▸ Check Dependencies
[08:39:29]: ▸ Cleaning MyApp/MyAppWatch [Debug]
[08:39:29]: ▸ Check Dependencies
[08:39:29]: ▸ Cleaning Pods/Pods-MyApp [Debug]
[08:39:29]: ▸ Check Dependencies
[08:39:29]: ▸ Cleaning MyApp/MyApp [Debug]
[08:39:29]: ▸ Check Dependencies
[08:39:29]: ▸ Clean Succeeded
[08:39:29]: ▸ Building MyApp/MyAppWatch Extension [Release]
[08:39:29]: ▸ Check Dependencies
[08:39:29]: ▸ Code signing is required for product type 'WatchKit Extension' in SDK 'watchOS 3.1'
[08:39:29]: ▸ Building Pods/FMDB-iOS8.0 [Release]
[08:39:29]: ▸ Check Dependencies
[08:39:30]: ▸ Building Pods/IQKeyboardManager [Release]
[08:39:30]: ▸ Check Dependencies
[08:39:30]: ▸ Building Pods/MGSwipeTableCell [Release]
[08:39:30]: ▸ Check Dependencies
[08:39:30]: ▸ Processing Info.plist
[08:39:30]: ▸ Compiling MGSwipeButton.m
[08:39:30]: ▸ Compiling MGSwipeTableCell-dummy.m
[08:39:30]: ▸ Building Pods/iToast [Release]
[08:39:30]: ▸ Check Dependencies
[08:39:30]: ▸ Processing Info.plist
[08:39:30]: ▸ Compiling iToast-dummy.m
[08:39:30]: ▸ Compiling iToast.m
[08:39:30]: ▸ Compiling iToast_vers.c
[08:39:30]: ▸ Compiling iToast-dummy.m
[08:39:30]: ▸ Compiling iToast.m
[08:39:30]: ▸ Compiling iToast_vers.c
[08:39:30]: ▸ ** ARCHIVE FAILED **
[08:39:30]: ▸ The following build commands failed:
[08:39:30]: ▸ Check dependencies
[08:39:30]: ▸ (1 failure)
▸ Cleaning Pods/MGSwipeTableCell [Debug]
▸ Check Dependencies
▸ Cleaning Pods/iToast [Debug]
▸ Check Dependencies
▸ Cleaning Pods/IQKeyboardManager [Debug]
▸ Check Dependencies
▸ Cleaning MyApp/MyAppWatch Extension [Debug]
▸ Check Dependencies
▸ Cleaning Pods/FMDB-iOS8.0 [Debug]
▸ Check Dependencies
▸ Cleaning MyApp/MyAppWatch [Debug]
▸ Check Dependencies
▸ Cleaning Pods/Pods-MyApp [Debug]
▸ Check Dependencies
▸ Cleaning MyApp/MyApp [Debug]
▸ Check Dependencies
▸ Clean Succeeded
▸ Building MyApp/MyAppWatch Extension [Release]
▸ Check Dependencies

Code signing is required for product type 'WatchKit Extension' in SDK 'watchOS 3.1'


▸ Building Pods/FMDB-iOS8.0 [Release]
▸ Check Dependencies
▸ Building Pods/IQKeyboardManager [Release]
▸ Check Dependencies
▸ Building Pods/MGSwipeTableCell [Release]
▸ Check Dependencies
▸ Processing Info.plist
▸ Compiling MGSwipeButton.m
▸ Compiling MGSwipeTableCell-dummy.m
▸ Building Pods/iToast [Release]
▸ Check Dependencies
▸ Processing Info.plist
▸ Compiling iToast-dummy.m
▸ Compiling iToast.m
▸ Compiling iToast_vers.c
▸ Compiling iToast-dummy.m
▸ Compiling iToast.m
▸ Compiling iToast_vers.c
** ARCHIVE FAILED **


The following build commands failed:
Check dependencies
(1 failure)
[08:39:30]: Exit status: 65
[08:39:30]: 📋  For a more detailed error log, check the full log at:
[08:39:30]: 📋  /Users/username_0/Library/Logs/gym/MyApp-MyApp.log
[08:39:30]: Found multiple versions of Xcode in '/Applications/'
[08:39:30]: Make sure you selected the right version for your project
[08:39:30]: This build process was executed using '/Applications/Xcode.app'
[08:39:30]: If you want to update your Xcode path, either
[08:39:30]: 
[08:39:30]: - Specify the Xcode version in your Fastfile
[08:39:30]: ▸ xcversion(version: "8.1") # Selects Xcode 8.1.0
[08:39:30]: 
[08:39:30]: - Specify an absolute path to your Xcode installation in your Fastfile
[08:39:30]: ▸ xcode_select "/Applications/Xcode8.app"
[08:39:30]: 
[08:39:30]: - Manually update the path using
[08:39:30]: ▸ sudo xcode-select -s /Applications/Xcode.app
[08:39:30]: 

+-------------+-------------------------+
|           Build environment           |
+-------------+-------------------------+
| xcode_path  | /Applications/Xcode.app |
| gym_version | 2.20.0                  |
| sdk         | iPhoneOS10.2.sdk        |
+-------------+-------------------------+


[!] Error building the application - see the log above

</details>

### Environment

<details><summary>✅ developer machine ✅</summary>
username_0:MyApp-ios-app$ xcodebuild -showsdks
iOS SDKs:
	iOS 10.2                      	-sdk iphoneos10.2

iOS Simulator SDKs:
	Simulator - iOS 10.2          	-sdk iphonesimulator10.2

macOS SDKs:
	macOS 10.12                   	-sdk macosx10.12

tvOS SDKs:
	tvOS 10.1                     	-sdk appletvos10.1

tvOS Simulator SDKs:
	Simulator - tvOS 10.1         	-sdk appletvsimulator10.1

watchOS SDKs:
	watchOS 3.1                   	-sdk watchos3.1

watchOS Simulator SDKs:
	Simulator - watchOS 3.1       	-sdk watchsimulator3.1

username_0:MyApp-ios-app$ xcodebuild -version
Xcode 8.2
Build version 8C38
username_0:MyApp-ios-app$ uname -a
Darwin mac.local 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64
</details>

<details><summary>✅ fastlane environment ✅</summary>

### Stack

| Key                         | Value                                       |
| --------------------------- | ------------------------------------------- |
| OS                          | 10.12.3                                     |
| Ruby                        | 2.4.0                                       |
| Bundler?                    | false                                       |
| Git                         | git version 2.9.2                           |
| Installation Source         | ~/.rbenv/versions/2.4.0/bin/fastlane        |
| Host                        | Mac OS X 10.12.3 (16D32)                    |
| Ruby Lib Dir                | ~/.rbenv/versions/2.4.0/lib                 |
| OpenSSL Version             | OpenSSL 1.0.2k  26 Jan 2017                 |
| Is contained                | false                                       |
| Is homebrew                 | false                                       |
| Is installed via Fabric.app | false                                       |
| Xcode Path                  | /Applications/Xcode.app/Contents/Developer/ |
| Xcode Version               | 8.2                                         |


### System Locale

| Variable | Value       |   |
| -------- | ----------- | - |
| LANG     | de_DE.UTF-8 | ✅ |
| LC_ALL   |             |   |
| LANGUAGE |             |   |


### fastlane files:

<details><summary>`./fastlane/Fastfile`</summary>

```ruby
# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://docs.fastlane.tools/actions
# can also be listed using the `fastlane actions` command

# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`

# If you want to automatically update fastlane if a new version is available:
# update_fastlane

# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "2.19.3"

default_platform :ios

platform :ios do
  before_all do
    # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
    cocoapods
    
  end

  desc "Runs all the tests"
  lane :test do
    scan
  end

  desc "Submit a new Beta Build to Apple TestFlight"
  desc "This will also make sure the profile is up to date"
  lane :beta do
    # match(type: "appstore") # more information: https://codesigning.guide
    gym # Build your app - more options available
    pilot

    # sh "your_script.sh"
    # You can also use other beta testing services here (run `fastlane actions`)
  end

  desc "Deploy a new version to the App Store"
  lane :release do
    # match(type: "appstore")
    # snapshot
    gym # Build your app - more options available
    deliver(force: true)
    # frameit
  end

  # You can define as many lanes as you want

  after_all do |lane|
    # This block is called, only if the executed lane was successful

    # slack(
    #   message: "Successfully deployed new App Update."
    # )
  end

  error do |lane, exception|
    # slack(
    #   message: exception.message,
    #   success: false
    # )
  end
end


# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
# All available actions: https://docs.fastlane.tools/actions

# fastlane reports which actions are used
# No personal data is recorded. Learn more at https://github.com/fastlane/enhancer
```
</details>

<details><summary>`./fastlane/Appfile`</summary>

```ruby
app_identifier "com.gigatronik.app.M-Vap" # The bundle identifier of your app
apple_id "artem.werner@gigatronik.com" # Your Apple email address

team_id "EB7CQ2HWFZ"  # Developer Portal Team ID

# you can even provide different app identifiers, Apple IDs and team names per lane:
# More information: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Appfile.md
```
</details>

### fastlane gems

| Gem      | Version | Update-Status |
| -------- | ------- | ------------- |
| fastlane | 2.20.0  | ✅ Up-To-Date  |


### Loaded fastlane plugins:

**No plugins Loaded**


<details><summary><b>Loaded gems</b></summary>

| Gem                       | Version      |
| ------------------------- | ------------ |
| did_you_mean              | 1.1.0        |
| slack-notifier            | 1.5.1        |
| i18n                      | 0.8.1        |
| thread_safe               | 0.3.6        |
| tzinfo                    | 1.2.2        |
| minitest                  | 5.10.1       |
| activesupport             | 4.2.8        |
| CFPropertyList            | 2.3.5        |
| claide                    | 1.0.1        |
| colored                   | 1.2          |
| nanaimo                   | 0.2.3        |
| xcodeproj                 | 1.4.2        |
| rouge                     | 1.11.1       |
| xcpretty                  | 0.2.4        |
| terminal-notifier         | 1.7.1        |
| unicode-display_width     | 1.1.3        |
| terminal-table            | 1.7.3        |
| plist                     | 3.2.0        |
| public_suffix             | 2.0.5        |
| addressable               | 2.5.0        |
| multipart-post            | 2.0.0        |
| word_wrap                 | 1.0.0        |
| tty-screen                | 0.5.0        |
| babosa                    | 1.0.2        |
| highline                  | 1.7.8        |
| commander                 | 4.4.3        |
| excon                     | 0.55.0       |
| faraday                   | 0.11.0       |
| unf_ext                   | 0.0.7.2      |
| unf                       | 0.1.4        |
| domain_name               | 0.5.20170223 |
| http-cookie               | 1.0.3        |
| faraday-cookie_jar        | 0.0.6        |
| fastimage                 | 2.1.0        |
| gh_inspector              | 1.0.3        |
| uber                      | 0.0.15       |
| representable             | 2.3.0        |
| retriable                 | 2.1.0        |
| mime-types-data           | 3.2016.0521  |
| mime-types                | 3.1          |
| hurley                    | 0.2          |
| little-plugger            | 1.1.4        |
| multi_json                | 1.12.1       |
| logging                   | 2.2.0        |
| jwt                       | 1.5.6        |
| memoist                   | 0.15.0       |
| os                        | 0.9.6        |
| signet                    | 0.7.3        |
| googleauth                | 0.5.1        |
| httpclient                | 2.8.3        |
| google-api-client         | 0.9.28       |
| json                      | 2.0.2        |
| mini_magick               | 4.5.1        |
| multi_xml                 | 0.6.0        |
| rubyzip                   | 1.2.1        |
| security                  | 0.1.3        |
| xcpretty-travis-formatter | 0.0.4        |
| dotenv                    | 2.2.0        |
| bundler                   | 1.14.6       |
| faraday_middleware        | 0.11.0.1     |
| io-console                | 0.4.6        |
| openssl                   | 2.0.2        |
</details>


*generated on:* **2017-03-17**
</details>
Code signing is required for product type 'WatchKit Extension' in SDK 'watchOS 3.1'
issue
created
hjanuschka
username_1
<img width="1070" alt="bildschirmfoto 2017-03-17 um 09 48 26" src="https://cloud.githubusercontent.com/assets/2891702/24035708/efe59d52-0af6-11e7-82b9-adf2f46a59a7.png">


to find the correct env variable to use, see the output of match it comes out like this:

```
+---------------------+----------------------------------------------------------------------------+----------------------------------------------------------------+
|                                                                  Installed Provisioning Profile                                                                   |
+---------------------+----------------------------------------------------------------------------+----------------------------------------------------------------+
| Parameter           | Environment Variable                                                       | Value                                                          |
+---------------------+----------------------------------------------------------------------------+----------------------------------------------------------------+
| App Identifier      |                                                                            | krone.at-krone.at.watchkitapp.watchkitextension                |
| Type                |                                                                            | appstore                                                       |
| Profile UUID        | sigh_krone.at-krone.at.watchkitapp.watchkitextension_appstore              | 757988e4-0f7a-4799-b98a-a0e038bdc0dc                           |
| Profile Name        | sigh_krone.at-krone.at.watchkitapp.watchkitextension_appstore_profile-name | match AppStore krone.at-krone.at.watchkitapp.watchkitextension |
| Development Team ID | sigh_krone.at-krone.at.watchkitapp.watchkitextension_appstore_team-id      | H2YB79SEHH                                                     |
+---------------------+----------------------------------------------------------------------------+----------------------------------------------------------------+
```

the `profile-name` name variable is used

let me know if this helps you.
comment
created
gtatgh
username_0
@username_1 Thanks, i will try it.
comment
created
zaro0508
username_2
I'm a bit of a fastlane newbie.  I'm using fastlane ver 2.22.0 and xcode 8.2 trying to run build on Travis.  I'm also trying to use match to manage profiles and certs.  I believe i have all that setup correctly so I was under the impression that if you are using match you don't need to configure what @username_1 suggested above to use fastlane with "automatic code signing".  Isn't match supposed to handle that for you?  I'm getting the same codesigning error as @username_0 and the only way I got it to build is by disabling "automatic code signing" in all targets in my project.   

Also I'm wondering where  disable_automatic_code_signing and enable_automatic_code_signing are coming from in @username_1 example.  I don't see those in the [fastlane docs](https://docs.fastlane.tools/actions/).  I do see update_project_provisioning however there's no parameter to allow disabling automatic code signing.
comment
created
mgrebenets
username_3
Hi @username_2 

`match` doesn't touch your Xcode project.
`match` is all about provisioning you Mac OS with certificates and profiles.

When it comes to configuring Xcode project build settings - it's all up to a developer.
It can be done either manually by following the guides, or even by trying out some plugins or other tools. I've always been doing it by hand so far, either working with build settings directly or by moving the into `xcconfig` files.
comment
created
zaro0508
username_2
I've got fastlane match working and I can archive/export my project on Travis *only* if I disable "automatically manage signing" in all my targets.

I then attempted to use do the toggle "automatic manage signing" trick suggested by @username_1 above however when i did that I get the error "Code signing is required for product type 'WatchKit Extension' in SDK 'watchOS 3.1'".   I did notice that when I ran disable_automatic_code_signing then looked at my xcode project the "automatically manage signing" was disabled but the "Provisioning Profile" did not get set to value.  I have setup the provisioning profile in xcode to "$(sigh_org.sagebase.BridgeAppSDKSample_appstore_profile-name)".  Is there something else that needs to be done to get this working?

This my lane:

```
 lane :archive do |options|
    scheme = options[:scheme]
    export_method = options[:export_method]
    certificates       # call to run match
    disable_automatic_code_signing(path: "BridgeAppSDK.xcodeproj")
    gym(
      scheme: "#{scheme}",
      clean: true,
      include_bitcode: true,
      output_directory: "./build",
      output_name: "#{scheme}.ipa",
      export_method: "#{export_method}",
      destination: "generic/platform=iOS",
    )
    enable_automatic_code_signing(path: "BridgeAppSDK.xcodeproj")
  end
```
comment
closed
gtatgh
username_0
issue
created
gtatgh
username_0
If someone have the same issue, here is the solution found. I have to set developer team id explicit `DEVELOPMENT_TEAM =  $(sigh_com.mycompany.myapp.watchkitapp_adhoc_team-id)";` for **all** targets.
comment
created
AndriyGo
username_4
@username_1 whenever I try to use match for the .watchkitapp (not .watchkitapp.watchkitextension) I get an error saying that an app with such ID does not exist on the Dev portal...
comment