class BDAwesomeTransmit::BDPodsTrans

Public Class Methods

install(argv) click to toggle source
# File lib/BDTransmit, line 6
def self.install(argv)
  @@project = Xcodeproj::Project.open("Pods/Pods.xcodeproj")
  self.saveOriginXcconfig
  self.generatorAwesomePodsContainer(argv)
  @@project.targets.each do |target|
    targetName = target.name
    if target.name.include?"-"
      targetName = target.name.split("-")[0]
    end
    case0 = argv.include?(targetName) && self.isAnAwesomePods(targetName)
    case1 = argv.include?(target.name) && self.isAnAwesomePods(target.name)
    if case0 || case1
      self.save_file_setting(target)
      files = Array.new()
      unless target.class == Xcodeproj::Project::Object::PBXAggregateTarget
        target.source_build_phase.files.each do |pbx_build_file|
          if pbx_build_file.display_name != "#{target.name}-dummy.m"
            files << pbx_build_file
          end
        end
        files.each do |file|
          target.source_build_phase.remove_build_file(file)
        end
      end
      
    end
  end
  @@project.save
end

Private Class Methods

findxcconfig() click to toggle source
# File lib/BDTransmit, line 136
def self.findxcconfig
  @@project_path = "Pods/Target Support Files"
  allConfigFiles = Array.new
  Dir::foreach(@@project_path) { |file|
    if file.include?("Pods-")
      Dir::foreach("#{@@project_path}/#{file}") { |config|
        if config.include?(".xcconfig")
          allConfigFiles << "#{@@project_path}/#{file}/#{config}"
        end
      }
    end
  }
  return allConfigFiles
end
generatorAwesomePodsContainer(argv) click to toggle source
# File lib/BDTransmit, line 38
def self.generatorAwesomePodsContainer(argv)
  temp = Array.new
  self.findxcconfig.each do |xcconfigPath|
    if xcconfigPath.include?(".origin")
      config = Xcodeproj::Config.new(xcconfigPath)
      config.libraries.each do |lib|
        if lib.include?("_awesome_")
          temp << lib.split(pattern='_')[0]
        end
      end
    end
  end
  @@awesomePods = temp.uniq
end
isAnAwesomePods(podName) click to toggle source
# File lib/BDTransmit, line 53
def self.isAnAwesomePods(podName)
  return @@awesomePods.include?(podName)
end
removeSourceLinkerIfNeeded(podName,xcconfigPath) click to toggle source
# File lib/BDTransmit, line 67
def self.removeSourceLinkerIfNeeded(podName,xcconfigPath)
  config = Xcodeproj::Config.new(xcconfigPath)
  removeLinkers = Array.new
  config.libraries.each do |lib|
    if lib.include?("#{podName}") && lib.include?("_awesome_")
      removeLinkers << lib
    end
  end
  if removeLinkers.count != 0
    config.other_linker_flags[:libraries] = config.libraries.delete(podName)
    pn = Pathname.new(xcconfigPath)
    config.save_as(pn)
  end
end
saveOriginXcconfig() click to toggle source
# File lib/BDTransmit, line 57
def self.saveOriginXcconfig
  self.findxcconfig.each do |xcconfigPath|
    if !xcconfigPath.include?(".xcconfig.")
      config = Xcodeproj::Config.new(xcconfigPath)
      pn = Pathname.new("#{xcconfigPath}.origin")
      config.save_as(pn)
    end
  end
end
save_file_setting(target) click to toggle source
# File lib/BDTransmit, line 82
def self.save_file_setting(target)
  @@project_path = "Pods/Target Support Files"
  targetName = target.name
  target.build_configurations.each do |config|
    if config.name == "Debug"
      arc = config.build_settings['CLANG_ENABLE_OBJC_ARC']
      if arc == "NO"
        if File::exist?("#{@@project_path}/#{targetName}")
          aFile = File.new("#{@@project_path}/#{targetName}/config.json", "w")
          config = Hash.new;
          files = Array.new();
          unless target.class == Xcodeproj::Project::Object::PBXAggregateTarget
            target.source_build_phase.files.each do |pbx_build_file|
              files << pbx_build_file.display_name
            end
            config["xcconfig"] = 'true';
            config["usedFiles"] = files;
            aFile.syswrite(config.to_json);
            aFile.close
          end

        end
      else
        if File::exist?("#{@@project_path}/#{targetName}")
          aFile = File.new("#{@@project_path}/#{targetName}/config.json", "w")
          config = Hash.new;
          config["xcconfig"] = 'false';
          files = Array.new();
          usedFiles = Array.new();
          unless target.class == Xcodeproj::Project::Object::PBXAggregateTarget
            target.source_build_phase.files.each do |pbx_build_file|
              usedFiles << pbx_build_file.display_name;
              if pbx_build_file.settings
                origin = pbx_build_file.settings["COMPILER_FLAGS"];
                if origin.include?('-fno-objc-arc')
                  files << pbx_build_file.display_name
                end
              end
            end
            config["no-arc"] = files;
            config["usedFiles"] = usedFiles;
            aFile.syswrite(config.to_json);
            aFile.close
          end


        end

      end

    end
  end
end