Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XCode refuses to run app on physical iPhone with error: The executable was signed with invalid entitlements. #7966

Closed
6 tasks done
thatjuan opened this issue Jan 24, 2017 · 4 comments

Comments

@thatjuan
Copy link

New Issue Checklist

Issue Description

When I try to run my app on a physical iPhone directly from XCode, it complains that:

screenshot 2017-01-23 17 43 15

This is what I've tried:

  • Follow Apple's Entitlements Troubleshooting Guide
  • made sure that the entitlements selected in XCode's "Capabilities" screen match the ones selected in the app id on the developer panel.
  • Re-ran match. i.e. fastlane match development fastlane match adhoc fastlane match appstore
  • Ran fastlane match decrypt and then security cms -D -i /path/to/***.mobileprovision. Although I'm not entirely sure what I'm looking for that is missing/extra/invalid.

Questions:

  1. What should these settings be for both the project and the target?
    screenshot 2017-01-23 18 31 55

  2. Which signing identity should be used for running the app on a device from xcode during development?

  3. What else can I try to troubleshoot this?

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

You can use: --capture_output as the last commandline argument to get that collected for you

### Captured Output

Command Used: `fastlane --capture_output`
<details><summary>Output/Log</summary>


Successfully loaded Appfile at path '/Users/user/Documents/Dev/MyApp/App-Client-ReactNative/MyApp/fastlane/Appfile'
- apple_id: 'ios-dev@MyApp.com'
- json_key_file: 'android/app/client-credentials.json'
- package_name: 'com.MyApp'
-------
INFO [2017-01-23 18:16:03.37]: Successfully loaded custom action '/Users/user/Documents/Dev/MyApp/App-Client-ReactNative/MyApp/fastlane/actions/sign_apk.rb'.
INFO [2017-01-23 18:16:03.38]: Successfully loaded custom action '/Users/user/Documents/Dev/MyApp/App-Client-ReactNative/MyApp/fastlane/actions/zipalign.rb'.
DEBUG [2017-01-23 18:16:03.38]: Checking if there are any plugins that should be loaded...
INFO [2017-01-23 18:16:03.44]: -------------------------------------------------
INFO [2017-01-23 18:16:03.44]: --- Step: Verifying required fastlane version ---
INFO [2017-01-23 18:16:03.44]: -------------------------------------------------
INFO [2017-01-23 18:16:03.44]: Your fastlane version 2.10.0 matches the minimum requirement of 1.111.0  ✅
INFO [2017-01-23 18:16:03.45]: ------------------------------
INFO [2017-01-23 18:16:03.45]: --- Step: default_platform ---
INFO [2017-01-23 18:16:03.45]: ------------------------------
INFO [2017-01-23 18:16:03.45]: Welcome to fastlane! Here's what your app is setup to do:
+--------+-------------------------+-----------------------------------------------------+
|                                 Available lanes to run                                 |
+--------+-------------------------+-----------------------------------------------------+
| Number | Lane Name               | Description                                         |
+--------+-------------------------+-----------------------------------------------------+
| 1      | ios test                | Runs all the tests                                  |
| 2      | ios beta                | Submit a new Beta Build to Apple TestFlight         |
|        |                         | This will also make sure the profile is up to date  |
| 3      | ios register_new_device | Register new device                                 |
| 4      | ios refresh_profiles    | A helper lane for refreshing provisioning profiles. |
| 0      | cancel                  | No selection, exit fastlane!                        |
+--------+-------------------------+-----------------------------------------------------+
WARN [2017-01-23 18:16:03.45]: Which number would you like run?

Looking for related GitHub issues on fastlane/fastlane...
Search query: Could not retrieve response as fastlane runs in non-interactive mode

URL: https://api.github.com/search/issues?q=Could%20not%20retrieve%20response%20as%20fastlane%20runs%20in%20non-interactive%20mode+repo:fastlane/fastlane
➡️  Running fastlane on Bitrise - non-interactive mode
   https://github.com/fastlane/fastlane/issues/5867 [closed] 5 💬
   06 Dec 2016

➡️  gem install fastlane started to fail
   https://github.com/fastlane/fastlane/issues/7508 [closed] 8 💬
   5 weeks ago

➡️  Cannot run fastlane on Xcode Server bot
   https://github.com/fastlane/fastlane/issues/6318 [closed] 8 💬
   a week ago

and 9 more at: https://github.com/fastlane/fastlane/search?q=Could%20not%20retrieve%20response%20as%20fastlane%20runs%20in%20non-interactive%20mode&type=Issues&utf8=✓

🔗 You can ⌘ + double-click on links to open them directly in your browser.


</details>

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

### Stack

| Key                 | Value                                       |
| ------------------- | ------------------------------------------- |
| OS                  | 10.12.2                                     |
| Ruby                | 2.3.1                                       |
| Bundler?            | false                                       |
| Git                 | git version 2.11.0                          |
| Installation Source | ~/.rbenv/versions/2.3.1/bin/fastlane        |
| Host                | Mac OS X 10.12.2 (16C67)                    |
| Ruby Lib Dir        | ~/.rbenv/versions/2.3.1/lib                 |
| OpenSSL Version     | OpenSSL 1.0.2j  26 Sep 2016                 |
| Is contained        | false                                       |
| Xcode Path          | /Applications/Xcode.app/Contents/Developer/ |
| Xcode Version       | 8.2.1                                       |


### System Locale

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


### fastlane files:

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

```ruby
fastlane_version "1.111.0"

default_platform :ios

TEAM_ID = "N7Q74VZM68"
USERNAME = "ios-dev@MyApp.com"


platform :ios do
  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", readonly: true)
    
    increment_build_number(
      xcodeproj: './ios/MyApp.xcodeproj'
    )

    ipa = gym(
      scheme: "MyApp",
      project: "./ios/MyApp.xcodeproj"
    )

    pilot(ipa: ipa)

    clean_build_artifacts

    commit_version_bump(
      message: "👷 Deployed new version #{lane_context[SharedValues::BUILD_NUMBER]} [skip ci]",
      xcodeproj: './ios/MyApp.xcodeproj'
    )
  end



  desc "Register new device"
  lane :register_new_device do  |options|
  	  sh "instruments -s devices"
      device_name = prompt(text: "Enter the device name: ")
      device_udid = prompt(text: "Enter the device UDID: ")
      device_hash = {}
      device_hash[device_name] = device_udid
      register_devices(
                       devices: device_hash
                       )
    refresh_profiles
  end

  desc "A helper lane for refreshing provisioning profiles."
  lane :refresh_profiles do
    match(
      type: "development",
      force: true)
    match(
      type: "adhoc",
      force: true)
  end




#  desc "Runs the app on a physical device"
#  lane :device do

#  	match(force: true)
#    match(app_identifier: "com.MyDomain.MyApp", type: "adhoc", verbose:true, force_for_new_devices: true)

#  end

end


platform :android do

  desc "Alpha release app. Deploy a new version to the Google Play Store - Alpha channel"
  lane :alpha do


    gradle(task: "clean", project_dir: "android/")

    gradle(task: "doBuildVersionIncrement", project_dir: "android/")

    gradle(
      task: "assemble",
      build_type: "Release",
      project_dir: "android/"
    )

#    sign_apk(
#      keystore_path: "android/app/my-app-app.keystore",
#      alias: "my-app",
#      storepass: options[:storepass],
#      tsa: "http://timestamp.comodoca.com/rfc316",
#    )

    #zipalign(apk_path: "#{lane_context[SharedValues::SIGNED_APK_PATH]}")

    supply(
      track: "alpha",
      apk: "#{lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]}"
    )
  end

end```
</details>

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

ruby
#iOS
apple_id 'ios-dev@MyApp.com'

#Android
json_key_file "android/app/client-credentials.json"
package_name "com.MyApp"

</details>

### fastlane gems

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


### Loaded fastlane plugins:

**No plugins Loaded**


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

| Gem                       | Version      |
| ------------------------- | ------------ |
| did_you_mean              | 1.0.0        |
| slack-notifier            | 1.5.1        |
| CFPropertyList            | 2.3.4        |
| claide                    | 1.0.1        |
| colored                   | 1.2          |
| nanaimo                   | 0.2.3        |
| xcodeproj                 | 1.4.1        |
| rouge                     | 1.11.1       |
| xcpretty                  | 0.2.4        |
| terminal-notifier         | 1.7.1        |
| terminal-table            | 1.4.5        |
| plist                     | 3.2.0        |
| multipart-post            | 2.0.0        |
| word_wrap                 | 1.0.0        |
| babosa                    | 1.0.2        |
| highline                  | 1.7.8        |
| commander                 | 4.4.1        |
| faraday                   | 0.10.0       |
| unf_ext                   | 0.0.7.2      |
| unf                       | 0.1.4        |
| domain_name               | 0.5.20161129 |
| http-cookie               | 1.0.3        |
| faraday-cookie_jar        | 0.0.6        |
| gh_inspector              | 1.0.2        |
| 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.1.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.20       |
| mini_magick               | 4.5.1        |
| multi_xml                 | 0.6.0        |
| security                  | 0.1.3        |
| xcpretty-travis-formatter | 0.0.4        |
| dotenv                    | 2.1.1        |
| bundler                   | 1.13.6       |
| faraday_middleware        | 0.10.1       |
| json                      | 2.0.2        |
| io-console                | 0.4.5        |
| excon                     | 0.54.0       |
| rubyzip                   | 1.2.0        |
</details>


*generated on:* **2017-01-23**
</details>
@fastlane-bot
Copy link

It seems like this issue might be related to code signing 🚫

Have you seen our new Code Signing Troubleshooting Guide? It will help you resolve the most common code signing issues 👍

@thatjuan
Copy link
Author

I've switched to Automatic signing as per @hjanuschka's approach found in #6757 but sadly I still get the same "invalid entitlements" error.

@thatjuan
Copy link
Author

... and, finally fixed this. Just in case some other poor soul out there is spinning their wheels, here's what was broken in my case.

The App ID on the dev portal has 3 options for data protection:

screenshot 2017-01-25 01 17 40

However, Xcode doesn't:

screenshot 2017-01-25 01 18 33

The setting has to match anyway, so I hadn't noticed that the entitlements file was set to NSFileProtectionComplete as opposed to NSFileProtectionCompleteUntilFirstUserAuthentication

Making that change, along with switching to Automatic Signing (which in hindsight might have had no effect), fixed the issue. I may switch back to match-managed development profiles and see what happens.

@mgrebenets
Copy link
Collaborator

👍

@fastlane fastlane locked and limited conversation to collaborators Apr 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants