Skip to content
This repository has been archived by the owner on Oct 2, 2018. It is now read-only.

XCode 7: The generated archive is invalid #115

Closed
aloifolia opened this issue Oct 7, 2015 · 12 comments
Closed

XCode 7: The generated archive is invalid #115

aloifolia opened this issue Oct 7, 2015 · 12 comments
Labels

Comments

@aloifolia
Copy link

Is it possible to skip the validation of a generated archive? I use the following lane to archive and export my enterprise app:

 36 lane :beta do
 37     gym(
 38       clean: true,
 39       export_method: 'enterprise',
 40       scheme: 'Beta',
 41       output_directory: './build',
 42       output_name: 'MyApp-#{lane_context[SharedValues::BUILD_NUMBER]}'
 43     )
 44   end

The archive is generated but not exported to an .ipa file, probably because the verification fails:

[11:31:34]: Successfully stored the archive. You can find it in the Xcode Organizer.
[11:31:34]: The generated archive is invalid, this can have various reasons:
[11:31:34]: Usually it's caused by the `Skip Install` option in Xcode, set it to `NO`
[11:31:34]: For more information visit https://developer.apple.com/library/ios/technotes/tn2215/_index.html
[11:31:34]: Variable Dump:
[11:31:34]: {:DEFAULT_PLATFORM=>:ios, :PLATFORM_NAME=>:ios, :LANE_NAME=>"ios beta"}
[11:31:34]: Archive invalid

To give you some more information: The validation does not work in XCode, as well (even if I do not use fastlane but XCode's UI to generate the archive). However, if I click 'Export' in XCode and move the generated .ipa to my iPad it can be started without any problems. I don't know whether this is an XCode 7 bug. On the other hand, I am using a configuration that is a little bit confusing:
screen shot 2015-10-07 at 11 46 21
The Release should actually use a Distribution certificate. Since this does not seem to work (also have a look at the Apple forums) I chose the standard Developer certificate.

@johnkueh
Copy link

Hi @aloifolia did you find a solution to this? I am facing the same issue as well.

@KrauseFx
Copy link
Contributor

You could try using the use_legacy_build_api option 👍

@johnkueh
Copy link

@KrauseFx that worked beautifully thank you so much!

@KrauseFx
Copy link
Contributor

Yeah 👍

@aloifolia
Copy link
Author

This option does not work for me. I guess, the validation is still performed... So, back to the question: Can I disable it somehow?

If I use the following 3 lines to generate an IPA file I can install the app without any problems:

xcodebuild clean -workspace $project.xcworkspace -scheme Beta
xcodebuild archive -workspace $project.xcworkspace -scheme Beta -archivePath $project.xcarchive
xcodebuild -exportArchive -archivePath $project.xcarchive -exportPath build -exportFormat ipa -exportProvisioningProfile "$profile"

where $project is the project name and $profile is the corresponding enterprise provisioning profile for distribution.

@KrauseFx KrauseFx reopened this Oct 19, 2015
@adcooley
Copy link

Strangely, I had this problem, switched to legacy_build_api and that solved it, and now today I've got the problem again. My hope is that I made a change that broke code signing but interesting to see someone else having the issue

@adcooley
Copy link

@aloifolia think I've got a fix for you. @KrauseFx think I've got a bug for you :)

I changed three things from when it was working:

I was calling

cert(output_path: "./certs")
sigh(output_path: "./fastlane/profiles")

and dropped the output paths to just cert and sigh

...and I was specifying an output folder for the gym build , output_directory: './fastlane/build', and an archive_path: "./fastlane/build", both of which i dropped when successful testing just now.

I'm currently testing to determine which is the root cause (my builds take forever) but the fact that you're specifying a path for the build output makes me think that's the culprit.

@adcooley
Copy link

Alright, so removing the output_directory and archive_path cause the ipa creation to succeed again. In fact, just removing archive_path and keeping output_directory worked as well. For reference, I originally had:

    cert(output_path: "./certs")
    sigh(output_path: "./fastlane/profiles")
    ENV["PROFILE_UDID"] = lane_context[SharedValues::SIGH_UDID]

    gym(
      scheme: ENV['SCHEME'],
      configuration: ENV['CONFIGURATION'],
      codesigning_identity: ENV['IDENTITY'],
      output_directory: './fastlane/build',
      archive_path: './fastlane/build',
      use_legacy_build_api: true
    )

and it's fixed with:

    cert(output_path: "./certs")
    sigh(output_path: "./fastlane/profiles")
    ENV["PROFILE_UDID"] = lane_context[SharedValues::SIGH_UDID]

    gym(
      scheme: ENV['SCHEME'],
      configuration: ENV['CONFIGURATION'],
      codesigning_identity: ENV['IDENTITY'],
      use_legacy_build_api: true
    )

I see now that output_directory and archive_path were probably conflicting or something ( so maybe this doesn't solve your issue @aloifolia ) but honestly there are like 4 'output' related variables and it's kinda confusing

| * output_directory        | The directory in which the ipa file should be stored in (default: '.')
| output_name               | The name of the resulting ipa file                                    
| archive_path              | The directory in which the archive file should be stored in           
| destination               | Use a custom destination for building the app                         

I assumed they were all just specifying where the products of the build/archive would end up, and wouldn't affect the successful completion of the action.

@mrniket
Copy link

mrniket commented Oct 28, 2015

I fixed this by putting .xcarchive after my archive path so that my gym action looks like this:

gym(
    scheme: xcode_scheme,
    output_name: ipa_path,
    codesigning_identity: codesigning_identity,
    export_method: export_method,
    archive_path: "#{xcode_scheme}.xcarchive",
    include_bitcode: false,
    clean: true
)

Looking at the gym source code, the problem seems to be in runner.rb in the verify_archive method, the line with Dir[BuildCommandGenerator.archive_path + "/*"].count == 0 should probably be Dir[BuildCommandGenerator.archive_path + "/*"].count == 0 || Dir[BuildCommandGenerator.archive_path + ".xcarchive/*"].count == 0

@KrauseFx
Copy link
Contributor

Please update to the latest release and let me know if that works for you 👍

mrniket added a commit to mrniket/gym that referenced this issue Oct 29, 2015
@mrniket
Copy link

mrniket commented Oct 29, 2015

Unfortunately the latest release didn't work for me but I've submitted a pull request (#134) with a fix that does though :)

KrauseFx added a commit that referenced this issue Oct 29, 2015
Fix for issue #115, 'Generated archive is invalid'
@fastlanebot
Copy link

This issue was migrated to fastlane/fastlane#3179. 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 🚀

@fastlane-old fastlane-old locked and limited conversation to collaborators Mar 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants