The question is: the CocoaPods generates the xcconfig
file for my project and I want to include my xcconfig
file as a dependency into it. Am I able to do in for example in post_install
hook?
I've only found that the XCBuildConfiguration has build_settings
hash, but as far as I understood I can add or change only keys and not include statements with that hash.
Asked
Active
Viewed 696 times
0

Antondomashnev
- 51
- 6
1 Answers
0
Following the instructions from this answer I was able to update xcconfig
and I use this code to include my xcconfig
file into pod's generated:
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

Community
- 1
- 1

Antondomashnev
- 51
- 6