Cannot Lint/Push a Swift Cocoapods podspec

I tried to create my first podspec combining ObjC and Swift code, but I soon stumbled uppon a stubborn error that I cannot solve while uploading

Copying MyLibrary from /Users/lukasschwoebel/Library/Caches/CocoaPods/Pods/External/MyLibrary/540307feb534d63ad9015f3f6452b3ad-be661 to ../../../../../../private/var/folders/2p/_pc_vts51b3_pfydgm7_2n200000gn/T/CocoaPods/Lint/Pods/MyLibrary - Running pre install hooks -> MyLibrary (0.1.0) - ERROR | [iOS] Encountered an unknown error (Pods written in Swift can only be integrated as frameworks; this feature is still in beta. Add use_frameworks! to your Podfile or target to opt into using it. The Swift Pod being used is: MyLibrary) during validation.

Here is the command I use:

pod repo push test-podspecs MyLibrary/MyLibrary.podspec --use-libraries --allow-warnings --verbose

As you might see, this is the minimum untouched sample project from CocoaPods as described here: https://guides.cocoapods.org/making/using-pod-lib-create.html As I can not even make this sample running, I suspect something wrong with my cocoapods configuration.

I made sure there is no single Objective C line in the pod that is to be uploaded (though in the end, I would like to have a podspec with ObjC and Swift code mixed, but at this time I just want to have a working podspec with Swift).

I cannot even upload this simple pod with pure Swift. I first tried with CocoaPods v0.39.0, then downgraded to 0.38.2 and after that 0.38.0, even 0.36.0. Even with a complete un-install of CocoaPods.

It seems I need to configure something in CocoaPods to be able to upload a Swift podspec? The error I get obviously is during the building-phase of the pod where the Podfile needs use_frameworks! to be included. So how can I make CocoaPods use it while compiling the pod during the podspec verification?

Also, I have Xcode 7.0.1 and OSX 10.10.5 installed and it is Swift 2.0 code.

Thank you in advance!

Here is the complete podspec, adapted from the original created MyLibrary.podspec (and yes, that is a local Podspec-Repo, but that does not cause/change the error)

Pod::Spec.new do |s|
  s.name             = "MyLibrary"
  s.version          = "0.1.0"
  s.summary          = "A short description of MyLibrary." 
  s.description      = 'Sample Description'
  s.license          = 'MIT'
  s.author           = { "Luke A." => "ls@mymail.to" }
  s.source           = { :git => "file:///Users/.../test/MyLibrary/", :tag => s.version.to_s }
  s.platform     = :ios, '8.0'
  s.requires_arc = true
  s.source_files = 'Pod/Classes/**/*'
  s.resource_bundles = {
    'MyLibrary' => ['Pod/Assets/*.png']
  }
  s.frameworks = 'UIKit'
end

I just found the answer, which seems a little obvious.

The command to upload/push the pod was in a bash-script so I did not always have to type all the flags but just and over the filename/path to the podspec. So in the default bash-script I had the flag --use-libraries which is required for one of my pods.

As I was trying something out and had a typo in the pod repo push .. command I stumbled across the man-page:

--use-libraries Linter uses static libraries to install the spec

With static libraries, this flag seems to be incompatible with Swift podspecs. Removing that flag lints and pushes my podspec successfully.

链接地址: http://www.djcxy.com/p/89644.html

上一篇: 在objc podspec项目中快速依赖

下一篇: 不能纤细/推动Swift Cocoapods podspec