{"record":{"id":"1d2d1a0cea12cbd1","repo":"CocoaPods/CocoaPods","slug":"an-error-occurred-while-processing-the-pre-integra","errorCode":null,"errorMessage":"An error occurred while processing the pre-integrate hook of the Podfile.\n\n#{e.message}\n\n#{e.backtrace * \"\\n\"}","messagePattern":"An error occurred while processing the pre-integrate hook of the Podfile\\.\n\n#(.+?)\n\n#(.+?)","errorType":"exception","errorClass":"Pod::Informative","httpStatus":null,"severity":"error","filePath":"lib/cocoapods/installer.rb","lineNumber":987,"sourceCode":"    # @return [void]\n    #\n    def run_podfile_pre_integrate_hooks\n      UI.message '- Running pre integrate hooks' do\n        executed = run_podfile_pre_integrate_hook\n        UI.message '- Podfile' if executed\n      end\n    end\n\n    # Runs the pre integrate hook of the Podfile.\n    #\n    # @raise  Raises an informative if the hooks raises.\n    #\n    # @return [Boolean] Whether the hook was run.\n    #\n    def run_podfile_pre_integrate_hook\n      podfile.pre_integrate!(self)\n    rescue => e\n      raise Informative, 'An error occurred while processing the pre-integrate ' \\\n        'hook of the Podfile.' \\\n        \"\\n\\n#{e.message}\\n\\n#{e.backtrace * \"\\n\"}\"\n    end\n\n    # Runs the post install hooks of the installed specs and of the Podfile.\n    #\n    # @note   Post install hooks run _before_ saving of project, so that they\n    #         can alter it before it is written to the disk.\n    #\n    # @return [void]\n    #\n    def run_podfile_post_install_hooks\n      UI.message '- Running post install hooks' do\n        executed = run_podfile_post_install_hook\n        UI.message '- Podfile' if executed\n      end\n    end\n","sourceCodeStart":969,"sourceCodeEnd":1005,"githubUrl":"https://github.com/CocoaPods/CocoaPods/blob/b80e113e28a7e23cd6dbc169f0c923f6b48bf7a2/lib/cocoapods/installer.rb#L969-L1005","documentation":"Installer#run_podfile_pre_integrate_hook invokes the Podfile's `pre_integrate do |installer| ... end` block (runs before the Pods project is generated) and rescues any exception, re-raising as Informative with the original message and full backtrace appended. The hook name in the header is the only difference from the other hook wrappers; diagnosis is identical.","triggerScenarios":"Any exception raised by Ruby inside `pre_integrate do |installer| ... end`: nil dereferences on installer state that is not yet populated at pre-integrate time, undefined methods, or version-drifted CocoaPods APIs.","commonSituations":"Hooks assuming pods_project/targets exist before project generation; hooks written for older CocoaPods after an upgrade; shared Podfile templates where the hook expects targets a project doesn't have.","solutions":["Locate the failing line via the embedded backtrace frame inside the Podfile and fix the Ruby error.","At pre-integrate time, prefer analyzer results (`installer.analysis_result`) over project objects that may not exist yet.","Comment the block out to confirm the install proceeds, then restore incrementally.","Pin the CocoaPods version your hooks were written against (Gemfile + `bundle exec pod install`) until the hook is ported."],"exampleFix":"# before (Podfile)\npre_integrate do |installer|\n  puts installer.aggregate_targets.map(&:name).upcase  # NoMethodError: Array has no upcase\nend\n# after\npre_integrate do |installer|\n  puts installer.aggregate_targets.map(&:name).map(&:upcase).inspect\nend","handlingStrategy":"try-catch","validationCode":"# Syntax-check the Podfile before CI install\nsystem('ruby -c Podfile') or abort 'Podfile has a Ruby syntax error'","typeGuard":null,"tryCatchPattern":"pre_integrate do |installer|\n  begin\n    # ... hook logic ...\n  rescue NoMethodError => e\n    Pod::UI.warn \"pre_integrate: API misuse #{e.message} — check CocoaPods #{Pod::VERSION}\"\n    raise\n  end\nend","preventionTips":["At pre-integrate time, rely on `installer.analysis_result` rather than assuming the Pods project is fully materialized.","Write hooks defensively: check collections are non-empty before mapping.","Version-pin CocoaPods on CI and locally so hook behavior is reproducible."],"tags":["cocoapods","podfile","ruby","hooks","pre-integrate"],"backgroundTag":"lifecycle-hook-error","analyzedSha":"b80e113e28a7e23cd6dbc169f0c923f6b48bf7a2","analyzedAt":"2026-08-21T15:07:28.652Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}