I am creating a pod that uses RestKit and a bunch of other pods.
When I am compiling my pod with the command :
pod repo push myCocoapodsRepo myPodspec.podspec --allow-warnings --verbose
The first error I get is
In file included from /var/folders/mx/cg3cmvh14wl2f3mnq0sc_cd00000gn/T/CocoaPods/Lint/Pods/RestKit/Code/ObjectMapping.h:21:
/var/folders/mx/cg3cmvh14wl2f3mnq0sc_cd00000gn/T/CocoaPods/Lint/Pods/RestKit/Code/ObjectMapping/RKObjectMapping.h:23:9: error: include of non-modular header inside framework module 'RestKit.RKObjectMapping' [-Werror,-Wnon-modular-include-in-framework-module]
#import "RKValueTransformers.h"
^
If I rely on other StackOverflow threads about this error, like
Swift compiler error: "non-modular header inside framework module"
Include of non-modular header inside framework module
XCode6: Receiving error "Include of non-modular header inside framework module"
They will all say that setting CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES to YES and/or placing the problematic header file in the Public section instead of the Project section, it will solve the problem. But for me, it does not. Those threads also have in common the Swift language, but I do not use it. I'm still using only Objective-C, but I don't know if it has an impact on my problem.
I do not understand what the error means, therefore I have a lot of difficulty solving the problem. Does someone have another solution?
You should add the flag --use-libraries like this:
pod repo push myCocoapodsRepo myPodspec.podspec --allow-warnings --verbose --use-libraries
Related
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.
I get this error only when I try to archive, building for simulator or other test device works. Previously, I had this problem when trying to build for a test device, but I started over and reinstalled the pod and it worked. I have tried setting 'Allow non-modular Includes in Frameworks' to yes in both my project and Target, but this has NOT worked. Any ideas on how to get out of this would be greatly appreciated!
I got the same error (for archiving only) for my Swift framework with C code inside.
Only this remedy helped me.
Add -Xcc -Wno-error=non-modular-include-in-framework-module in Other Swift Flags (build settings of framework). This flag forces the compiller count that error as a warning.
I have no debugging values in my console for my swift + obj-c app, and I get a really unhelpful message that explains why the debugger isn't working: "warning: Swift error in module XXX.". XXX is the name of my module, not a 3rd party that I include.
My app has been around since before Swift. I used the bridging header to start using Swift, and I recently used the Xcode tool to migrate all the Swift 2 files to Swift 3. (but I still have obj-c legacy in there). I use cocoapods, which may be contributing to the problem.
(lldb) po self
warning: Swift error in module XXX.
Debug info from this module will be unavailable in the debugger.
I tried following the second answer to this post and a couple others
I have found that suggest the same thing: remove duplicate imports.
I tried removing duplicate imports from my swift project. In fact if I run find . -name "*swift" | xargs grep "import" I get no results. So I went to the extreme of removing all imports from all of my swift files (and commenting out code to get it to compile) just to see if I can get my debugger to come back.
So...
Is there another solution to this problem?
Is there a way to get a more detailed error message?
Is it a problem to have duplicate headers in the my bridging header? For example, a lot of my obj-c files import UIKit, and I include a few of those files in the bridging header.
Just now I have encountered this problem.
This is my solution:
If you import 3rd repo by Cocoapods, and the repo is written by Objective-C, you need to import it by this way:
// System
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
// Directly add - Objective-C
#import "EaseUI.h"
// Cocoapods - Objcetive-C
#import MJRefresh;
You can refer to this issue in Github and this question.
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!
I have a Swift 2 project running on Xcode 7. I'm using CocoaPods (v 0.38.2 with use_frameworks!) and have already managed to get those frameworks working:
CryptoSwift
Pluralize_swift
Both Pods are written in Swift, so no problems so far. They work as charm.
Now I'm trying to use SMPageControl which is written in Objective-C. I've seen it's possible to use Obj-C Pods with Swift 2, tried a lot of different combinations but I can't get it to work. SMPageControl class doesn't show on autocomplete suggestions, and obviously when I try to use it the compiler throws Use of undeclared type 'SMPageControl'.
What I have done so far:
Added pod 'SMPageControl' to my Podfile
Ran pod install (I can see the Pod source/framework on Xcode project tree)
Added SMPageControl.framework in Build Phases > Link Binary With Libraries (as I've done with the other frameworks that work)
Created PROJECT_NAME-Bridging-Header.h and added it on the project's Build Settings (I can tell it's working because it threw errors until I got to import SMPageControl correctly)
Added #import <SMPageControl/SMPageControl.h> to the file above
Up to here the project compiles without errors, but I can't get to use SMPageControl in my Swift classes. Tried import SMPageControl in the Swift file, but no luck (it doesn't even autocomplete). I understood it's possible, but I didn't find any example codes.
Is it really possible? If so, what am I missing?
Finally got it to work, it turns out that I was actually missing something.
Along with all steps above, it's needed to import the framework at the top of the Swift file:
import SMPageControl
Since Xcode was not providing any autocomplete I thought it wouldn't be possible to do that. Once I added the import statement, the project compiled successfully and I was able to use SMPageControl() class.