Why is my simple objective c bridging header failing to find the file "BraintreeCore.h"? - objective-c

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.

Related

How to properly add System Header Search Paths in Xcode

I'm having a problem getting the 'System Header Search Paths' in build settings to work in Xcode and allow me to use #import <Core/CoreBlocks.h> rather than a local copy and #import "CoreBlocks.h"
First I need to "frame" the problem.
I have built a framework that I use across many if not all my projects. This is Core.framework . Inside the framework is the requisite "Headers" directory and within that 40 other headers, all of which are included in the 41'st header Core.h
I drop the Core.framework into another project and the other project headers or source files then import:
#import <Core/Core.h>
and get all the functionality of the 40 modules in the framework. Works fine.
BUT, what I need is a simple way to run the 40 modules of Core.framework outside the framework construct, as a separate build or project, with just the source and breakpoints, so I can debug and enhance it.
I try to define the framework's source directory as a search path for the other project:
yet the compiler complains about the inability to find the headers in the source code:
is all I get for all of the imports even though they all reside in the lower Core directory below that path:
~/Development/Projects/Core/Core/Core/NSRange+Core.h
And that's where I'm at a loss. What am I doing wrong?
Found out why... Xcode for some reason can't use the *nix home directory notation in a pathname.
In other words while:
~/Development/Projects/Core/Core
does not work, the expanded equivalent:
/Users/BC/Development/Projects/Core/Core
does work in the Xcode system header search paths, yet it is not obvious as to why...

Failed to import bridging header swift Xcode 8.2.1

Trying to use the Google Sign In API and I get this error consistently.
GGLCore/GGLCore.h' file not found
#import <GGLCore/GGLCore.h>
<unknown>:0: error: failed to import bridging header
I have looked around for solutions but nothing has seemed to work. I checked all of the search paths and it looks good. Also my bridging file is definitely linked in the settings. I have also tried cleaning and updating cocoapods.
Bridging Header:
#import <Google/SignIn.h>
#import <OneSignal/OneSignal.h>
Podfile:
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target "Sell Goods" do
pod 'Firebase/Core'
pod 'Firebase/Storage'
pod 'Firebase/Database'
pod 'Google/SignIn'
pod 'Fabric'
pod 'Crashlytics'
pod 'JSQMessagesViewController'
pod 'OneSignal'
pod 'TextFieldEffects'
end
A possible cause for this would be that the Bridging Header is not properly connected to your project.
Solution 1:
I strongly recommend deleting your current Bridging Header and then go to File -> New File -> Objective-C Source File(.m). When you create the file it will ask you if it should create a new Bridging Header. Click Create. After that, put your #import statements in the new header, and delete the .m file, which is unnecessary. Then, you're good to go.
Solution 2:
To check if your Bridging Header is connected properly to your project, go to Project -> Build Settings -> Swift Compiler - General. There, you will have the option Objective-C Bridging Header.
The value of Objective-C Bridging Header should be:
YourProjectName/YourProjectName-Bridging-Header.h as shown in the image below:
Please note that your Install Objective-C Compatibility Header must be set to YES. If the name of your Objective-C Bridging Header is not set as described above, please do that manually.
Let me know if this helps!
I had a nearly identical problem, it arose after adding a build configuration, scheme, info.plist attribute, and a couple unused classes. (Not sure which caused the problem).
I did 2 things, not sure which fixed it for me.
1) ran pod update from the project root directory
2) cleaned the project (Top menu bar, Product -> Clean)
Then the project ran with no errors.
I had the same issue and it was resolved by going to Framework Search Paths and ensuring all of the values were in quotes " ". Hope this helps someone!

umbrella header for module 'myFramework' does not include header 'otherFramework.h'

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.

Using SBYZipArchive or other Zip Cocoa Pod in Swift not working

I have an OSX app that needs to be able to zip and unzip directories, and I figured it would be easy using a cocoapod. I've hit a brick wall.
I've installed Godzippa, Objective-Zip, zipzap, ZipKit, ZipArchive, SSZipArchive, and basically every other cocoapod that claims to provide "Zip" functionality, but I've failed to get any of them to work.
I'll share the steps to my failure, and perhaps someone will correct me where I've strayed the correct path:
1. Because I am working out of a Swift codebase, I created an Objective-C-Bridging Header, and set the corresponding attribute under Build Settings in the Swift Compiler Section.
2. I installed cocoapods in the application and included the desired cocoa pod in the Pod file, ran pod install, and restarted the application using the workspace.
3. Inside the bridging header, I imported the necessary objective-c headers of the corresponding cocoa-pod so I can use them in Swift. For example, for SBYZipArchive I had the following in my file I imported the < SBYZipArchive/SBYZipArchive.h> header.
4. I try to build the application and it fails on multiple places all referencing the zlib.h library.
5. I attempted to provide access to the zlib library by adding the libz.dylib to the Build Phases under Link Binary with Libraries.
6. I attempt to build the application, and it still doesn't love me.
To my knowledge the reason why none of these frameworks is working is because they are for some reason failing to access the zlib files that are necessary to do the actual data compression. Thats as far as I've figured out... Any help would be appreciated.
Update
I was able to do the zipping without using any of the above packages by simply setting up an NSTask. For those who may care more about zipping than they do using these tools here is how I did it:
var task = NSTask()
task.launchPath = "/usr/bin/zip"
task.arguments = ["-r", "/Users/$USERNAME/Documents/$PATHTODIR/zip1.zip", "/Users/$USERNAME/Documents/$PATHTODIR/filesToZip"]
task.launch()
When using NSTask you set the launch path to the tool you want to use, and then give the required arguments. so the above task is the equivalent to the command in UNIX:
zip -r /Users/$USERNAME/Documents/$PATHTODIR/zip1.zip /Users/$USERNAME/Documents/$PATHTODIR/filesToZip
Obviously swap out the variables I put in there for your own path
UPDATE
Although the UNIX zipper works perfect for the mac app, I am pretty sure I need one of the zip packages to be able to do this on iOS

"Installing" CoreAudio headers on Mac OSX

I've been at this for a few days now and I can safely say I'm stumped and haven't made progress on my own. I'm attempting to compile a project included in the XCode documentation (SinSynth) but every time I attempt to build it, I get errors upon errors about missing header files. "Okay," I thought enthusiastically, "Take a deep breath and let's use this as an opportunity to better learn XCode."
I looked at the paths the compiler told me it was looking for the headers in, added them, and then got more warnings because files needed to reference one another in the same folder (This files were not the missing header files - they were other files included that had definitions and what looked like boiler plate code). At this point I was a bit confused as to why the headers weren't installed in the first place. I uninstalled and reinstalled XCode but still had the same errors.
My question is where do I need to put the header files and cpp files included in the Audio Tools for Mac download? This is my first time having to break open XCode and add content, and thus far I've found no newbie-friendly tutorials to help me with this. To say it bluntly, I'm confused! What should I do?