Skip to content

Instantly share code, notes, and snippets.

@amleszk
Created October 3, 2014 16:08
Show Gist options
  • Select an option

  • Save amleszk/3ad63f5fd8b164fb1149 to your computer and use it in GitHub Desktop.

Select an option

Save amleszk/3ad63f5fd8b164fb1149 to your computer and use it in GitHub Desktop.

Revisions

  1. amleszk renamed this gist Oct 3, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. amleszk created this gist Oct 3, 2014.
    30 changes: 30 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    post_install do |installer|
    project = Xcodeproj::Project.open('MeetupApp.xcodeproj')
    config_mapping = {
    :Debug => 'Configuration/Debug.xcconfig'
    }
    set_xcconfig_reference(project,'MeetupApp','Debug','Configuration/Debug.xcconfig')
    end


    def set_xcconfig_reference(project, target_name, config_name, xcconfig_name)

    puts project.targets

    target = project.targets.find { |target|
    target.name == target_name
    }
    !target and abort("Post install - target: #{target_name} not found")

    puts target.build_configurations

    target_config = target.build_configurations.find { |config|
    config.name == config_name
    }
    !target_config and abort("Post install - target: #{target_name} config: #{config_name} not found")

    !File.exist?(xcconfig_name) and abort("Post install - File does not exist #{xcconfig_name}")

    config..base_configuration_reference = xcconfig_name
    puts "Overriding configuration setting: #{target_name}.#{config_name} = #{xcconfig_name}"
    end