Skip to content

Instantly share code, notes, and snippets.

@joncardasis
Last active September 21, 2016 14:16
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 joncardasis/2d63ef7d7da6bf0addafc0b9cb396f0c to your computer and use it in GitHub Desktop.
Save joncardasis/2d63ef7d7da6bf0addafc0b9cb396f0c to your computer and use it in GitHub Desktop.
Replace Xcode Build Settings for Mobile Provisioning using Xcodeproj
#!/usr/bin/ruby
#
# Usage:
# ./{program} {filepath} {provisioning profile}
# Example: ./{program} path/to/project/myapp.xcodeproj EB75C687-2F3E-4D57-B895-0F515DA178CC
#
require 'xcodeproj'
project_path = ARGV[0]
provisioning_id = ARGV[1]
# Replaces the provisioning profile id in the xcproject
# project : an Xcodeproj Project
# provisioning_id : a provisoning profile string name ex:'EB75C687-2F3E-4D57-B895-0F515DA178CC'
def replace_provisioning_profile(project, provisioning_id)
project.targets.each do |target|
next unless target.name == 'APP-TARGET-NA' || target.name == 'APP-TARGET-EU'
target.build_configurations.each do |configuration|
configuration.build_settings['PROVISIONING_PROFILE'] = provisioning_id
end
end
end
project = Xcodeproj::Project.open(project_path)
replace_provisioning_profile(project, provisioning_id)
# Save the project
project.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment