is it possible to import one pod that is equivalent to it's dependencies?
I know I can do it in the Podfile, but what about the actual imports in code?
For example, instead of import SwiftyJSON and import RxSwift, I'd have only import AllMyPods, which is my own pod I created just to aggregate the pods I use.
Related
I'm following this documentation to implement ML Kit for iOS, but I can't figure out which import should I use to create a VisionImage.
The pod I am using is GoogleMLKit/BarcodeScanning.
I have tried with the following imports without luck:
import MLImage
import MLKit
import MLKitBarcodeScanning
Which is the right import to create a VisionImage and then a BarcodeScanner?
According to MLKit Release Notes (as of June 29, 2021), the correct pod artifact names are listed like this.
Update your pod declaration to the latest version like this.
pod 'MLKitBarcodeScanning', '1.3.0'
After this change, do a pod install and now you can use following two imports to work with MLKit on iOS.
import MLKitBarcodeScanning
import MLKitVision
At top of the documentation you referenced, there is a link to the ML Kit quickstart sample, where you can find sample code in both Swift and Objective-C showing you how to import ML Kit. Specifically, in Swift you can import MLKit and in Objective-C #import MLKit;.
I configured CocoaLumberjack properly using the swift pod.
And I can log whatever:
DDLogVervose("")
DDLogInfo("")
But I have to in every class to use it:
import CocoaLumberjack
Isnt there a way that I can globaly import ?
The only "trick" to have it available in all your classes is to use a pch (precompiled header) and import CocoaLumberjack there. It's a header that gets imported in all your files.
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?
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!
Yes you need to declare your class, methods and relevant variables as public and don't forget to import your module on top of the class you need.
I am trying to implement the Venmo-iOS-SDK into my app using CocoaPods. Inside my Podfile, I have the use_frameworks! statement to make all dependencies into embedded frameworks. After running pod install, the Venmo-iOS-SDK appears to correctly be installed in CocoaPods, but I cannot figure out what to put at the top of my files as an import statement.
The other pods that I have worked with do not have dashes in their name, so I am just able to put import PodName. However, import Venmo-iOS-SDK triggers a compile time error stating "consecutive statements on a line must be separated by a ;".
I have tried all the following statements and none work:
import Venmo-iOS-SDK
import Venmo
import VenmoiOSSDK
import VenmoSDK
Does anyone know what to import for this framework in swift, or what the import statement looks like for other pods with a - in their name?
I'd try the below option
import Venmo_iOS_SDK
I would like to use CocoaPods in my CocoaTouchFramework, which has Swift classes.
My Podfile looks the following:
platform :ios, '7.0'
inhibit_all_warnings!
link_with 'MyFramwork'
pod "AFNetworking", "2.5.0"
But how do I achieve to include e.g. AFNetworking into my .swift class in the CocoaTouch Framework? There's no briding header so I somehow have to import it directly in my swift class...
AFNetworking is an objective-c library. So you need to have a bridging-header and import the correct headers.
If you want to use a Swift library for networking you should look to Alamofire. It's from the same creator. Put this in your podfile:
pod 'Alamofire', '~> 1.1'
In every Swift file where you want to use it import the library with this line:
import Alamofire
You need to import AFNetworking, just using in your Swift files:
import AFNetworking
Be careful with upper/lower case letters, as autocompletion does not work. Import every pod library you need to use, using its name (i.e., the name of the folder inside the Pods group/directory)
If you want to use AFNetworking pod, try to add an Objective-C class by using File->New->File->Cocoa Touch Class. Xcode will ask you to add bridge header.
In your bridge header you can import AFNetworking such as;
#import <AFNetworking/AFNetworking.h>
If you don't want to use bridge header you should use Alamofire pod.