access parent project OTHER_SWIFT_FLAGS from pod

Solutions Collect From Internet About “access parent project OTHER_SWIFT_FLAGS from pod”

So basically it looks like this.
Accessing the xcode project, then accessing the pod and looping through each config to set the proper value.

post_install do |installer|
require 'xcodeproj'
project_path = 'pathTo/myProj.xcodeproj' # path to your xcode project
project = Xcodeproj::Project.open(project_path)
project.targets.each do |target|
    if target.name == 'myTarget' # name of the target in your main project containing the custom flag
        installer.pods_project.targets.each do |podTarget|
            if podTarget.name == 'myPod' #name of your pod
                target.build_configurations.each do |targetConfig|
                    podTarget.build_configurations.each do |podConfig|
                        podConfig.build_settings["OTHER_SWIFT_FLAGS"] = targetConfig.build_settings["OTHER_SWIFT_FLAGS"]
                    end
                end

            end
        end
    end
end