Sha256: 35f5281c9d41d36ca7d989687142edf8a66e5cbe5c1b3821fcc5c08b0d85f783

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

module Depcheck
  module Finder

    def self.find_derived_data_path(project, workspace, scheme)
      arg = if project
              "-project \"#{project}\""
            else
              "-workspace \"#{workspace}\""
            end

      arg+= " -scheme \"#{scheme}\"" if scheme

      build_settings = `xcodebuild #{arg} -showBuildSettings build CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO`
      raise StandardError until $?.success?

      derived_data_path = build_settings.match(/ OBJROOT = (.+)/)[1]
      project_name = build_settings.match(/ PROJECT_NAME = (.+)/)[1]
      target_name = build_settings.match(/ TARGET_NAME = (.+)/)[1]

      "#{derived_data_path}/#{project_name}.build/**/#{target_name}*.build"
    end

    def self.find_swiftdeps(project, workspace, scheme)
      derived_data_path = find_derived_data_path(project, workspace, scheme)
      swiftdeps = Dir.glob("#{derived_data_path}/**/*.swiftdeps") if derived_data_path

      if swiftdeps.nil? || swiftdeps.empty?
        raise StandardError, 'No derived data found. Please make sure the project was built.'
      end

      swiftdeps
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
depcheck-0.5.0 lib/depcheck/finder.rb