2016-09-01 3 views
0

질문 : CocoaPods가 내 프로젝트에 xcconfig 파일을 생성하고 이에 대한 종속성으로 xcconfig 파일을 포함하고자합니다. 예를 들어 post_install 후크에서 할 수 있습니까? XCBuildConfiguration에 build_settings 해시가 있음을 알게되었지만 키를 추가하거나 변경할 수 있고 해당 해시가있는 명령문을 포함 할 수는 없습니다.CocoaPods에서 생성 된 xcconfig에 포함시킬 수 있습니까?

답변

0

this answer의 지시에 따라 나는 xcconfig를 업데이트 할 수 있었고, 난 생성 된 포드의로 내 xcconfig 파일을 포함하려면이 코드를 사용

post_install do |installer| 
     installer.pods_project.targets.each do |target| 
     next unless target.name.include?("Pods-CNISDK") 
     puts "Updating #{target.name}" 
     target.build_configurations.each do |config| 
      xcconfig_path = config.base_configuration_reference.real_path 
      # read from xcconfig to build_settings dictionary 
      build_settings = Hash[*File.read(xcconfig_path).lines.map{|x| x.split(/\s*=\s*/, 2)}.flatten] 
      # write build_settings dictionary to xcconfig 
      File.open(xcconfig_path, "w") do |file| 
      file.puts "#include \"../configurations/Warnings.xcconfig\"\n" 
      build_settings.each do |key,value| 
       file.puts "#{key} = #{value}" 
      end 
      end 
     end 
     end 
    end 
관련 문제