Skip to content

Instantly share code, notes, and snippets.

@tomredman
Last active March 23, 2019 03:27
Show Gist options
  • Save tomredman/9769940 to your computer and use it in GitHub Desktop.
Save tomredman/9769940 to your computer and use it in GitHub Desktop.
Add file to specific Pods' Frameworks Build Phase using cocoapods' post_install

In a large, nested project where I prefer to control the workspace, I run pod install --no-integrate on my root project. However, some pods don't include their required static libs correctly within their target's framework build phases.

For example, Pod-TestFlightSDK's required libTestFlight.a is excluded and removed every time I update my pods. Which required me to manually update the Pod target each time to include the static lib, which required me to automate it:

post_install do |installer_representation|
    installer_representation.project.targets.each do |target|
        if target.name == 'Pods-TestFlightSDK'
            libFile = installer_representation.project.new_file('TestFlightSDK/libTestFlight.a')
        end
        
        if target.name == 'Pods-Brightcove-Player-SDK'
            libFile = installer_representation.project.new_file('Brightcove-Player-SDK/Library/libBCOVPlayerSDK.a')
        end
        
        unless libFile.nil?
            puts "     - Adding %s to %s Frameworks Build Phases" % [libFile, target.name]
            target.frameworks_build_phase.add_file_reference(libFile)
        end
    end
end
@jaysonjh
Copy link

I already fixed this. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment