gpt4 book ai didi

ios - 如何使用 Swift 制作 pod

转载 作者:可可西里 更新时间:2023-11-01 01:40:55 26 4
gpt4 key购买 nike

我尝试用 Swift 创建 pod,但我无法让它在 Swift 项目上运行。

我创建了非常简单的 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

最佳答案

似乎该文件对您的项目不可见。
如果这是 .swift 文件,而不是 .framework,请尝试将文件添加到
构建阶段 -> 编译源

它应该是这样的:

enter image description here

假设您已正确完成一切 - 正确的 podspec 文件等 - 并且您的项目结构如下所示:

enter image description here

关于ios - 如何使用 Swift 制作 pod,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29861942/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com