【发布时间】:2015-04-25 06:42:29
【问题描述】:
我尝试使用 Swift 创建 pod,但无法使其在 Swift 项目上运行。
我创建了非常简单的快速扩展
import UIKit
public extension UIView {
public func sw_foo() {
println("bar")
}
}
还有 Podfile
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
pod "TestSwift", :path => "../"
在Objective-C项目中我可以导入#import <TestSwift/TestSwift-Swift.h>并使用方法[self.view sw_foo];
但在 Swift 项目中,当我命令+单击标题import TestSwift时,我不能这样做
即使我将其公开,我也看不到我的方法
import TestSwift
import UIKit
var TestSwiftVersionNumber: Double
很简单的课,不知道自己做错了什么。
在 pod 0.36.3 和 0.36.4 上尝试过
这是我的项目:https://www.dropbox.com/s/h6yyq8207iajlsv/TestSwift.zip?dl=0
和 podspec
Pod::Spec.new do |s|
s.name = "TestSwift"
s.version = "0.1.0"
s.summary = "A short description of TestSwift."
s.description = <<-DESC
An optional longer description of TestSwift
* Markdown format.
* Don't worry about the indent, we strip it!
DESC
s.homepage = "https://github.com/<GITHUB_USERNAME>/TestSwift"
# s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2"
s.license = 'MIT'
s.author = { "Sarun Wongpatcharapakorn" => "artwork.th@gmail.com" }
s.source = { :git => "https://github.com/<GITHUB_USERNAME>/TestSwift.git", :tag => s.version.to_s }
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
s.platform = :ios, '7.0'
s.requires_arc = true
s.source_files = 'Pod/Classes/**/*'
s.resource_bundles = {
'TestSwift' => ['Pod/Assets/*.png']
}
# s.public_header_files = 'Pod/Classes/**/*.h'
s.frameworks = 'UIKit'
# s.dependency 'AFNetworking', '~> 2.3'
end
【问题讨论】:
-
您是否为
TestSwift创建了 pod 规范?如果是这样,请出示这个。否则,您需要创建一个。 pod 规范定义了 pod 的源文件、依赖项等。 -
问题好像有点不对,你用 Swift 做了一个 pod 但是你不能用还是怎么的?
-
@JRG-Developer 在帖子中添加 podspec 以及代码示例
-
@KostiantynKoval 是 Swift pod,但不能在 Swift 中使用。您可以查看我的示例代码。