I'm looking to create a precompiled header file, to avoid having to include the same debug and tracking libraries in every header in the project.
I've created a file called -Prefix.pch:
#ifdef __OBJC__
#import "Blah.h"
#import "Blarg.h"
#endif
and added it to the project. Is there anything more I'm supposed to do, or should things just work now (assuming I do a project clean and recompile)?
Set the target's build settings as follows:
GCC_PRECOMPILE_PREFIX_HEADER=YES
GCC_PREFIX_HEADER="Prefix.pch"
Note that you can plop these keys in the Build Settings search field, if you prefer to use Xcode's UI for your build settings.
I got this error in my flutter app when using the library flutter_inappwebview and tried to set deployment version of ios in Runner > General to 12.0.
I set it back to 11.4 and it built with no problems.
Related
Having problems importing diff class, in Xcode 10. This doesn't occur in their previews version. Any Suggestion to fix this?
Based on Xcode release notes you have to use include syntax.
The legacy header map that was generated when the Always Search User
Paths (ALWAYS_SEARCH_USER_PATHS) setting was YES is not supported by
the new build system. Instead, set ALWAYS_SEARCH_USER_PATHS to NO and
migrate to using modern header include syntax. Add any needed header
files that are in the project repository to the Xcode project to
ensure they are available for use in #include (via the project wide
header map). Use quote-style include ("foo.h") for project headers,
and reserve angle-bracket include () for system headers.
For example:
#import <SystemFile/SystermFile.h>
#import "ProjectFile.h"
I'm struggeling with Modules in a project. Where I use #import I get "Use of '#import' when modules are disabled". But why are they disabled?
In my build settings I have "Enable modules (C and Objective-C)" set to Yes for all targets.
Setting "Link Frameworks Automatically" to Yes or No does not impact this (compile-time) error
Although the project used to have Objective-C++ and some C++ code, it doesn't anymore. Are there any project-settings I can have missed that were set because of this?
I have no more .pch files in the project, and the build settings have no mention of them
I use CocoaPods (0.39.0) with "use_frameworks!" and the modules I wish #import are from there. But the same error happens if I replace the '#import ' or '#import ' with '#import Foundation;' and '#import UIKit', so I expect this is not related
The project is from pre-iOS7 so I might have missed a setting that used to be on by default
The project requires iOS 8 and builds against iOS 9.2.
I realize that loading third-party modules will probably slow down the apps loading time. I'm converting to CocoaPods with use_frameworks! so that I can measure by how much. If it's not too bad, I'd like to use as I'm planning to move multiple swift-only parts of the codebase into their own frameworks (as open source coocapods)
I believe that this is not be a duplicate of other questions on SO since I've gone through the ones I found (big thank-you to this one), followed the links, re-watched WWDC'13 session 404, and read the related posts on Apples forums, so I believe I've done my homework. :-)
In my project I have a bridging header to bridge from ObjC to Swift, and there is a generated header file to bridge from Swift to ObjC. It turns out that if the bridging header referenced headers where the implementation file referenced the bridge file from Swift to ObjC, module support is disabled. So be careful about what you put in your bridging file, and be careful about when you import the generated -Swift.h file.
Firstly go to the terminal and type xcode-select -p. It should say, /Applications/Xcode.app/Contents/Developer. If it doesn't, then type, sudo xcode-select -s /Applications/Xcode.app and hit enter and type in your password.
If that doesn't fix it, try deleting your project's derived data directory. Go to the Projects view and delete the derived data for your project. Then clean your build folder (command-shift-K). Run Analyze (command-shift-B) and resolve any issues in blue and yellow.
Now if #import is still not working, create a brand new XCode project. Verify that #import works in it. If it doesn't, then your XCode installation got screwed up probably, or your HDD is dying. Delete XCode and re-download it, see if that works. Restart into the recovery partition and see if you have some disk issues (unlikely, but hey).
If #import works in the new project, try taking all your from your current project and copying them into the new project. Make sure you have the latest version of cocoapods and then freshly install your pods into the new project.
If all of that doesn't fix it, you probably left an #end statement out somewhere or have a missing } ...
I have some compiler warnings in my app which I do not understand:
I have installed Mailgun and AFNetworking using cocoapods. My main project has SystemConfiguration and MobileCoreServices frameworks imported however I still get these issues.
These warnings are unnecessary and my app works perfectly regardless!
How would I go about removing these?
AFNetworking required to link SystemConfiguration.framework and MobileCoreService.framework and import them in you *.pch file.
To do that, go into your target's settings -> Build Phases tab -> Link Binary With Libraries
Click on "+" button and choose those two frameworks (SystemConfiguration and MobileCoreService).
After, open your [Project name]-Prefix.pch file (by default its in Supporting Files group folder) and add
#import <SystemConfiguration/SystemConfiguration.h>
#import <MobileCoreServices/MobileCoreServices.h>
IMNPORTANT NOTE
In case if you installed from pods, then you must import those also in 2 places:
1. Pods->AFNetworking->Supporting Files->Pods-AFNetworking-prefix.pch
2. Pods->maligun->Supporting Files->Pods-mailgun-prefix
AFNetworking library wantedly kept #Warning flag for showing the warning. That you need not worry about. Still you want to suppress warning go to your project build phase > Compile sources > click on File that's showing warning > add -w to it. Now build your application. But in general we don't need to worry about warning that are there in library.
Please note suppressing warnings is not a good practice,
Just linking frameworks, will not help, you need to import them in <project>.pch file
(Please note: not all in all Pod dependencies!, only in your project's pch file)
Here is a small guide to resolve this issue!
1) Open your <project>.pch file (that's the precompiled header file)
2) Make sure you have imported the frameworks
#import <SystemConfiguration/SystemConfiguration.h>
#import <MobileCoreServices/MobileCoreServices.h>
There is a library that causes build errors when the project builds for the simulator.
Is there a way to set a flag in the build settings or somewhere else to make the compiler NOT link the specific library when building for the simulator?
This could be done by creating a new Target, but I would prefer not having to create a whole new target.
What would be the most convenient solution for something like this? (which works both in XCode 4 and 5)
You can #ifdef out the #import calls to the library using:
#ifdef TARGET_IPHONE_SIMULATOR
#import <...>
#endif
If you do that then the code won't try to link with the library.
Here the problem: For a project at work we need to include an extern API: mobileAppTrackeriOS from HasOffers.
It gives us a framework to include in our projet and instruction to enter in our code.
So I copy the framework in the project directory and drag it into xcode to include it.
But when i want to use it with:
#import <framework/mainheader.h>
The build give me an error :
Lexical or Processor issue 'MobileAppTrackeriOS_arc/MobileAppTracker.h' file not found
I check the framework search path in my target build setting, my main directory where is the framework is here.
I test with "" instead of <> same issue...
i cleaned and rebuilt, try to include directly the header... many ridiculous things... no changes.
So what I forget?
I'm on Xcode 4.5 and develop for iOS 6.0.
A question, can you see if the framework is in Build Phases -> Link binary with Libraries?
If answer is not, you must add in this section.