Module: Xcode Deprecated

Defined in:
lib/spm_version_updates/xcode.rb

Overview

Deprecated.

Use XcodeProjectPackageReader and XcodeParser from the spm_version_updates core gem instead. This shim exists only for backward compatibility with Dangerfiles written against v0.2.0.

Legacy Xcode project parser used by the Danger plugin API.

Constant Summary collapse

XcodeprojPathMustBeSet =

Raised when Danger plugin Xcode mode is invoked without a project path. Aliased to the core parser’s class so plugin callers rescuing the legacy name keep working now that the plugin delegates to SpmChecker/XcodeParser.

XcodeParser::XcodeprojPathMustBeSet
CouldNotFindResolvedFile =

Raised when a Danger plugin Xcode project has no Package.resolved file.

XcodeParser::CouldNotFindResolvedFile

Class Method Summary collapse

Class Method Details

.get_packages(xcodeproj_path) ⇒ Hash<String, Hash>

Find the configured SPM dependencies in the xcodeproj

Parameters:

  • xcodeproj_path (String)

    The path of the Xcode project

Returns:

  • (Hash<String, Hash>)

Raises:



17
18
19
20
21
22
23
24
# File 'lib/spm_version_updates/xcode.rb', line 17

def self.get_packages(xcodeproj_path)
  raise(XcodeprojPathMustBeSet) if xcodeproj_path.nil? || xcodeproj_path.empty?

  XcodeProjectPackageReader.package_references(xcodeproj_path).to_h { |package|
    repository_url = package.repository_url
    [Git.trim_repo_url(repository_url), package.requirement]
  }
end

.get_resolved_versions(xcodeproj_path) ⇒ Hash<String, String>

Extracts resolved versions from Package.resolved relative to an Xcode project. When a block is given, malformed resolved files are reported to it as ‘(resolved_path, error)` and skipped; without a block the error is raised.

Parameters:

  • xcodeproj_path (String)

    The path to your Xcode project

Returns:

  • (Hash<String, String>)

Raises:

  • (CouldNotFindResolvedFile)

    if no Package.resolved files were found

  • (PackageResolved::MalformedFileError)

    if a resolved file is invalid JSON and no block is given



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/spm_version_updates/xcode.rb', line 34

def self.get_resolved_versions(xcodeproj_path)
  resolved_paths = find_packages_resolved_file(xcodeproj_path)
  raise(CouldNotFindResolvedFile) if resolved_paths.empty?

  resolved_paths.each_with_object({}) { |resolved_path, pins|
    begin
      pins.merge!(PackageResolved.versions_from(resolved_path))
    rescue PackageResolved::MalformedFileError => error
      raise unless block_given?

      yield(resolved_path, error)
    end
  }
end