2016-09-01 10 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 
関連する問題