Skip to content

Commit

Permalink
fix(CocoaPods): Parse external sources from lock files
Browse files Browse the repository at this point in the history
External sources can refer to unpublished packages for which `pod spec
which` would fail like

    Unable to find a pod with name matching `^MLHudAlert$'

as no metadata could be retrieved. Support this case by getting as much
metadata as possible for such packages from the lock file itself.

The added test is based on the files from [1], commit 8c0c913.

[1]: https://github.com/youusername/magnetX

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Sep 22, 2023
1 parent a2fa752 commit 4bbd26a
Show file tree
Hide file tree
Showing 5 changed files with 397 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
---
project:
id: "CocoaPods::src/funTest/assets/projects/synthetic/external-sources/Podfile:"
definition_file_path: "plugins/package-managers/cocoapods/src/funTest/assets/projects/synthetic/external-sources/Podfile"
declared_licenses: []
declared_licenses_processed: {}
vcs:
type: ""
url: ""
revision: ""
path: ""
vcs_processed:
type: "Git"
url: "<REPLACE_URL_PROCESSED>"
revision: "<REPLACE_REVISION>"
path: "<REPLACE_PATH>"
homepage_url: ""
scopes:
- name: "dependencies"
dependencies:
- id: "Pod::AFNetworking:3.2.1"
dependencies:
- id: "Pod::AFNetworking/NSURLSession:3.2.1"
dependencies:
- id: "Pod::AFNetworking/Reachability:3.2.1"
- id: "Pod::AFNetworking/Security:3.2.1"
- id: "Pod::AFNetworking/Serialization:3.2.1"
- id: "Pod::AFNetworking/Reachability:3.2.1"
- id: "Pod::AFNetworking/Security:3.2.1"
- id: "Pod::AFNetworking/Serialization:3.2.1"
- id: "Pod::AFNetworking/UIKit:3.2.1"
- id: "Pod::CocoaSecurity:1.2.4"
- id: "Pod::MLHudAlert:0.0.4-3f23fa41632f8935fed028b04335576633ec53a2"
- id: "Pod::Ono:2.1.1"
packages:
- id: "Pod::AFNetworking:3.2.1"
purl: "pkg:cocoapods/[email protected]"
declared_licenses:
- "MIT"
declared_licenses_processed:
spdx_expression: "MIT"
description: "A delightful iOS and OS X networking framework."
homepage_url: "https://github.com/AFNetworking/AFNetworking"
binary_artifact:
url: ""
hash:
value: ""
algorithm: ""
source_artifact:
url: ""
hash:
value: ""
algorithm: ""
vcs:
type: "Git"
url: "https://github.com/AFNetworking/AFNetworking.git"
revision: "3.2.1"
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/AFNetworking/AFNetworking.git"
revision: "3.2.1"
path: ""
- id: "Pod::AFNetworking/NSURLSession:3.2.1"
purl: "pkg:cocoapods/AFNetworking%[email protected]"
declared_licenses:
- "MIT"
declared_licenses_processed:
spdx_expression: "MIT"
description: "A delightful iOS and OS X networking framework."
homepage_url: "https://github.com/AFNetworking/AFNetworking"
binary_artifact:
url: ""
hash:
value: ""
algorithm: ""
source_artifact:
url: ""
hash:
value: ""
algorithm: ""
vcs:
type: "Git"
url: "https://github.com/AFNetworking/AFNetworking.git"
revision: "3.2.1"
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/AFNetworking/AFNetworking.git"
revision: "3.2.1"
path: ""
- id: "Pod::AFNetworking/Reachability:3.2.1"
purl: "pkg:cocoapods/AFNetworking%[email protected]"
declared_licenses:
- "MIT"
declared_licenses_processed:
spdx_expression: "MIT"
description: "A delightful iOS and OS X networking framework."
homepage_url: "https://github.com/AFNetworking/AFNetworking"
binary_artifact:
url: ""
hash:
value: ""
algorithm: ""
source_artifact:
url: ""
hash:
value: ""
algorithm: ""
vcs:
type: "Git"
url: "https://github.com/AFNetworking/AFNetworking.git"
revision: "3.2.1"
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/AFNetworking/AFNetworking.git"
revision: "3.2.1"
path: ""
- id: "Pod::AFNetworking/Security:3.2.1"
purl: "pkg:cocoapods/AFNetworking%[email protected]"
declared_licenses:
- "MIT"
declared_licenses_processed:
spdx_expression: "MIT"
description: "A delightful iOS and OS X networking framework."
homepage_url: "https://github.com/AFNetworking/AFNetworking"
binary_artifact:
url: ""
hash:
value: ""
algorithm: ""
source_artifact:
url: ""
hash:
value: ""
algorithm: ""
vcs:
type: "Git"
url: "https://github.com/AFNetworking/AFNetworking.git"
revision: "3.2.1"
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/AFNetworking/AFNetworking.git"
revision: "3.2.1"
path: ""
- id: "Pod::AFNetworking/Serialization:3.2.1"
purl: "pkg:cocoapods/AFNetworking%[email protected]"
declared_licenses:
- "MIT"
declared_licenses_processed:
spdx_expression: "MIT"
description: "A delightful iOS and OS X networking framework."
homepage_url: "https://github.com/AFNetworking/AFNetworking"
binary_artifact:
url: ""
hash:
value: ""
algorithm: ""
source_artifact:
url: ""
hash:
value: ""
algorithm: ""
vcs:
type: "Git"
url: "https://github.com/AFNetworking/AFNetworking.git"
revision: "3.2.1"
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/AFNetworking/AFNetworking.git"
revision: "3.2.1"
path: ""
- id: "Pod::AFNetworking/UIKit:3.2.1"
purl: "pkg:cocoapods/AFNetworking%[email protected]"
declared_licenses:
- "MIT"
declared_licenses_processed:
spdx_expression: "MIT"
description: "A delightful iOS and OS X networking framework."
homepage_url: "https://github.com/AFNetworking/AFNetworking"
binary_artifact:
url: ""
hash:
value: ""
algorithm: ""
source_artifact:
url: ""
hash:
value: ""
algorithm: ""
vcs:
type: "Git"
url: "https://github.com/AFNetworking/AFNetworking.git"
revision: "3.2.1"
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/AFNetworking/AFNetworking.git"
revision: "3.2.1"
path: ""
- id: "Pod::CocoaSecurity:1.2.4"
purl: "pkg:cocoapods/[email protected]"
declared_licenses:
- "MIT"
declared_licenses_processed:
spdx_expression: "MIT"
description: "Encrypt/Decrypt: AES. Hash: MD5, SHA(SHA1, SHA224, SHA256, SHA384,\
\ SHA512). Encode/Decode: Base64, Hex."
homepage_url: "https://github.com/kelp404/CocoaSecurity.git"
binary_artifact:
url: ""
hash:
value: ""
algorithm: ""
source_artifact:
url: ""
hash:
value: ""
algorithm: ""
vcs:
type: "Git"
url: "https://github.com/kelp404/CocoaSecurity.git"
revision: "1.2.4"
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/kelp404/CocoaSecurity.git"
revision: "1.2.4"
path: ""
- id: "Pod::MLHudAlert:0.0.4-3f23fa41632f8935fed028b04335576633ec53a2"
purl: "pkg:cocoapods/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
homepage_url: "https://github.com/MacLabs/MLHudAlert.git"
binary_artifact:
url: ""
hash:
value: ""
algorithm: ""
source_artifact:
url: ""
hash:
value: ""
algorithm: ""
vcs:
type: "Git"
url: "https://github.com/MacLabs/MLHudAlert.git"
revision: "3f23fa41632f8935fed028b04335576633ec53a2"
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/MacLabs/MLHudAlert.git"
revision: "3f23fa41632f8935fed028b04335576633ec53a2"
path: ""
- id: "Pod::Ono:2.1.1"
purl: "pkg:cocoapods/[email protected]"
declared_licenses:
- "MIT"
declared_licenses_processed:
spdx_expression: "MIT"
description: "A sensible way to deal with XML & HTML."
homepage_url: "https://github.com/mattt/Ono"
binary_artifact:
url: ""
hash:
value: ""
algorithm: ""
source_artifact:
url: ""
hash:
value: ""
algorithm: ""
vcs:
type: "Git"
url: "https://github.com/mattt/Ono.git"
revision: "2.1.1"
path: ""
vcs_processed:
type: "Git"
url: "https://github.com/mattt/Ono.git"
revision: "2.1.1"
path: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

target 'magnetX' do
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!

# Pods for magnetX
pod 'AFNetworking'
pod 'Ono'
pod 'CocoaSecurity'
#pod 'SSZipArchive'
pod 'MLHudAlert', git: 'https://github.com/MacLabs/MLHudAlert.git'
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
PODS:
- AFNetworking (3.2.1):
- AFNetworking/NSURLSession (= 3.2.1)
- AFNetworking/Reachability (= 3.2.1)
- AFNetworking/Security (= 3.2.1)
- AFNetworking/Serialization (= 3.2.1)
- AFNetworking/UIKit (= 3.2.1)
- AFNetworking/NSURLSession (3.2.1):
- AFNetworking/Reachability
- AFNetworking/Security
- AFNetworking/Serialization
- AFNetworking/Reachability (3.2.1)
- AFNetworking/Security (3.2.1)
- AFNetworking/Serialization (3.2.1)
- CocoaSecurity (1.2.4)
- MLHudAlert (0.0.4)
- Ono (2.1.1)

DEPENDENCIES:
- AFNetworking
- CocoaSecurity
- MLHudAlert (from `https://github.com/MacLabs/MLHudAlert.git`)
- Ono

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- AFNetworking
- CocoaSecurity
- Ono

EXTERNAL SOURCES:
MLHudAlert:
:git: https://github.com/MacLabs/MLHudAlert.git

CHECKOUT OPTIONS:
MLHudAlert:
:commit: 3f23fa41632f8935fed028b04335576633ec53a2
:git: https://github.com/MacLabs/MLHudAlert.git

SPEC CHECKSUMS:
AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057
CocoaSecurity: d288a6f87e0f363823d2cb83e753814a6944f71a
MLHudAlert: e1654a23a4c1bffbf0fbcea2ef1c5f1c8c5dc896
Ono: 13c25831a4a66b30df93bd1fa57cf70f13c62699

PODFILE CHECKSUM: 13d1396980f8da373e400ea9318d6521b938a692

COCOAPODS: 1.6.0
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ class CocoaPodsFunTest : WordSpec({
result.toYaml() should matchExpectedResult(expectedResultFile, definitionFile)
}

"determine dependencies from a Podfile with a external sources" {
val definitionFile = getAssetFile("projects/synthetic/external-sources/Podfile")
val expectedResultFile = getAssetFile("projects/synthetic/external-sources-expected-output.yml")

val result = create("CocoaPods").resolveSingleProject(definitionFile)

result.toYaml() should matchExpectedResult(expectedResultFile, definitionFile)
}

"return no dependencies along with an issue if the lockfile is absent" {
val definitionFile = getAssetFile("projects/synthetic/no-lockfile/Podfile")
val expectedResultFile = getAssetFile("projects/synthetic/no-lockfile-expected-output.yml")
Expand Down
Loading

0 comments on commit 4bbd26a

Please sign in to comment.