I built FFmpeg for Apple's platforms as an XCFramework. I used the script in https://github.com/kewlbear/FFmpeg-iOS-build-script/pull/147 to do so.
I'm trying to now consume that framework inside a traditional iOS/macOS framework (named VideoEditing), that then is used inside my iOS app (soon to try and be Catalyst).
In VideoEditing I have linked to FFmpeg.xcframework and then in the app that uses VideoEditing I have linked & embedded FFmpeg.xcframework. Previously I was building FFmpeg as a standard static library, and using that from inside VideoEditing in a Objective-C++ wrapper so I can use it all from Swift.
In that Objective-C++ file I would import FFmpeg headers like #import <libswscale/swscale.h> To make that work, I had to set header search paths. How are you supposed to do it once you convert to the XCFramework? I've tried #import FFmpeg, #import <FFmpeg/libswscale/swscale.h>, #import <FFmpeg/swscale.h> as well as #import <libswscale/swscale.h>. In every case I just get a file not found error on the import line.
All of Apple's examples are showing it just in Swift with the framework vending a module. If I was to try and still set a header search path, you now have different headers per architecture.
Try #import FFmpeg and also set Enable Modules (C and Objective C) to YES from build settings. Make sure that Link Frameworks Automatically is set to YES
You need to put header files parallel to xcframework and set header search path to that header file. xcframework is just like a single .a file, Xcode will not search headers inside xcframework.
Related
I have a CocoaPod written in Swift 4. Now I need to add some new features to this pod. To be able to do it I need to use a static framework written in Objective-C.
I supposed I need to use a bridging header, but I don't know how should I modify my .podspec in such case. When I am trying to add a header file with this line of code:
#import <MyObjectiveCFramework/MyObjectiveCFramework.h>
to s.source_files I see this error: Include of non-modular header inside framework module.
Also, I found out that I can use a special module.modulemap file, but what data should I add to that file and how can I refer to the module.modulemap in my .podspec file?
This is really frustrating me. I've integrated the Braintree library into several iOS projects before to be used in swift and never really had a problem but currently I can't get it to work.
I have followed/repeated the instructions here over and over:
https://developers.braintreepayments.com/start/hello-client/ios/v4
Specifically, i put pod 'Braintree' in my Podfile, ran a pod install and pod update, and have verified the Braintree library now appears in the Pods directory.
I have re made my bridging header 3 times now too, being careful to set the target to my app. I've also verified over and over that I have set the objective c bridging header in my Build Settings to the correct file, and have it succesfully creating bridging headers for other objective c files. Sadly though the following lines just aren't working in the bridging header:
#import "BraintreeCore.h"
#import "BraintreeUI.h"
They both give a compile error of the same type, saying BraintreeCore.h file not found.
I was able to do the following without getting an error:
#import "Pods/Braintree/BraintreeCore/Public/BraintreeCore.h"
But when I try and do the same for BraintreeUI.h like so:
#import "Pods/Braintree/BraintreeUI/Public/BraintreeUI.h"
It links me to the BraintreeUI.h file and tells me "BraintreeCore/BraintreeCore.h" file not found about this line in the BraintreeUI.h file:
#import <BraintreeCore/BraintreeCore.h>
What am I doing wrong?? this should be straightforward but it's been infuriating me for over 12 hours now.
Full disclosure: I work at Braintree on the iOS SDK.
Your bridging header should not need you to specify a path to the umbrella header files. This might indicate that your Xcode project's build configuration is set up so that Xcode's build system can't find the header files. In a typical project, you should be able to do this no problem.
My suggestion would be to take a close look at the Project > Build Settings > Search Paths settings. In particular, the Header Search Paths setting should contain one entry that looks like this:
"${PODS_ROOT}/Headers/Public/Braintree"
If it doesn't, I suspect that CocoaPods is not playing nice with your Xcode project. You may want to try de-integrating and re-integrating. Using CocoaPods 1.0, you should be able to do pod deintegrate, make sure your Pods/ folder is deleted, and run pod install. Worst case possibility, you may just want to start with a brand-new Xcode project and drag over your old source files (although that might be a big pain).
Did you find a solution, HelloCoding? Facing the same issue ...
In my case, I noticed that the Braintree documentation says "If your app is written in Swift but your CocoaPods integration does not use dynamic frameworks, you can import Braintree in a bridging header".
So I deleted the imports from the bridge file, and included a "use_frameworks!" instruction in my Podfile instead.
I have no idea whether this is the approved way to fix the issue, but it seemed to work for me.
I am responsible for converting an application from Objective-C to Swift. One of the objective c files called 'database' imports file called sqlite3.h. Now I did not convert database.h and database.m to Swift. Instead I created an Objective-C bridging header that exposed the database code to the Swift files. However the database header file imports a file called sqlite3.h. So first I linked a library to my project called libsqlite3.dylib as I believed this library contains the sqlite3.h file. But I cannot view any header files the library contains.
So do I just need to include the libsqlite3.dylib in my objective-c bridging header file, and if so whats the syntax? Or do i need to download the sqlite3.h header file, and if so where can I get the code from or download it from?
Libraries do not contain header files (i.e. there is no header inside a dylib file).
In database.h (or .m), there is a line that looks like this:
#import <sqlite3.h>
Right-click on it and choose "Jump to definition" -- it should take you to the file. If not, something is wrong with your header paths.
You can install the sqlite3 using cocopods:
pod 'sqlite3'
Or if you want the swift version:
https://github.com/stephencelis/SQLite.swift
My Swift / iOS9 framework 'viewer_protocol' uses another and external Objective-C framework (CocoaAsyncSocket). I'm using Carthage to build CocoaAsyncSocket. So far everything works fine: In have an example App inside my framework Xcode Project using my framework without any problems.
Now I want to use my Framework in a different Xcode Project - although using Carthage. I include only my Framework as a dependency and Carthage automatically resolves the dependencies to CocoaAsyncSocket. I embedded both frameworks into this new Xcode Project and build my App: Everything works fine here - except one warning I can't rid off:
/Users/John/Repositories/my_project/<module-includes>:1:1:
Umbrella header for module 'my_project' does not include header 'GCDAsyncSocket.h'
This is my framework header:
#import <UIKit/UIKit.h>
//! Project version number for my_project.
FOUNDATION_EXPORT double my_projectVersionNumber;
//! Project version string for my_project.
FOUNDATION_EXPORT const unsigned char my_projectVersionString[];
// In this header, you should import all the public headers of your framework
using statements like #import <my_project/PublicHeader.h>
#import <CocoaAsyncSocket/CocoaAsyncSocket.h>
As you can see CocoaAsyncSocket.h is imported. Furthermore inside my framework the CocoaAsyncSocket.h file is included:
What I am missing here? I'm using several others external frameworks inside my framework, there're no warnings for them - all of these external frameworks are written in Swift - CocoaAsyncSocket is pure Objective-C.
This is my frameworks module.modulemap:
framework module my_project {
umbrella header "my_project.h"
export *
module * { export * }
}
module viewer_protocol.Swift {
header "my_project-Swift.h"
}
Update
I found a solution: Changing the import statement in my framework header from
#import <CocoaAsyncSocket/CocoaAsyncSocket.h>
to
#import "CocoaAsyncSocket/CocoaAsyncSocket.h"
Now Xcode finds the header file and the warning disappears.
I recently ran into same issue. Apparently I had header file set as public in target membership, but it was not exposed in umbrella header. Fixed issue by making header file with project access instead of public.
I had the same issue. Seemed to be related to old build files.
The standard Xcode problem fixer worked for me:
Clean project (Product > Clean Build Folder)
Deleted derived data
Restart Xcode
I had the same issue today
Umbrella header for module 'HockeySDK' does not include header 'BITHockeyBaseViewController.h'
and the solution was
1.build and run project and go-to Report Navigator
2.look at the warning, click to expand details
it will so you the file name where you need to make change
as you can seen in below screen shot
So i just updated my import statement in AppDelegate.m file
New
#import "HockeySDK/HockeySDK.h"
Old
#import <HockeySDK/HockeySDK.h>
and issue gone..
hope this will help someone. who are coming here for solution.
For me the solution was as follows:
1) Each Objective C framework has 1 header file that contains all the:
#import ...
#import ...
#import ...
2) Make sure that this file imports the missing header.
3) Build the project again, it should remove the warning.
Alternatively, you may have exposed files within the Public area of your framework's build phases that should actually be moved back to the Project area.
If you don't want those files to be within your framework's umbrella header so they're publicly accessible, you can revert this.
Goto Framework -> Target -> Build Phases and drag to move the unnecessary header files from Public to Project.
Just for completeness if your header is set to public in :
Build Phases > Headers
You should either
Include the import in your main header as others have mentioned
OR
Move that header to "private" if it doesn't need to be exposed
We got this recently and it was due to corruption in DerivedData. Deleting that folder fixed the problem.
For others :
In my case I already move the headers I want to expose from my framework, from "project" to "public" (Build phases of the framework target)
Then Xcode gave my this warning.
Xcode is telling us that we also need to add #import "name of header in the warning> in the public header file that was created with framework, so the clients (of the framework) will know this header.
So The Fix:
1.go to the framework public header file.(the one what created by xcode when you created the framework) .
2. add #import "the-name-of-the-header-in-the-warning.h"
In my case (Obj-c framework):
Umbrella header for module 'opus' does not include header 'opus_multistream.h'
I needed to change:
#import opus.opus_defines;
into
#import opus;
(I don't have in #import "....h" or #import <....h> for frameworks)
Take a look at this post:
#import vs #import - iOS 7
It goes over the concepts of the new module importing.
I had my own custom framework and after adopting the new method to import objective-c framework
old:
#import <MyFramework/MyFramework.h>
new:
#import MyFramework;
it took care of the warning/
Deleting DerivedData did the trick for me. Try running the below command and see if it works.
rm -rf ~/Library/Developer/Xcode/DerivedData
trying to fix a archive build error led me to this error and post
my solution was real simple but took forever for me to figure out.
when i ran $ pod install it generated a workspace for me in the same dir as my .xcodeproj file.
however i had already created a workspace to use as its parent directory.
so then i simply deleted my old workspace and went with the one that pods created
hope this helps someone!
glhf!
For me the fix was rather simple, commit all your changes and build again. The warning disappeared.
I have downloaded the Dropbox API for Objective-C/iOS devices, and I am able to successfully build and run the DBRoulette application.
When I follow the README directions for including the API in my project, I have an enormous number of build errors, all appearing to be related to missing the Foundation header. (Eg. Can't find the interface declaration for NSObject, NSString, etc.)
Many of their header files don't include any other headers at all. Don't all .h files need to import Foundation.h if they extend NSObject? This doesn't seem to be the case, as the example project (DBRoulette) builds and runs fine without the Foundation header declarations, but my own application fails miserably.
I must be missing some sort of project setting, but I can't determine what it is.
Screenshot of One Failing Class
In their example app, they have
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
in their prefix header file (DBRoulette_Prefix.pch). This file is automatically prefixed to all source files in the project, so the appropriate headers are found. You can either put the #import directives in the source files themselves, or do what they did and edit the .pch file for your project.