Guilherme Guilherme - 1 month ago 7
iOS Question

Creating pod, use of undeclared type for my pod classes

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

"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:

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?

Answer

Be sure to declare you class as public, as stated here

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.

So, just declare namespace "public" on you classes and you are good to go

I had the same problem, and this worked for me!