首页 > 解决方案 > An unexpected version directory Classes was encountered

问题描述

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://Username@bitbucket.org/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://Username@bitbucket.org/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://Username@bitbucket.org/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' => 'Username@hotmail.com' }
  s.source           = { :git => 'https://Username@bitbucket.org/Username/privaterepo.git', :tag => s.version.to_s }

  s.ios.deployment_target = '8.0'

  s.source_files = 'PrivateRepo/Classes/**/*'
end

标签: gitcocoapodsbitbucket

解决方案


看起来您快到了,但还没有设置您的 podspec 存储库(这是推荐的步骤:https ://guides.cocoapods.org/making/private-cocoapods.html )。

在您的 Podfile 中,尝试将您的 repo 的源 URL 替换为您的规范的源 URL。例如:

source 'https://username@bitbucket.org/username/private-repo-specs.git'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, ’10.3’

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

我还发现这篇文章有助于建立一个私人仓库: https ://medium.com/practical-code-labs/how-to-create-private-cocoapods-in-swift-3cc199976a18

编辑

在我们的项目中,我们现在直接 URL 到 pod 文件中的 git 源,因为它允许我们快速更改 pod 中的分支,并且意味着您可以删除source我上面提到的 2 行。无论哪种方式都有效:)。

下面是一个使用 URL 直接指向 pod 文件中的 git 项目的示例:

pod ‘PrivatePod’, :git => "git@github.com:Test/privatepod.git"


推荐阅读