Cocoapods: Getting "undefined method `post_integrate!'" when running pod install

Created on 7 Apr 2020  Â·  5Comments  Â·  Source: CocoaPods/CocoaPods

Report

What did you do?

I installed the trunk version of Cocapods (9b9aff04f5942d0d895c35a7d4e51a4b33534830) and ran pod install in my existing project which works fine with 1.9.1

What did you expect to happen?

Expected to run through as before with 1.9.1

What happened instead?

[!] An error occurred while processing the post-integrate hook of the Podfile.

undefined method `post_integrate!' for #<Pod::Podfile:0x00007fe94e76d920>
Did you mean?  post_install!

/Users/rist/.gem/bundler/gems/CocoaPods-9b9aff04f594/lib/cocoapods/installer.rb:903:in `run_podfile_post_integrate_hook'
/Users/rist/.gem/bundler/gems/CocoaPods-9b9aff04f594/lib/cocoapods/installer.rb:891:in `block in run_podfile_post_integrate_hooks'
/Users/rist/.gem/bundler/gems/CocoaPods-9b9aff04f594/lib/cocoapods/user_interface.rb:145:in `message'
/Users/rist/.gem/bundler/gems/CocoaPods-9b9aff04f594/lib/cocoapods/installer.rb:890:in `run_podfile_post_integrate_hooks'
/Users/rist/.gem/bundler/gems/CocoaPods-9b9aff04f594/lib/cocoapods/installer.rb:819:in `block in integrate_user_project'
/Users/rist/.gem/bundler/gems/CocoaPods-9b9aff04f594/lib/cocoapods/user_interface.rb:64:in `section'
/Users/rist/.gem/bundler/gems/CocoaPods-9b9aff04f594/lib/cocoapods/installer.rb:814:in `integrate_user_project'
/Users/rist/.gem/bundler/gems/CocoaPods-9b9aff04f594/lib/cocoapods/installer.rb:178:in `integrate'
/Users/rist/.gem/bundler/gems/CocoaPods-9b9aff04f594/lib/cocoapods/installer.rb:164:in `install!'
/Users/rist/.gem/bundler/gems/CocoaPods-9b9aff04f594/lib/cocoapods/command/install.rb:52:in `run'
/Users/rist/.gem/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Users/rist/.gem/bundler/gems/CocoaPods-9b9aff04f594/lib/cocoapods/command.rb:52:in `run'
/Users/rist/.gem/bundler/gems/CocoaPods-9b9aff04f594/bin/pod:55:in `<top (required)>'
/Users/rist/.gem/bin/pod:23:in `load'
/Users/rist/.gem/bin/pod:23:in `<top (required)>'
/Users/rist/.gem/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/Users/rist/.gem/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/Users/rist/.gem/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/Users/rist/.gem/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/Users/rist/.gem/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/rist/.gem/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/rist/.gem/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/Users/rist/.gem/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/Users/rist/.gem/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/Users/rist/.gem/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/Users/rist/.gem/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/Users/rist/.gem/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/Users/rist/.gem/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/Users/rist/.gem/bin/bundle:23:in `load'


## CocoaPods Environment


### Stack

CocoaPods : 1.9.1
Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
RubyGems : 3.0.3
Host : Mac OS X 10.15.4 (19E266)
Xcode : 11.3.1 (11C505)
Git : git version 2.21.1 (Apple Git-122.3)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : beeone-cocoa-pods-specs - git - [email protected]:kyc/cocoa-pods-specs.git @ b45dce35191245651fc0f828662ee98c2fc5165d

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

           trunk - CDN - https://cdn.cocoapods.org/
### Installation Source

Executable Path: /Users/rist/.gem/bin/pod

### Plugins

claide-plugins : 0.9.2
cocoapods-deintegrate : 1.0.4
cocoapods-dependencies : 1.3.0
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.1.0
cocoapods-trunk : 1.4.1
cocoapods-try : 1.1.0
slather : 2.4.7

### Podfile

```ruby
require_relative "modules/modules.rb"

source 'https://cdn.cocoapods.org/'
source '[email protected]:kyc/cocoa-pods-specs.git'
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

platform :ios, '12.4'

use_frameworks!
inhibit_all_warnings!

install! 'cocoapods', 
#  :generate_multiple_pod_projects => true, 
#  :incremental_installation => true,
#  :share_schemes_for_development_pods => true

# Global variable where modules store R.swift
# specific data with resource bundle target as key,
# which is then processed by post-install script, which
# adds R.swift build phase to module's resource target.
$rswift = Hash.new

@devPods = []
def devPod(name, tests=["Tests"])
  pod "#{name}", 
    :path => "modules/#{name}", 
    :testspecs => tests, 
    :inhibit_warnings => false
  @devPods << name
end

project 'XXXXXXXXXXX XXXXXXXXXXX', 
  'Debug Apple Pay RO' => :debug,
  'Debug Apple Pay AT' => :debug

abstract_target 'Core' do
    target 'NotificationService'

    devPod 'NotificationSupport'

    abstract_target 'App' do
        target 'XXXXXXXXXXX XXXXXXXXXXX'

        target 'XXXXXXXXXXX XXXXXXXXXXX Internal' do
            pod 'AppCenter/Distribute'
            devPod 'DebugSupport'

            target 'XXXXXXXXXXX XXXXXXXXXXX Unit Tests' do
                inherit! :complete
                devPod 'TestSupport', []
            end
        end

        devPod 'Signing'
        devPod 'Cards'
        devPod 'Transactions'
        devPod 'XXXXXXXXXXXLogger', []
        devPod 'XXXXXXXXXXXAPI'
        devPod 'XXXXXXXXXXXUI'
        devPod 'Tracking'
        devPod 'Multibanking'
        devPod 'FXConverter'
        devPod 'XXXXXXXXXXXPro'
        devPod 'Securities'
        devPod 'XXXXXXXXXXXProducts'
        devPod 'XXXXXXXXXXXPromotions', []
        devPod 'Payments'
        devPod 'ATMBranchFinder'
        devPod 'Overview', []
        devPod 'Messenger', []
        devPod 'XXXXXXXXXXXPlugins'
        devPod 'ElectronicStorage'

        pod 'UICKeyChainStore', '~> 2.1'

        # own libraries
        pod 'KeenClient', :git => '[email protected]:BeeOne-Mobile/KeenClient-iOS.git', :tag => '3.7.0-baseURL'
        pod 'TrackingClient', :git => '[email protected]:BeeOne-Mobile/tracking-client-ios.git', :commit => '5df0dd6827ac97c8add4bc97e3fe9d1829f28218'

        # networking
        pod 'OpenSSL-Universal', '1.0.2.19'
        pod 'Alamofire', '5.0.5'

        # core
        pod 'AppCenter/Core', '~> 3.1.0'
        pod 'AppCenter/Crashes'

        pod 'DTTJailbreakDetection'

        # Locker SDK
        pod 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '20.13.0' 

        # KYC SDK
        pod 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '20.13.0'

        # UI
        pod 'UIImage-Resize', '~> 1.0'

        pod 'SwiftLint', '0.39.1'
        pod 'SwiftFormat/CLI', '0.44.6'
    end
end

pre_install do |installer|
    $rswift.each do |target,rswift|
        rswift[:output_files].each do |generate|
            file = generate.sub "../", "./"

            # make sure directory exists
            FileUtils.mkdir_p File.dirname(file)

            puts "Creating #{file}"
            FileUtils.touch file
        end
    end
end

post_install do |installer|
    installer.pods_project.build_configurations.each do |config|
        # silence xcode warning: https://github.com/CocoaPods/CocoaPods/issues/8494
        config.build_settings['CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED'] = "YES"
        config.build_settings['ENABLE_BITCODE'] = "NO"
    end

    installer.generated_projects.each do |project|
        project.targets.each do |podTarget|
            podTarget.build_configurations.each do |config|
                # silence xcode warning: https://github.com/CocoaPods/CocoaPods/issues/8494
                config.build_settings['CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED'] = "YES"
            end

            case podTarget.name when *@devPods
                puts "Setting -DINTERNALBUILD to development pod: " + podTarget.name
                podTarget.build_configurations.each do |podConfig|
                    # exclude every "Release" config
                    unless podConfig.name.include?("Release")
                        puts "- Config: " + podConfig.name
                        podConfig.build_settings["OTHER_SWIFT_FLAGS"] = "$(inherited) -DINTERNALBUILD -Xfrontend -warn-long-function-bodies=400 -Xfrontend -warn-long-expression-type-checking=250"
                    end
                end
            end

            # check if current pod target is a resource target
            # for a module that requires R.Swift
            # also see: modules.rb -> add_rswift, which prepares
            # all necessary infos in $rswift global variable
            rswift = $rswift[podTarget.name]
            resource_phase = podTarget.build_phases.find { |p|
                p.display_name == "Resources"
            }
            unless rswift.nil? || resource_phase.nil?
                phase = podTarget.new_shell_script_build_phase "R.swift"

                phase.shell_path = "/bin/sh"
                phase.shell_script = rswift[:script]

                # gather all resource-taret resources as input for R.Swift,
                # so it's only run when a resource changes
                phase.input_paths = resource_phase.files_references.map { |ref|
                    ref.real_path.to_s.partition("/modules")[2].prepend("../modules")
                }
                # ...or when the module's `R.generated.swift` file
                # is missing or changed.
                phase.output_paths = rswift[:output_files]
            end
        end
    end

    require 'fileutils'
    puts "copying acknowledgements.plist to settings bundle"
    FileUtils.cp_r('Pods/Target Support Files/Pods-Core-App-XXXXXXXXXXX XXXXXXXXXXX/Pods-Core-App-XXXXXXXXXXX XXXXXXXXXXX-acknowledgements.plist', 'XXXXXXXXXXX/Settings.bundle/Acknowledgements.plist', :remove_destination => true)

    # Copy XXXXXXXXXXX default file header template file into Pods.xcodeproject
    FileUtils.mkdir_p('Pods/Pods.xcodeproj/xcshareddata/')
    FileUtils.cp_r('XXXXXXXXXXX XXXXXXXXXXX.xcodeproj/xcshareddata/IDETemplateMacros.plist', 'Pods/Pods.xcodeproj/xcshareddata/IDETemplateMacros.plist',:remove_destination => true)
end

Most helpful comment

Do the same and add:

gem 'cocoapods-core', :git => 'https://github.com/CocoaPods/Core.git'

All 5 comments

Seems like a bug in the latest master branch that deals with adding post_integrate hook support.

Did you also upgrade cocoapods-core to latest master?

what I did was changing my Gemfile to:

gem 'cocoapods', :git => 'https://github.com/CocoaPods/CocoaPods.git'

and then running

bundle install

Do the same and add:

gem 'cocoapods-core', :git => 'https://github.com/CocoaPods/Core.git'

ok, after updating 'cocoapods-core' runs through pod install runs fine

thanks for this prompt help!

np!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sonu5 picture sonu5  Â·  3Comments

evermeer picture evermeer  Â·  3Comments

spencerkohan picture spencerkohan  Â·  3Comments

pronebird picture pronebird  Â·  3Comments

iosdev-republicofapps picture iosdev-republicofapps  Â·  3Comments