After I updated my Xcode toXcode 8.
I found out that if I import vendor framework header files in .pch file. there will be a error. 'xxx' .h file not Found
Such as:
I want to import a framework named Umeng's header file.
So I write the codes below to my XXX-prefix.pch
#import <UMMobClick/MobClick.h>
But Error UMMobClick/MobClick.h file not found appeared.
Any constriction of Xcode that prohibit importing vendor framework header files in .pch file?
I had a similar problem with a legacy Xcode project that used a .pch file -- the file was being ignored.
The fix was in build settings, where the original path to this file assumed it began at the project root:
SharkAlert/SharkAlert-Prefix.pch
Xcode 8 apparently requires an explicit reference to the starting point
$(SRCROOT)/SharkAlert/SharkAlert-Prefix.pch
Now the project builds as expected.
If this file you are used to bridge OC and Swift,now you should creat a new .header file and Move All Header file Name inside file
I had a similar issue. Changing #import <Framework/Framework.h> to #import Framework; fixed it for me.
Related
I updated to Xcode 8.3 and Swift 3.1 and got this warning in my bridging header file, referencing to an Objective-C header file:
Non-portable path to file "File.h"; specified path differs in case from file name on disk
How can I resolve this?
It turned out that I misspelled the file's name, the correct name was "FILE.h" instead of "File.h". The warning appeared because of the soon coming APFS to macOS.
In my case, the !!project folder name!! isn't match the bridging header path.
I changed
"project/project-Bridging-Header.h"
to
"Project/project-Bridging-Header.h"
Tested on Xcode 9.3
One additional cause, that I experienced, was that a library project was importing itself incorrectly. For example, given projects Main and Library, Main would import Library with:
#import "Library/Library.h"
If Library attempts to use the same import, the Non-portable path warning will appear. Removing the path portion is the easy fix:
#import "Library.h"
The better fix is to import the specific components that Library needs from itself:
#import "Widget.h"
#import "NSString+Library.h"
Encountered the problem in Qt (C++) on a MacOS computer from a code developed and working on Ubuntu.
My project had two files : server.cpp and Server.cpp.
The solution was to change the name of one file or the other.
I have recently added a Swift file to my Objective-C only project. Xcode created the necessary header files, including the Objective-C Generated Interface Header. Everything works fine if I #import this header file "myProject-Swift.h" to the .m file where I am accessing the Swift class I have added.
However I will want to eventually use this Swift class throughout my project, and to avoid importing it every single time, I wanted to add this myProject-Swift.h import file to my .pch prefix file.
However when I try to build my app after having added this, I get a 'myProject-Swift.h' file not found error and the build fails.
Does this mean it is not possible to import this myProject-Swift.h in a .pch file?
Is it really only possible to do it in each .m file individually?
I am getting an error that it can not find the header file, but I have added the file via "link binary with library" under Build Phases.
The file is WhirlyGlobeComponent.h
and I imported... #import "WhirlyGlobeComponent.h" and it said that the file can not be found.
What could I doing wrong. I have already cleaned the project.
Just drag and drop the .h and the .m file into your swift project. Then Xcode should create a Briding-Header.h file for you. In there you have to add the .h file:
#import "WhirlyGlobeComponent.h"
After that, you should be able to use the WhirlyGlobeComponent without any additional imports in your swift files.
I'm trying to integrate UrbanAirShip in my application following these steps .
This is what i've done:
1) I've Unziped the framework in the Project folder so that I have the Airship folder at the same level of other file of my project.
2) I've added the path ./Airship/** to my Header search Paths.
I've also tried with ../Airship/** but it doesn't work.
3) I try to include the right headers
#import "UAirship.h"
#import "UAConfig.h"
#import "UAPush.h"
But xcode complains... saying 'UAirship.h' file not found.
What I'm doing wrong? Have I to include the files into the project?
Neither ./ or ../ worked for me in the Header Search Paths. I ended up using this:
$(PROJECT_DIR)/Airship
Airship folder is in same level as the project.
You mistyped the path to add in the Header Search Paths (forgot one ".") :
./Airship/**
Should be :
../Airship/**
Did you do the following step:
Link against the static library.
Add the libUAirship.a file to the “Link Binary With Libraries” section in the Build Phases tab for your target.
May not be applicable all of two years later, but I encountered a very similar problem today and solved it by using the CocoaPods version of the framework found here:
https://cocoapods.org/pods/UrbanAirship-iOS-SDK
After running pod install, I added the following paths to my Header Search Paths under target project > build settings:
It seemed redundant to me to add both paths, but without the subfolders at /** the AirshipLib.h file wasn't able to locate its dependancies, and without the main folder my Bridging-Header.h file wasn't able to locate AirshipLib.h
Luckily enough I'm using some old Objective-C files from our codebase and incorporating them into a new Swift app, so I already had a Bridging-Header.h file, but if you needed to create one you can find instructions here:
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html
Finally, I added the following to my Bridging-Header.h file:
#import "AirshipLib.h"
No issues on build and everything from the framework can be easily referenced directly in my files.
I've an iOS project, with cocoapods for external libraries management.
When I try to import an header file from that, instead of the right library, Xcode imports the file (with the same name) from another project/folder.
Furthermore the file is different.
If I want to reference to the right header I must write the absolute path
#import "Pods/CHCSVParser/CHCSVParser/CHCSVParser.h"
Why?