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

[gym] fix in the gym/runner. When moving mac 'app' silently fails if file already exist in that location. #18529

Merged
merged 2 commits into from Apr 14, 2021

Conversation

krzysiek84
Copy link
Contributor

@krzysiek84 krzysiek84 commented Apr 9, 2021

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Motivation and Context

I've found a bug in the export of the mac app using developer-id. Looks like the app file generated by fastlane did not contain valid entitlements. After investigation, it looks like the exported app is the one from Xcode archive, and not the one from exporter tool.

Description

I've used the following config:

build_mac_app(
    workspace: 'Journal.xcworkspace',
    scheme: 'Diarly_Setapp',
    configuration: 'Release',
    export_options: {
      iCloudContainerEnvironment: 'Production',
      provisioningProfiles: specifiers
    },
    export_method: 'developer-id',
    output_directory: 'build/setapp',
  )

When I verified created App file with:

codesign -d --entitlements :entitlements.plist Diarly.app

I've noticed that the iCloudContainerEnvironment was not set correctly. After applying the fix (removing existing app file) everything worked ok.

What's interesting / off the topic, when I use skip-package option the export options are ignored (not sure if it's expected behavior). Was expecting even the app without package to be exported.

Testing Steps

I've used the following action to verify if the iCloudContainerEnvironment is set after export is done

module Fastlane
  module Actions

    class VerifyIcloudEnvironmentAction < Action
      def self.run(params)
        UI.message "Verifying if the app is set to correct icloud-container-environment"

        entitlements_path = "entitlements.plist"
        sh("codesign -d --entitlements :#{entitlements_path} #{params[:path]}")

        entitlements = File.open(entitlements_path) { |f| Plist.parse_xml(f) }

        value = entitlements['com.apple.developer.icloud-container-environment']
        if value != "Production"
          UI.abort_with_message! "iCloud container was not set to production!"
        end
      end


      def self.description
        "Verifies the app is using correct icloud-container-environment"
      end

      def self.available_options
        [
          FastlaneCore::ConfigItem.new(key: :path,
                                       description: "path to the .app file to verify",
                                       is_string: true),
        ]
      end

      def self.authors
        ["krzysztof"]
      end

      def self.is_supported?(platform)
        true
      end
    end
  end
end

@google-cla google-cla bot added the cla: yes label Apr 9, 2021
@joshdholtz joshdholtz changed the title Fix in the gym/runner. When moving mac 'app' silently fails if file already exist in that location. [gym] fix in the gym/runner. When moving mac 'app' silently fails if file already exist in that location. Apr 14, 2021
Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gaahhh, I can’t believe it wasn’t already doing this 😱 Thank you so much for catching this fix! Really appreciate the contribution ❤️

@joshdholtz joshdholtz merged commit e5c127f into fastlane:master Apr 14, 2021
@fastlane-bot
Copy link

Hey @krzysiek84 👋

Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a week, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀

@fastlane-bot
Copy link

Congratulations! 🎉 This was released as part of fastlane 2.181.0 🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants