How to properly add System Header Search Paths in Xcode - objective-c

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...

Related

Why are some .h files missing when compiling wbrtc_ios as a framework?

I am new to WebRTC stuff. I cloned the webrtc_ios main branch, and I built the framework as instructed here with the python script for arm64. When I add this to my Xcode project as a framework, everything is fine. Project builds, I can import files using <WebRTC/...> syntax.
However, I need to use RTCMTLRendeder.h file. Building a framework with python script leaves some of the header files out. (When I take a look at WebRTC.h inside the built framework, I can see that this file is missing) How can I include all header files that actually exist inside /webrtc_ios/src/sdk/objc/components folder while building the framework? I can see RTCMTLRenderer.h and .mm files are in that folder before using the build script. When turned into a framework those files don't exist inside the framework anymore. Why? And is there any other way to actually copy those files into the project as well?
Turns out you need to create your own, long renderer class which does not inherit from RTCMTLRenderer at all if you want to render on Metal view manually in a Swift/ObjC hybrid project (at least this is how I solved it). That class does whatever RTCMTLRenderer does, and grabs pixel buffers from RTCVideoTrack through an RTCVideoView.

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

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.

Xcode 6 Cocoa Touch Framework Project Can't Find Public Headers

I'm having major issues trying to get Xcode to find any public header files in my Cocoa Touch framework project in Xcode 6. I have a very explicit folder structure within my framework project directory that goes something like this:
APIKit -> DataModels -> User -> APIUser.h
The "DataModels" directory is where I put all of my model objects and every object subtype will have its own sub-directory within DataModels (e.g. like APIUser above). Importing the above file in my APIKit.h header file looks like the following:
#import <APIKit/DataModels/User/APIUser.h>
However, for whatever reason, Xcode cannot find that dang file! Looking at my list of public headers from the project settings shows that the directory I outlined above is 100% correct. Does this make sense to anyone?
Update: Even #import <UIKit/UIKit.h> can't be found in my APIKit.h header file -- crazy!
don't forget to link the binaries in Xcode under build phases or are you saying xCode cannot find them in link section.

header file not display in xcode project

I'am a newcomer to cocoa developement and i have not yet got used to.
When use eclipse for java development, we can see all the added jars source file if we attached the source files.
But in xcode, we add a framework such as "Cocoa.framework",there is only one Cocoa.h file we can see.
eg:
I clone the 'Sonora' source code from github for study.
there is one line
#import "SNRFileCopyManager.h"
exist in SNRFileImportOperation.h file
Both the SNRFileImportOperation.h and SNRFileCopyManager.h can be found in Sonora/Classes directory.
But, i can see the SNRFileImportOperation.h file in xcode project only and they get work fine together, Why this non third party header file not display in it's own project?
I know something about the dependency setting adn header search paths.
Any one give me a guidance or some references of the code management|organization?
Thanks a lot.
The file SNRFileCopyManager.h is found because it is in one of the include search paths. If you select a header file in Xcode and look at the info panel on the right side you can see that it doesn't actually belong to any target, they are shown more or less regardless. Though, building a framework you can select header files to be included into the framework when building. So, you can just pull in your header files into Xcode.

What should I do if I can't find the GPUImage.h header for the GPUImage framework?

I have created a sample application to perform bump distortion, using the GPUImage framework. I added this framework to my application, but I'm seeing the following error
Lexical or preprocessor issue 'GPUImage.h' file not found.
I have added the -ObjC flag to the Other Linker Flags, but I'm still seeing this error. How can I solve this problem and get my application to compile?
Adding GPUImage framework to XCode project could be tricky. So I haved added detailed step-by-step instructions w/ images on how to do it.
Static Compilation Method (detailed solution so we don't mess up)
This is Static compilation method. In this basically we will compile the framework using ./build.sh file. And simply add it to our XCode project, then configure XCode to properly use it.
Download GPUImage from Github and extract it (or just clone it).
Go to the GPUImagefolder in terminal
Run ./build.sh
Note: This will compile and create ready-to-use binary for all the sdks on your mac.
build.sh creates a folder called build and generates compiled binaries and dumps them to folders like: Release-iPhone, Release-iPhoneOS, Release-iphonesimulator etc folders.
For iPhone use Release-iphone (This also works for simulator).
Copy (not drag-drop) Release-iphone to your XCode project's root directory so that we have a local copy of framework.
Now iPhone drag-and-drop Release-iphone onto your XCode project. Make sure to check "Copy to .." option.
Note:
This Release-iphone folder contains two sub-folders: include and lib
include folder contains all the header .h files
lib folder contains compiled binary version file called libGPUImage.a
We now need to simply configure XCode to use .h and .a files.**
Select your project in the project explorer > Project name under Targets > select Build Phases > Expand Link Binary With Libraries
Add the libGPUImage.a to Link Binary With Libraries section. You may want to Right-click on libGPUImage.a then Open in Finder and finally drag-drop it.
While we are at it, also add the following GPUImage's dependent frameworks/ libraries
CoreMedia, CoreVideo, OpenGLES, AVFoundation, QuartzCore to Link Binary With Libraries section
Now, lets configure .h headers.
Select your project in the project explorer > Project name under Targets > select Build Settings > and type search paths to see search paths section.
Open Headers Search Paths by clicking on the value field.
Drag-and-drop the lib folder to that popup. Note: If it shows absolute path, change it to looks $(SRCROOT)/path/to/lib/. (You should have the framework relative to your xcode project see step 6).
Repeat 11 & 12 for Library Search Paths as well.
Additional tips: You can add .h files to Library Search Paths or Headers Search Paths, you can make them Recursive. I have a main root-folder called Dependencies folder where I keep all the dependencies like MySDK-framework including Release-iPhone. And I just have one search-path at the Dependencies (root folder) and made it recursive.
Did you follow all of the instructions from the Readme on the project page? From the installation instructions:
You'll also need to find the framework headers, so within your
project's build settings set the Header Search Paths to the relative
path from your application to the framework/ subdirectory within the
GPUImage source directory. Make this header search path recursive.
If you're seeing the above error, it means that you did not point the Header Search Paths at the right directory where you've installed GPUImage relative to your project, and / or did not click the checkbox to the left to make those search paths recursive.
I show some screenshots of where you need to go to set this in this answer, which explains something similar for the Core Plot framework. The same principles apply, only you need to find where you installed the GPUImage framework at.
I add relative path to "Header Search Paths", but there is still a error that is "not found".
Then, I add path to "User Header Search Paths", and it works.
May help you.
finally, I realized the KEY WORD is relativeļ¼
I put GPUImage source files in my project root dir:
before I solved the problem, I add Header Search Paths is:
$(PROJECT_DIR)/GPUImage/framework
$(PROJECT_DIR)/GPUImage/framework/iOS
and make them Recursive, but error is still there, So I changed Paths to:
GPUImage/framework and make it Recursive, then it works.
Hope it helps.