An unexpected version directory Classes was encountered
Asked Answered
C

3

16

I get an error while create a private repo. This are the steps I take:

  1. Create folder, run pod lint create PrivateRepo and set the values
  2. Create private repo in BitBucket
  3. Run this command in the PrivateRepo folder:

commands:

git add .
git commit -m “Initial Commit"
git remote add origin https://[email protected]/Username/privaterepo.git
git push -u origin master
  1. Change the summary and homepage in my podspec, and set the bitbucket link above as source
  2. Run this commands:

commands:

git tag 0.1.0
git push origin 0.1.0
  1. Running pod spec lint --swift-version=4.1 now passes validation
  2. Run this commands:

commands:

pod repo add PrivateRepo https://[email protected]/Username/privaterepo.git
pod repo push PrivateRepo PrivateRepo.podspec --swift-version=4.1
  1. Till now, no error has ocurred. However when I want to pod install that pod into my other project, I get an error:

An unexpected version directory Classes was encountered for the /Users/Username/.cocoapods/repos/PrivateRepo/PrivateRepo Pod in the PrivateRepo repository.

This is my podfile in my other project:

source 'https://[email protected]/Username/privaterepo.git'
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, ’10.3’

target 'OtherProject' do
  use_frameworks!
pod 'PrivateRepo'
end

This is my podspec file:

Pod::Spec.new do |s|
  s.name             = 'PrivateRepo'
  s.version          = '0.1.0'
  s.summary          = 'test'

  s.description      = <<-DESC
TODO: Add long description of the pod here.
                       DESC

  s.homepage         = 'https://google.com'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'Username' => '[email protected]' }
  s.source           = { :git => 'https://[email protected]/Username/privaterepo.git', :tag => s.version.to_s }

  s.ios.deployment_target = '8.0'

  s.source_files = 'PrivateRepo/Classes/**/*'
end
Chastain answered 6/5, 2018 at 11:48 Comment(3)
So the issue is with pod not git?Hammon
@Hammon I have no idea, maybe I missed a step somewhere.Chastain
finally found answer?? same issue for meTympanitis
S
15

It looks like you're almost there, but just haven't set up your podspec repo (which is a recommended step: https://guides.cocoapods.org/making/private-cocoapods.html).

In your Podfile, try replacing the source URL of your repo to that of your spec instead. Eg:

source 'https://[email protected]/username/private-repo-specs.git'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, ’10.3’

target 'OtherProject' do
  use_frameworks!
pod 'PrivateRepo'
end

I also found this article helpful in setting up a private repo: https://medium.com/practical-code-labs/how-to-create-private-cocoapods-in-swift-3cc199976a18

EDIT

In our project, we now URL directly to the git source in the pod file, as it allows us to quickly change branches in the pod and means you can remove the 2 source lines I mentioned above. Either way works though :).

Here is an example of using a URL straight to the git project in your pod file:

pod ‘PrivatePod’, :git => "[email protected]:Test/privatepod.git"

Selah answered 19/2, 2019 at 14:57 Comment(3)
Not sure if this fixed the error (because I already had it working (but didn't know the steps I did)). If someone can verify this works, I will mark it eventually as accepted. Thank you!Chastain
Hi, after change to pod ‘PrivatePod’, :git => "[email protected]:Test/privatepod.git" , it worked fine to me.Kurdish
Worked beautifully after changing it to pod ‘PrivatePod’, :git => "[email protected]:Test/privatepod.git"Narceine
N
1

Ran into this issue because:

An unexpected version directory `1.0.1_customBuild_90` was encountered for the `/Users/mfaani/.cocoapods/repos/Product-specs/MyPod` Pod in the `MyPod` repository.`

Basically the 1.0.1_customBuild_90 wasn't standard.

Newlywed answered 4/3, 2022 at 19:8 Comment(0)
V
0

Due to time constraints, I used the :git method to temporarily import a private pod.

This time I encountered the same issue again. Fortunately, I found LocoMoviles' video tutorial and CocoaPods' official Specs. Through learning and reference, I finally had an epiphany and successfully solved this problem.

The pod source code repository and PodSpecs repository are not the same concept.

Here's an example using a pod called APrivatePod:

The file structure of APrivatePod is as follows:

APrivatePod
├── APrivatePod.podspec
├── Classes
│   └── APrivatePod.h
├── LICENSE
├── README.md
├── Resources

The file structure of the PodSpecs repository is as follows:

PodSpecs
├── APrivatePod
│ ├── 0.1.0
│ │ └── APrivatePod.podspec
│ └── 0.1.1
│ └── APrivatePod.podspec
└── BPrivatePod
├── 0.1.0
│ └── BPrivatePod.podspec
└── 0.1.1
└── BPrivatePod.podspec

With the above overview and the following picture I captured from the official website, the reason for the error is obvious.

enter image description here

The above answer is written by me and translated into English by OpenAI.

Ventral answered 13/6, 2023 at 7:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.