Description
The problem
When publishing multiple Podspecs with inter-dependencies to a private spec repo in sequence, the pod repo push
command fails. The validation for a pod fails to find a dependency that was successfully pushed in the immediately preceding step.
It seems like there's a race condition or a caching issue where the local spec repo clone is not correctly updated or referenced during the validation of the subsequent pod.
Steps to Reproduce
-
Have a private spec repo. For this example, we'll call it
MyPods
. -
Create multiple Podspecs with a dependency chain.
MyLibrarySwift.podspec
(no other internal dependencies)MyLibraryObjc.podspec
(depends onMyLibrarySwift
)MyLibrary.podspec
(depends onMyLibraryObjc
)
Here are the contents of our podspecs:
MyLibrarySwift.podspec
Pod::Spec.new do |s| s.name = 'MyLibrarySwift' s.version = '1.0.0' ... s.ios.deployment_target = '15.0' s.swift_version = '5.5' s.dependency 'OtherLib', '~> 0.1' s.source_files = 'MyLibrarySwift/Sources/*.swift' end
MyLibraryObjc.podspec
Pod::Spec.new do |s| s.name = 'MyLibraryObjc' s.version = '1.0.0' ... s.ios.deployment_target = '15.0' s.swift_version = '5.5' s.dependency 'MyLibrarySwift', '~> 1.0' s.public_header_files = 'MyLibraryObjc/Sources/Public/MyLibraryObjc/*.h' s.source_files = [ 'MyLibraryObjc/Sources/*.m', 'MyLibraryObjc/Sources/Public/MyLibraryObjc/*.h' ] end
-
Publish them in the correct dependency order using the following command for each podspec:
bundle exec pod repo push MLPods <path-to-podspec-file> --allow-warnings --skip-import-validation --sources=git@github.com: jjfernandes87/mobile-ios_specs.git,https://cdn.cocoapods.org
We first run this command for
MyLibrarySwift.podspec
, which succeeds. Then, we immediately run it forMyLibraryObjc.podspec
.
Expected Outcome
The second command (pod repo push
for MyLibraryObjc.podspec
) should successfully validate the podspec by finding the MyLibrarySwift
spec in the MLPods
repo, which was just pushed.
Actual Outcome
The second command fails with an error, indicating it cannot find the MyLibrarySwift
spec, even though it was successfully pushed and the local git repo seems to be updated.
Here is the full log trace from our CI:
Cloning spec repo `MyPods` from `git@github.com: jjfernandes87/mobile-ios_specs.git`
Validating spec
-> MyLibrarySwift -> MyLibrarySwift (1.0.0)
- WARN | source: Git SSH URLs will NOT work for people behind firewalls configured to only allow HTTP, therefore HTTPS is preferred.
- WARN | summary: The summary is not meaningful.
- NOTE | xcodebuild: note: Using codesigning identity override: -
- NOTE | [iOS] xcodebuild: note: Building targets in dependency order
- NOTE | [iOS] xcodebuild: note: Target dependency graph (2 targets)
Updating the `MyPods' repo
Adding the spec to the `MyPods' repo
- [Add] MyLibrarySwift (1.0.0)
Pushing the `MyPods' repo
Updating spec repo `MyPods`
$ /usr/bin/git -C /Users/ec2-user/.cocoapods/repos/MyPods fetch origin --progress
$ /usr/bin/git -C /Users/ec2-user/.cocoapods/repos/MyPods rev-parse --abbrev-ref HEAD
master
$ /usr/bin/git -C /Users/ec2-user/.cocoapods/repos/MyPods reset --hard origin/master
HEAD is now at 35bee8e04 [Add] MyLibrarySwift (1.0.0)
Validating spec
-> MyLibraryObjc -> MyLibraryObjc (1.0.0)
- WARN | source: Git SSH URLs will NOT work for people behind firewalls configured to only allow HTTP, therefore HTTPS is preferred.
- WARN | summary: The summary is not meaningful.
- ERROR | [iOS] unknown: Encountered an unknown error (Unable to find a specification for `MyLibrarySwift (~> 1.0)` depended upon by `MyLibraryObjc`)
Additional Context
- We are using a CI script to automate this process. Our script has this interesting line in it:
sleep(60) # Wait for sync to next pod
. This was likely added because this is a recurring problem, and it suggests a timing/synchronization issue. However, this is not a reliable solution and often fails. - It appears that the validation for
MyLibraryObjc
is not using the most up-to-date version of theMyPods
repo that's available locally after the first push, despite the git logs showing areset --hard
.