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

Converting post_install hooks once generate_multiple_pod_projects is set to true #8739

Closed
Panajev opened this issue Apr 26, 2019 · 2 comments

Comments

@Panajev
Copy link

commented Apr 26, 2019

Request for Help

@sebastianv1 hello :), I have been trying to take advantage of the generate_multiple_pod_projects feature and although I have read the original pitch thread (hopefully well :)) and seen the hints in how to migrate current post install hooks, I am unable to put them in practice successfully:

This is the kind of hooks I am trying to run and convert to CocoaPods post the multiple pod projects flag:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['VALID_ARCHS'] = 'arm64'
      config.build_settings['VALID_ARCHS[sdk=iphonesimulator*]'] = 'x86_64'
      if "#{target.name}" == "XMPPFramework" || "#{target.name}" == "FBSDKCoreKit" || "#{target.name}" == "Bolts" || "#{target.name}" == "Mantle" || "#{target.name}" == "Tune"
        config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = 'YES'
      end
    end
  end
end

In some cases, I have had to override the deployment target or the Swift version, but it is a variation of the changes above.

It would be really appreciated some help in converting that and maybe adding instructions to the README for 1.7.0. Thank you in advance!

@sebastianv1

This comment has been minimized.

Copy link
Collaborator

commented Apr 28, 2019

@Panajev For incremental_installation, we added some new properties to Pod#Installer that I would recommend using regardless of whether or not your project actually uses the incremental option.

    # @return [Array<Project>] The list of projects generated from the installation.
    #
    attr_reader :generated_projects

    # @return [Array<PodTarget>] The list of pod targets that were generated from the installation.
    #
    attr_reader :generated_pod_targets

    # @return [Array<AggregateTarget>] The list of aggregate targets that were generated from the installation.
    #
    attr_reader :generated_aggregate_targets

So for your post-install hook example, replacing installer.pods_project with installer.generated_projects should prevent any exceptions. It's also worth noting that due to the nature of incremental installation, the post install hook may not get applied to all of your targets as we only install the set of targets that have changed since the last installation. So when adding a new post install hook that you'd like to be applied to all targets in your project right away, you should pass the --clean-install flag to pod install or pod update.

@Panajev

This comment has been minimized.

Copy link
Author

commented Apr 29, 2019

Thank you @sebastianv1 , for completeness (still testing the results), this seems to be what I was looking for (no errors) based on your response:

install! 'cocoapods', :generate_multiple_pod_projects => true

[...]

post_install do |installer|
  installer.generated_projects.each do |project|
    project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['VALID_ARCHS'] = 'arm64'
        config.build_settings['VALID_ARCHS[sdk=iphonesimulator*]'] = 'x86_64'
        if "#{target.name}" == "XMPPFramework" || "#{target.name}" == "FBSDKCoreKit" || "#{target.name}" == "Bolts" || "#{target.name}" == "Mantle" || "#{target.name}" == "Tune"
          config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = 'YES'
        end
      end
    end
  end
end

@Panajev Panajev closed this Apr 29, 2019

@Panajev Panajev reopened this Apr 29, 2019

@Panajev Panajev closed this Apr 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.