2017-07-06 196 views

回答

1

所以基本上看起來像這樣。 訪問xcode項目,然後訪問pod並循環遍歷每個配置以設置適當的值。

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