Ios 如何用Swift制作豆荚
我试图用Swift创建pod,但我无法使它在Swift项目上工作 我创建了非常简单的swift扩展Ios 如何用Swift制作豆荚,ios,swift,cocoapods,Ios,Swift,Cocoapods,我试图用Swift创建pod,但我无法使它在Swift项目上工作 我创建了非常简单的swift扩展 import UIKit public extension UIView { public func sw_foo() { println("bar") } } 和播客文件 source 'https://github.com/CocoaPods/Specs.git' use_frameworks! pod "TestSwift", :path =>
import UIKit
public extension UIView {
public func sw_foo() {
println("bar")
}
}
和播客文件
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
pod "TestSwift", :path => "../"
在Objective-C项目中,我可以导入#导入并使用方法[self.view sw#u foo]代码>
但在Swift项目中,当我使用command+单击标题时,我无法导入TestSwift
我无法看到我的方法,即使我将其声明为公共
import TestSwift
import UIKit
var TestSwiftVersionNumber: Double
这门课很简单,我不知道我做错了什么
在第0.36.3舱和第0.36.4舱上试用
以下是我的项目:
和播客
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
Pod::Spec.new do|s|
s、 name=“TestSwift”
s、 version=“0.1.0”
s、 summary=“TestSwift的简短描述。”
s、 说明=2.3'
结束
您的项目似乎看不到该文件。
如果这是.swift
文件,而不是.framework
,请尝试将该文件添加到
构建阶段->编译源代码
应该是这样的:
假设您已经做了所有正确的事情-正确的podspec文件,etc-并且您的项目结构如下所示:
我终于发现了问题,我的示例项目与我的pod同名TestSwift
。更改项目名称后,一切正常。我的问题与扩展不是“公共的”有关
所以我的文件从
extension UIView {
//methods
}
到
您是否为TestSwift
创建了pod规范?如果是,请出示这个。否则,您需要创建一个。pod规范定义了pod的源文件、依赖项等。问题似乎有点错误,你在Swift中制作了一个pod,但你不能使用它,或者什么?@JRG Developer在帖子中添加了podspec和代码sample@KostiantynKoval是Swift pod,但不能在Swift中使用。你可以检查我的示例代码。这是我的示例项目,你能检查一下我做错了什么吗?
public extension UIView {
//methods
}