Skip to content

Instantly share code, notes, and snippets.

@yonat
Last active March 16, 2022 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yonat/2d0194220e02a44f0b8b4202994d8921 to your computer and use it in GitHub Desktop.
Save yonat/2d0194220e02a44f0b8b4202994d8921 to your computer and use it in GitHub Desktop.
Change any Xcode build setting in fastlane
desc "Change a value in xcodeproj file."
desc "Usage: fastlane change_build_value xcodeproj:<file-name> name:<build-setting> from:<old-value> to:<new-value>"
lane :change_build_value do |options|
xcodeproj = options[:xcodeproj]
name = options[:name]
from = options[:from]
to = options[:to]
optional_quotes = '"\\{0,1\\}'
replacement_expression = "s/#{name} = #{optional_quotes}#{from}#{optional_quotes};/#{name} = #{to};/g"
sh("sed -i '' '#{replacement_expression}' ../#{xcodeproj}/project.pbxproj")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment