Swift + Objective C Venmo Pod: 'VENUser.h' file not found - ios

I'm trying to integrate this in a Swift application. I'm using Xcode 6.4 and CocoaPods 0.38.2.
My podfile looks like this:
platform :ios, '8.0'
use_frameworks!
target 'my_app_name' do
pod 'Venmo-iOS-SDK', '~>1.3'
end
With no import in my bridge header, the app runs. With #import <Venmo_iOS_SDK/Venmo.h> however, I get the following error:
..Pods/Venmo-iOS-SDK/venmo-sdk/Categories/VENUser+VenmoSDK.h:1:9: 'VENUser.h' file not found
.../my_app_name-Bridging-Header.h:6:9: Could not build module 'Venmo_iOS_SDK'
Failed to import bridging header '../my_app_name/my_app_name-Bridging-Header.h'
The lines at the top of the Venmo.h file are as follows
#import Foundation;
#import UIKit;
#import <VENCore/VENCore.h>
#import "VENErrors.h"
#import "VENPermissionConstants.h"
#import "VENSession.h"
#import "VENTransaction+VenmoSDK.h"
I tried adding another pod just to make sure it was an issue specifically with my integration with venmo-ios-sdk and ended up adding #import <VENCore/VENcore.h> with zero problems. I'm pretty new to iOS, so I don't really know if I'm missing something extra obvious...

You shouldn't be importing the framework within your bridge header, but instead importing it directly in your Swift code using Swift imports:
import Venmo_iOS_SDK
Alternatively if you are using the Pod from Objective-C, you should be importing the framework header:
#import <Venmo_iOS_SDK/Venmo_iOS_SDK.h>
Or, using module imports in Objective-C (http://tonyarnold.com/2014/04/10/clean-up-your-projects-with-xcode-5.html):
#import Venmo_iOS_SDK;

I don't know if there was another way to solve this, but I just edited the pod so in VEnUser+VenmoSDK.h the first line was changed to
#import "VENCore/VENUser.h"
instead of
#import "VENUser.h"
I was looking at the wrong file so didn't see the "obvious" error, nor was it particularly obvious to me...but this fixes it.

You can check Header search paths or Library search paths.
Also can pod install.

Related

How to import framework into XCode project?

I get No such module 'BRLMPrinterKit' error.
I take a reference from official document https://support.brother.com/g/s/es/htmldoc/mobilesdk/guide/getting-started/getting-started-ios.html to import framework.
Here is my step:
drag BRLMPrinterKit.framework and BRLMPrinterKitW.framework into my framework folder
Check they are in Link Binary With Libraries (remove and drag again)
Check Framework Search Paths (I'm not sure it correct or not)
Check Header Search Paths (I'm not sure it correct or not)
Finally I clean and build get No such module 'BRLMPrinterKit' error.
I have no idea how to fix my import problem, any help would be appreciated. Thanks.
That's not a Swift module, so first, you need to create a bridging header, in which you import <BRLMPrinterKit/BRLMPrinterKit.h>, then you can use the BRLM classes in your Swift files.
Try using CocoaPods to install the framework, it's more convenient and faster.
Your framework supports installation using cocoapods
https://cocoapods.org/
https://github.com/jonathantribouharet/BRLMPrinterKit
using CocoaPods to install the 'BRLMPrinterKit' framework.
add the bridge file.(Targets > Build Settings > Swift Compiler - General > Objective-C Bridgeing Header)
the bridge file.h
#ifndef PtouchPrinterKit_Bridging_Header_h
#define PtouchPrinterKit_Bridging_Header_h
#import <BRLMPrinterKit/BRPtouchBluetoothManager.h>
#import <BRLMPrinterKit/BRPtouchDeviceInfo.h>
#import <BRLMPrinterKit/BRPtouchNetworkManager.h>
#import <BRLMPrinterKit/BRPtouchPrinter.h>
#import <BRLMPrinterKit/BRPtouchPrinterData.h>
#import <BRLMPrinterKit/BRPtouchPrinterKit.h>
#import <BRLMPrinterKit/BRPtouchPrintInfo.h>
#endif
then you can use the framework

iOS project won't build when certain pod files are included in files that are included in bridging header

I found a bug that I'm kind of stumped by. Wondering if anyone else experienced this.
I have this MBProgressHud pod that I include in my ViewController.h. Presumably I'll use it in ViewController.m somewhere.
I also want to include ViewController.h in my bridging header so that I can write a Swift extension.
However, when I build and run, I get an error:
'MBProgressHUD.h' file not found
I've recreated the error in this project: https://github.com/zackshapiro/PodTest
Any help would be appreciated
Replace
#import "MBProgressHUD.h"
with
#import <MBProgressHUD/MBProgressHUD.h>
And all will be compiled. MBProgressHUD.h is a file from module MBProgressHUD therefore you can't include it with ""

Swift Project With Objective C Wrapper OpenCV

I have just started to use the openCV library and I am trying to get everything set up. I have a swift project and have dowloaded the framework through cocoa pods. I am trying to import the openCV framework in my objective-c file and I keep getting errors. This is my code and the following are the errors.
#import "OpenCVWrapper.h"
//this line causes the errors
#import <opencv2/opencv.hpp>
#implementation OpenCVWrapper
#end
Errors:
After a little digging, I finally found the solution:
Import any Apple headers AFTER those of OpenCV. So the code should look like this:
#import <opencv2/opencv.hpp>
#import "OpenCVWrapper.h"
You need to add Bridging Header file and import the objective c file in it. after creating a file you need to add the path of this file into Build settings of project Target. Find Bridging Header in build settings. please refer
https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html

Bridging-header works, but imports are not working?

I installed a library using CocoaPods, and it all seems to work. I added a bridging-header to my project, which I know works since I use several different libraries in this header. But I just installed and bridged libPhoneNumber-iOS and it seems to work, except...it doesn't. I find the files, it imports them correctly in the header, but I can't use it in swift. It should be NBPhoneNumberUtil, but it doesn't exist.
I have imported them like this in my header:
#import "libPhoneNumber_iOS/NBPhoneNumberUtil.h"
#import "libPhoneNumber_iOS/NBPhoneNumber.h"
and if I type anything differently it will give me an error saying it can't the specified files, so this should be imported correctly. Also if I type NBPhoneNumberUtil in this header-file I can see the object so it works. But in my swift-project the modules doesn't exist. Again, I know my bridging-file works since I use other libraries in this file, and in swift. Any ideas what might be wrong?
Update #1:
So I tried adding import to my swift-file, and it "works".
import libPhoneNumber_iOS/NBPhoneNumberUtil
import libPhoneNumber_iOS/NBPhoneNumber
Except that Xcode complains that this is not a viable syntax, it wants to add a semi colon somewhere. But now I can create the objects I need, but I can't compile since Xcode wants me to fix the errors first. This is so weird. Any ideas?
I resolved the issue now. The issue was that I use use_frameworks! in my pod file so the paths are different. In fact, when you use use_frameworks! you don't need a bridging header, and have to import the files directly in swift. The problem was that I didn't know how to import it, but now I do.
pod file:
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, '8.0'
target 'test' do
pod 'libPhoneNumber-iOS', '~> 0.8'
end
target 'testTests' do
end
In the Xcode project you do not need a bridging header anymore, and simply import the library where you want to use it, like this:
import libPhoneNumber_iOS
Now it should be working. Hope this helps someone else.
The answer is to import them like this in your bridging header:
#import "NBPhoneNumberUtil.h"
#import "NBPhoneNumber.h"
The procedure that I used to test this is written below.
Create a new Xcode project
I used the Single View Application template for Objective-C.
Create Podfile and Install
Podfile:
source 'https://github.com/CocoaPods/Specs.git'
pod 'libPhoneNumber-iOS', '~> 0.8'
Install:
$ pod install
Create a Swift file
At this point a bridging header file was created by Xcode.
I added the imports into the bridging header using:
#import "NBPhoneNumberUtil.h"
#import "NBPhoneNumber.h"
In the Swift file, I wrote:
class Test {
func test() {
let util = NBPhoneNumberUtil()
}
}
The project compiled without errors.

iOs: Swift Google Analytics

I am new to iOs development and would like to implement Google Analytics (swift).
It appears there is some missing information on implementing Google Analytics in swift on Google's instruction page:
It seems the import statement above is incorrect, can anyone assist me with the missing/correct statement?
Exta Info:
I come from a Java background and IDEs I use import for you, so
please excuse my stupidity.
I have cocopods installed, and use other pods: Almofire, Fabric, swiftyJson etc
I am developing for iOs 8
Instructions above this, are clear and working. Installing the pods/config file etc
In your Objective-C bridging header file, You should import GA header files:
#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIEcommerceFields.h"
#import "GAIEcommerceProduct.h"
#import "GAIEcommerceProductAction.h"
#import "GAIEcommercePromotion.h"
#import "GAIFields.h"
#import "GAILogger.h"
#import "GAITrackedViewController.h"
#import "GAITracker.h"
I am not sure if I am missing some import.
If you look in your Pods folder in Xcode you can see the available pods there. Most of them usually have a file that contains all import statements for any files needed. In this case its the Analytics.h file in Pods/Google/Analytics/
I'm guessing that, to import this file in your bridging header (which I hope you have, if not let me know), you can use #import "Google/Analytics.h".
It also says a little bit lower on the page, to import the <Google/Analytics.h> to the header.

Resources