fastlane-old / gym

Building your iOS apps has never been easier
https://fastlane.tools
645 stars 54 forks source link

The embedded provisioning profile seems wrong #199

Closed steffendsommer closed 8 years ago

steffendsommer commented 8 years ago

I've been experimenting with gym (and cert and sigh since I'm dealing with an enterprise account) for a couple of days now, and it's going good. At some point, the builds uploaded to Crashlytics were not installable because they were no longer recognised as being enterprise builds.

I've tried backtracking a lot, but I cannot see what should cause this error on my end. I've noticed that even though Fastlane outputs the correct cert and sigh variables in the terminal, e.g. team_id and cert_id, the .ipa file that gets created is provisioned using another certificate. How can this be?

I narrowed my Fastfile down to:

    cert(
      team_id: "MyTeamId"
    )
    sigh(
      cert_id: "MyCertId"
    )
    gym(
      scheme: "My TestApp",
      clean: true,
      export_method: "enterprise",
      use_legacy_build_api: true
    )
    crashlytics

The Appfile is also pretty simple:

app_identifier "myappidentifier" # The bundle identifier of your app
apple_id "foo@foo.com" # The Apple email address
team_id "MyTeamId" # Developer Portal Team ID

These values are the same as outputted when running this lane. However when I inspect the .ipa file created in the project folder, it is using another team id and bundle identifier! Values which are also accessible from my developer account, but on another team. The values from the ipa is values I used in another lane yesterday, but which I completely removed from my Fastfile. It's like it's using some cached ipa all the time, even though that is not what the terminal is showing.

The terminal output:

> fastlane find_bug_lane
[13:40:12]: ------------------------------
[13:40:12]: --- Step: default_platform ---
[13:40:12]: ------------------------------
[13:40:12]: Driving the lane 'ios find_bug_lane' 🚀
[13:40:12]: ------------------
[13:40:12]: --- Step: cert ---
[13:40:12]: ------------------

+---------------+---------------------------------------------+
|                   Summary for cert 1.2.8                    |
+---------------+---------------------------------------------+
| development   | false                                       |
| force         | false                                       |
| username      | foo@foo.com                          |
| team_id       | MyTeamId                                  |
| keychain_path | /Users/sds/Library/Keychains/login.keychain |
+---------------+---------------------------------------------+

[13:40:13]: Starting login with user 'foo@foo.com'
[13:40:15]: Successfully logged in
[13:40:18]: Certificate SomeOtherCertId (Company ApS) can't be found on your local computer
[13:40:20]: Found the certificate MyCertId (Company ApS) which is installed on the local machine. Using this one.
[13:40:20]: Use signing certificate 'MyCertId' from now on!
[13:40:20]: ------------------
[13:40:20]: --- Step: sigh ---
[13:40:20]: ------------------

+-------------------------------------+---------------------------------------+
|                           Summary for sigh 1.3.1                            |
+-------------------------------------+---------------------------------------+
| adhoc                               | false                                 |
| skip_install                        | false                                 |
| development                         | false                                 |
| force                               | false                                 |
| app_identifier                      | myappidentifier |
| username                            | foo@foo.com                    |
| team_id                             | MyTeamId                            |
| ignore_profiles_with_different_name | false                                 |
| cert_id                             | MyCertId                            |
| skip_fetch_profiles                 | false                                 |
| skip_certificate_verification       | false                                 |
+-------------------------------------+---------------------------------------+

[13:40:20]: Starting login with user 'foo@foo.com'
[13:40:22]: Successfully logged in
[13:40:22]: Fetching profiles...
[13:40:27]: Found 1 matching profile(s)
[13:40:27]: Downloading provisioning profile...
[13:40:28]: Successfully downloaded provisioning profile...
[13:40:28]: Installing provisioning profile...
/Users/sds/Projects/Internal/Fastlane TestApp/InHouse_foo.mobileprovision
[13:40:28]: Setting Provisioning Profile type to 'enterprise'
[13:40:28]: -----------------
[13:40:28]: --- Step: gym ---
.....

How can we find the cause of this error? I'm using Fastlane 1.57.0.

steffendsommer commented 8 years ago

Testing on another lane that uploads to TestFlight I'm also experiencing some issues which I weren't yesterday. My lane:

    match(type: "appstore")

    # Build and archive the app.
    gym(
      scheme: "Fastlane TestApp",
      clean: true,
      use_legacy_build_api: true
    )

    # # Upload app to TestFlight
    pilot

While uploading to iTunes Connect, it will break and throw errors like:

ERROR ITMS-90161: "Invalid Provisioning Profile. The provisioning profile included in the bundle myappidentifier [Payload/Fastlane TestApp.app] is invalid. [Missing code-signing certificate]. A Distribution Provisioning profile should be used when submitting apps to the App Store. For more information, visit the iOS Developer Portal."
steffendsommer commented 8 years ago

Adding more mystery to this issue: Today when I came to work, I tried running the Crashlytics lane again and now it worked without having made any changes to the Fastfile or anything else for that matter, except that I made a small change to the DEBUG_INFORMATION_FORMAT flag in my Xcode project. I made two builds which worked perfectly, then I wanted to see if the flag I changed triggered the error, so I switched it back. Then the error occurred again (as described earlier) however, when changing the flag once again, it continued not to work.

TLDR: This is really confusing and even though I make clean builds, tried deleting derived data, it's like it continues to make archives using the wrong profile.

steffendsommer commented 8 years ago

Another clue that might be relevant.. Can it have anything to with me having two teams with the same name? As my log says:

[13:40:18]: Certificate SomeOtherCertId (Company ApS) can't be found on your local computer
[13:40:20]: Found the certificate MyCertId (Company ApS) which is installed on the local machine. Using this one.

It's two different certificates from two different teams, but both have the same name, (e.g. Company ApS). I know that this has caused some problems for Xcode in the past. However the Fastlane output looks correct, it's just the ipa I get that's wrong.

steffendsommer commented 8 years ago

I have now managed to fix this issue. The issue was me being unaware of the provisioning profile in the Xcode project being set to Automatic. This lead to some inconsistency between what Fastlane was trying to do and the final IPA file. Is there a way for Fastlane to catch these issues? Put in another way, would it be possible to let Fastlane guarantee that the chosen certificates/profiles will match the resulting IPA? And if not, let Fastlane fail the archive process.

Anyways, feel free to close this issue 👍

KrauseFx commented 8 years ago

Cool, thanks for letting me know @s0mmer :+1:

KrauseFx commented 8 years ago

It's hard to catch those issues automatically, as every project is different

fastlanebot commented 8 years ago

This issue was migrated to https://github.com/fastlane/fastlane/issues/3143. Please post all further comments there.

fastlane is now a mono repo, you can read more about the change in our blog post. All tools are now available in the fastlane main repo :rocket: