class PodBuilder::Configuration

Constants

DEFAULT_BUILD_SETTINGS

Remember to update README.md accordingly

DEFAULT_BUILD_SETTINGS_OVERRIDES
DEFAULT_BUILD_SYSTEM
DEFAULT_BUILD_USING_REPO_PATHS
DEFAULT_BUILD_XCFRAMEWORKS
DEFAULT_FORCE_PREBUILD_PODS
DEFAULT_LIBRARY_EVOLUTION_SUPPORT
DEFAULT_PLATFORMS
DEFAULT_SKIP_PODS
DEFAULT_SPEC_OVERRIDE

Attributes

allow_building_development_pods[RW]
base_path[RW]
build_base_path[RW]
build_path[RW]
build_settings[RW]
build_settings_overrides[RW]
build_system[RW]
build_using_repo_paths[RW]
build_xcframeworks[RW]
configuration_filename[RW]
deterministic_build[RW]
dev_pods_configuration_filename[RW]
development_pods_paths[RW]
force_prebuild_pods[RW]
library_evolution_support[RW]
license_filename[RW]
lldbinit_name[RW]
lockfile_name[RW]
lockfile_path[RW]
prebuilt_info_filename[RW]
project_name[RW]
react_native_project[RW]
restore_enabled[RW]
skip_licenses[RW]
skip_pods[RW]
spec_overrides[RW]
supported_platforms[RW]
use_bundler[RW]

Public Class Methods

check_inited() click to toggle source
# File lib/pod_builder/configuration.rb, line 119
def self.check_inited
  raise "\n\nNot inited, run `pod_builder init`\n".red if podbuilder_path.nil?
end
exists() click to toggle source
# File lib/pod_builder/configuration.rb, line 123
def self.exists
  return !config_path.nil? && File.exist?(config_path)
end
load() click to toggle source
# File lib/pod_builder/configuration.rb, line 127
def self.load
  unless podbuilder_path
    return
  end
  
  Configuration.base_path = podbuilder_path
  
  if exists
    begin
      json = JSON.parse(File.read(config_path))
    rescue => exception
      raise "\n\n#{File.basename(config_path)} is an invalid JSON\n".red
    end

    if value = json["spec_overrides"]
      if value.is_a?(Hash) && value.keys.count > 0
        Configuration.spec_overrides = value
      end
    end
    if value = json["skip_licenses"]
      if value.is_a?(Array)
        Configuration.skip_licenses = value
      end
    end
    if value = json["skip_pods"]
      if value.is_a?(Array)
        Configuration.skip_pods = value
      end
    end
    if value = json["force_prebuild_pods"]
      if value.is_a?(Array)
        Configuration.force_prebuild_pods = value
      end
    end
    if value = json["build_settings"]
      if value.is_a?(Hash) && value.keys.count > 0
        Configuration.build_settings = value
      end
    end
    if value = json["build_settings_overrides"]
      if value.is_a?(Hash) && value.keys.count > 0
        Configuration.build_settings_overrides = value
      end
    end
    if value = json["build_system"]
      if value.is_a?(String) && ["Latest", "Legacy"].include?(value)
        Configuration.build_system = value
      end
    end
    if value = json["library_evolution_support"]
      if [TrueClass, FalseClass].include?(value.class)
        Configuration.library_evolution_support = value
      end
    end
    if value = json["license_filename"]
      if value.is_a?(String) && value.length > 0
        Configuration.license_filename = value
      end
    end
    if value = json["project_name"]
      if value.is_a?(String) && value.length > 0
        Configuration.project_name = value
      end
    end
    if value = json["restore_enabled"]
      if [TrueClass, FalseClass].include?(value.class)
        Configuration.restore_enabled = value
      end
    end
    if value = json["allow_building_development_pods"]
      if [TrueClass, FalseClass].include?(value.class)
        Configuration.allow_building_development_pods = value
      end
    end
    if value = json["use_bundler"]
      if [TrueClass, FalseClass].include?(value.class)
        Configuration.use_bundler = value
      end
    end
    if value = json["deterministic_build"]
      if [TrueClass, FalseClass].include?(value.class)
        Configuration.deterministic_build = value
      end
    end
    if value = json["build_using_repo_paths"]
      if [TrueClass, FalseClass].include?(value.class)
        Configuration.build_using_repo_paths = value
      end
    end
    if value = json["react_native_project"]
      if [TrueClass, FalseClass].include?(value.class)
        Configuration.react_native_project = value
      end
    end
    if value = json["build_xcframeworks"]
      if [TrueClass, FalseClass].include?(value.class)
        Configuration.build_xcframeworks = value
      end
    end
    
    Configuration.build_settings.freeze

    sanity_check()
  end
  
  dev_pods_configuration_path = File.join(Configuration.base_path, Configuration.dev_pods_configuration_filename)
  
  if File.exist?(dev_pods_configuration_path)
    begin
      json = JSON.parse(File.read(dev_pods_configuration_path))  
    rescue => exception
      raise "\n\n#{File.basename(dev_pods_configuration_path)} is an invalid JSON\n".red
    end

    Configuration.development_pods_paths = json || []
    Configuration.development_pods_paths.freeze
  end

  if !deterministic_build
    build_path = "#{build_base_path}#{(Time.now.to_f * 1000).to_i}"
    lockfile_path = File.join(PodBuilder::home, lockfile_name)
  end
end
write() click to toggle source
# File lib/pod_builder/configuration.rb, line 251
def self.write
  config = {}
  
  config["project_name"] = Configuration.project_name
  config["spec_overrides"] = Configuration.spec_overrides
  config["skip_licenses"] = Configuration.skip_licenses
  config["skip_pods"] = Configuration.skip_pods
  config["force_prebuild_pods"] = Configuration.force_prebuild_pods
  config["build_settings"] = Configuration.build_settings
  config["build_settings_overrides"] = Configuration.build_settings_overrides
  config["build_system"] = Configuration.build_system
  config["library_evolution_support"] = Configuration.library_evolution_support
  config["license_filename"] = Configuration.license_filename
  config["restore_enabled"] = Configuration.restore_enabled
  config["allow_building_development_pods"] = Configuration.allow_building_development_pods
  config["use_bundler"] = Configuration.use_bundler
  config["deterministic_build"] = Configuration.deterministic_build
  config["build_using_repo_paths"] = Configuration.build_using_repo_paths
  config["react_native_project"] = Configuration.react_native_project
  
  File.write(config_path, JSON.pretty_generate(config))
end

Private Class Methods

config_path() click to toggle source
# File lib/pod_builder/configuration.rb, line 284
def self.config_path
  unless path = podbuilder_path
    return nil
  end
  
  return File.join(path, Configuration.configuration_filename)
end
podbuilder_path() click to toggle source
# File lib/pod_builder/configuration.rb, line 292
def self.podbuilder_path
  paths = Dir.glob("#{PodBuilder::home}/**/.pod_builder")
  paths.reject! { |t| t.match(/pod-builder-.*\/Example\/#{File.basename(Configuration.base_path)}\/\.pod_builder$/i) }
  raise "\n\nToo many .pod_builder found `#{paths.join("\n")}`\n".red if paths.count > 1
  
  return paths.count > 0 ? File.dirname(paths.first) : nil
end
sanity_check() click to toggle source
# File lib/pod_builder/configuration.rb, line 276
def self.sanity_check
  Configuration.skip_pods.each do |pod|
    if Configuration.force_prebuild_pods.include?(pod)
      puts "PodBuilder.json contains '#{pod}' both in `force_prebuild_pods` and `skip_pods`. Will force prebuilding.".yellow
    end
  end
end