I'm creating a pod in swift to use with cocoapods, but I'm having a strange problem when trying to use it. My pod is downloaded normally after 'pod install' and I can import it via 'import MyPod'. So far so good, but when I try to access my classes in the pod, I get the message
我正在创建一个豆荚快速使用茧,但我有一个奇怪的问题,当我试图使用它。我的pod在“pod安装”后正常下载,我可以通过“import MyPod”导入。到目前为止还不错,但是当我尝试在pod中访问我的类时,我得到了消息
"Use of undeclared type 'NameOfTheClassIwantToUse'".
If i go to my pod folder in Pods project, all the files are there, but I cannot use it. I also noticed when I go into the import 'MyPod' with command+click I can see just few imports instead of all my classes, like:
如果我去我的pod文件夹在Pods项目,所有的文件都在那里,但我不能使用它。我还注意到,当我使用command+click输入“MyPod”时,我只看到了一些导入,而不是所有的类,比如:
import MyPodProjectName
import MyPodProjectName.Swift
import Foundation
import UIKit
public var MyPodProjectNameVersionNumber: Double
While other imports has all the classes that are supposed to be available upon importing.
而其他导入的所有类都应该在导入时可用。
Does anyone has a clue on what am I missing here?
有人知道我在这里漏掉了什么吗?
1 个解决方案
#1
20
Be sure to declare you class as public, as stated here
如此处所述,请确保将类声明为public
https://guides.cocoapods.org/making/using-pod-lib-create
https://guides.cocoapods.org/making/using-pod-lib-create
As stated there:
如上所述:
It's worth mentioning here, as this catches people quite often, a Swift library needs to have its classes declared as public for you to see them in your example library.
这里值得一提的是,因为这经常会引起人们的注意,所以快速库需要将其类声明为public,以便在示例库中看到它们。
So, just declare namespace "public" on you classes and you are good to go
因此,只要在类上声明名称空间“public”,就可以开始了
I had the same problem, and this worked for me!
我也有同样的问题,这对我很有效!
#1
20
Be sure to declare you class as public, as stated here
如此处所述,请确保将类声明为public
https://guides.cocoapods.org/making/using-pod-lib-create
https://guides.cocoapods.org/making/using-pod-lib-create
As stated there:
如上所述:
It's worth mentioning here, as this catches people quite often, a Swift library needs to have its classes declared as public for you to see them in your example library.
这里值得一提的是,因为这经常会引起人们的注意,所以快速库需要将其类声明为public,以便在示例库中看到它们。
So, just declare namespace "public" on you classes and you are good to go
因此,只要在类上声明名称空间“public”,就可以开始了
I had the same problem, and this worked for me!
我也有同样的问题,这对我很有效!