Obj C project swift file cannot see cocoa pods - objective-c

I have an Objective C project that I added a swift file to - the swift file will contain convenience functions to the rest of my objc project. Adding the swift file triggered adding a bridging header - which I did. All of this works. I also have cocoapods configured and working from objc.
I can call a swift method from objc but my swift file cannot see any of my swift cocoapod modules. I get error 'no such module'. I've searched here extensively and have cleaned my project, cleaned the build folder checked my search paths- all appears ok. I am using use_frameworks! In my pod file.
Any pointers?

You need to add your pod header to your bridging header as described here: Import Objective-C Framework (CocoaPod) into Swift?

Related

Creating pod in swift which have dependency on another objective-c pod

As I explained in image I want to create Pod lib in swift which have another Pod lib dependency written in Objective-c.
Now I know that to use objective-c code in swift we need bridge file and I created it too.
but When I set it into Pod's build phase I got this error<unknown>:0: error: using bridging headers with framework targets is unsupported
I got hint in internet that I should put .h file into pod-umbrella.h file, But that also gave me error Include of non-modular header inside framework module 'DemoPod'
Please help me if you had similar issue in past and resolved it.
Some hint/suggestions are also welcome.
Here is my demopod project for you if you want to play around.
Demo Pod Project
EDIT
As per Ashsis suggestion I added below code into DemoPod.modulemap
framework module AdaptiveCard {
umbrella header "/Users/jageen.shukla/Documents/Project/ai answer/DemoPod/Example/Pods/AdaptiveCards/AdaptiveCards.framework/Headers/ACFramework.h"
requires ios
export *
}
But still I can not build project because it give me error in target project that can not find module "AdaptiveCard".
I change code in DemoPod.modulemap
framework module DemoPod {
umbrella header "DemoPod-umbrella.h"
// Solution 2
framework module AdaptiveCard {
umbrella header "/Users/jageen.shukla/Downloads/DemoPod/Example/Pods/AdaptiveCards/AdaptiveCards.framework/Headers/ACFramework.h"
export *
module * { export * }
}
// ----
export *
module * { export * }
}
Now I am able to compile my project. but I am not sure what I am doing is good practice or not? Plus I am also not know why I have to mention `absolute path` of adaptive card's header file.
Latest code : [Demo_2][4]
https://drive.google.com/file/d/1Xve0DUAy4bQ7sx4d3H8WLbJJwTqlJnCt/view?usp=sharing
Bridging header is only recommended at App Target and App Test target to access objective c and CPP files in swift. You should use modulemap to expose the Objc and CPP functionality to swift library when it comes to static library or framework. Please check the code implementation how to use modulemap here: https://github.com/ashislaha/Swift-ObjectiveC-Interoperability
As the error says, bridging headers aren't allowed in frameworks, only in applications.
The detailed documentation is here
The Swift code will be able to access everything from objc that is included in the public umbrella header for your framework where it says
// In this header, you should import all the public headers of your framework using statements like #import <YourFramework/PublicHeader.h>
You'll need to remove the bridging header from where you added it in the Build Settings, in order to get your framework to compile.
what should you do now ?
do this:
Remove your bridging header file.
Remove references to the bridging header file in the build settings for the framework
Add the necessary headers to your umbrella file ([Name].h)
Make the included files public in the framework's "Headers" section of its "Build Phases".
Clean and rebuild.
Note: The "umbrella header file" is a file (named [ProductName].h) that generally represents all public headers of a framework. It is usually just a list of #import statements to other headers contained in the framework. In Xcode, if you open UIKit.h, you will see a good example of an umbrella file.

Errors after removing Obj-C Bridging Header from Swift 2 Project

Was trying to implement some Obj-C code into my Swift 2 project and decided that I was going to try a different method.
I deleted the files I added, including the newly created bridging header.
I went to build settings and removed the contents of the "Objective-C Bridging Header" setting and now I am getting bombarded with errors.
My project was running fine with no errors prior to the Obj-C fiasco.
Can someone help? See attached image for the errors I am getting.
According to the errors, your swift files (profileVeedVC.swift) still refer to the obj-c code. Remove the pod from your podfile and remove any references within the files.
Good luck!

Swift pod in objective-c project issue

I tried to update a Pod that is in swift now.
So I added use_frameworks! into my Podfile and pod install.
I also checked "Embedded Content Contains swift Code" is YES
The error that my other pods that are in Objective-C cannot be found. (file not found)
If I understoof, use_frameworks compiles all pods as frameworks even the objective C ones that don't need that, but anyone can help me fix this issue ?
Do I need to use a Bridging-Header ?
When using frameworks with Swift pods, instead of using a bridging header, in the files that you wish to use the framework in, you just have to import FrameworkName

swift project with cocoapods obj-c dependence

I'm making a simple swift application which links an obj-c cocoapod dependency SFRoundProgressCounterView. My Podfile contains use_frameworks!. After installing pods and building the project I get 2 errors:
SFCounterLabel.h:12:9: 'TTTAttributedLabel.h' file not found
Could not build Objective-C module 'SFRoundProgressCounterView'
I checked that SFCounterLabel.h which is part of SFRoundProgressCounterView import TTTAttributedLabel:
#import "TTTAttributedLabel.h"
I tried to use MyProjectName-Bridging-Header.h with
#import "TTTAttributedLabel.h"
but without reason.
My version of Cocoapods is 0.39.0.
What should I do to link SFRoundProgressCounterView correctly to my swift project?
It looks like in SFCounterLabel.h SFRoundProgressCounterView needs to use the import syntax that supports frameworks. #import <TTTAttributedLabel/TTTattributedLabel.h> or #import TTTAttributedLabel.TTTAttributedLabel;

Xcode 6/CocoaPods 0.36 - adding Swift bridging header to project Build Settings manually

I've read a bunch of articles on adding a Swift bridging header to an Obj-c project:
Apple's docs
Bohemian Polymorph
SwiftCast
Using CocoaPods 0.36, I should see the Swift Compiler sections appear in Build Settings but they aren't? I search in the box for Swift or Bridging and nothing shows up. And I can't add a new Swift file to the project in this situation because I'm writing some reusable installation steps for a project (having the end user create a blank swift file and delete it after the fact is pretty janky).
What's the proper way to manually add a bridging header and configure the Build settings when using CocoaPods? What am I missing?
Bonus Points: I'm ultimately going to be scripting this. If you have an idea of how to do it programmatically, that's even better!