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>
Related
I am currently working on an old source code of objective C, I am using Xcode11 and set the base target as iOS10.
Project is running fine but when I am trying to build it I am getting these errors:-
Unknown type for NS_ASSUME_NONNULL_BEGIN and FOUNDATION_EXPORT.
I tried importing Foundation in pch file but still same error.
Can anyone help me out on this.
Update: framework compiler flag settings
Here is project's pch file
Thanks
FWIW in my project I have Precompile Prefix Header set to no as in the image.
Other settings that may help - in 'Other Linker Flags' I also have
-framework "Foundation"
I hope you can get it right, here are two more things to try.
Force it by adding
FOUNDATION_EXPORT=extern NS_ASSUME_NONNULL_BEGIN= NS_ASSUME_NONNULL_END=
to your preprocessor macros.
Since Foundation is included in the project and given that it is so old, maybe there are places (source files) where you need to add
#import <Foundation/Foundation.h>
to a header file to get it to work.
After spending around 2 days, I found that there was nothing wrong in my source code or build setting, it was due to the disk space on my Mac.
If you are also facing this issue, you can try below things
Check the available disk space, or try building another project, make some room for project to build by cleaning up some space. I clear space with clean my Mac https://macpaw.com/cleanmymac
If you have pch file, cross check you if include foundation and UIKit framework and also check for pch prefix header path in build setting.This link may help
https://useyourloaf.com/blog/modules-and-precompiled-headers/
Check your project target, foundation framework should be added there.
Hope these steps help you.
Trying to install SDWebImage into my Swift project. I am using the following instructions (https://github.com/rs/SDWebImage):
Download and unzip the last version of the framework from the download page
Right-click on the project navigator and select "Add Files to "Your Project":
In the dialog, select SDWebImage.framework:
Check the "Copy items into destination group's folder (if needed)" checkbox
So I git clone --recursive the project from GitHub, I drag the .xcodeproj file into my project (since there is no SDWebImage.framework file as far as I can tell, and this has always worked for other frameworks), I complete the rest of the instructions:
In you application project app’s target settings, find the "Build Phases" section and open the "Link Binary With Libraries" block
Click the "+" button again and select the "ImageIO.framework", this is needed by the progressive download feature:
Add Linker Flag
Open the "Build Settings" tab, in the "Linking" section, locate the "Other Linker Flags" setting and add the "-ObjC" flag
And then I add #import <SDWebImage/UIImageView+WebCache.h> in my bridging header. I build the project and I get: "SDWebImage/UIImageView+WebCache.h" not found. I've tried some variations on these steps and nothing seems to work. What am I doing wrong?
EDIT
Pretty sure this is happening because I'm not pulling in an SDWebImage.framework file, rather the .xcodeproj file. But I've downloaded from zip and cloned the repo, and there doesn't seem to be a .framework file in there...
UPDATE
So apparently I'm just supposed to download the compiled framework, which I found in another answer: https://stackoverflow.com/a/30545367/918065. Maybe? I have no clue. When I imported the .framework file my bridging header worked and recognized #import <SDWebImage/UIImageView+WebCache.h>, but it didn't recognize imageView.sd_.... So still workin on it.
Last compiled framework is 3.7.0 and you can find it in: https://github.com/rs/SDWebImage/releases
For easier access, the direct link to the framework is below: https://github.com/rs/SDWebImage/releases/download/3.6/SDWebImage-3.6.framework.zip
import "SDWebImage/UIImageView+WebCache.h"
For me it helped when I remove SDWebImage from import. So I have this in my project-Bridging-Header.h:
#import "UIImageView+WebCache.h"
more information about iOS bridging header:
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html
I recommend using CocoaPods for dealing with dependencies.
CocoaPods is a dependency manager that is designed to solve problems like these.
Follow the installation guide on their website: https://cocoapods.org
So nothing was working for me until I finally realized that you're supposed to use not the main SDWebImage folder, but the SDWebImage folder inside of that into the project. Dragging in the .xcodeproj file, the folder as a whole, or the .framework file didn't work. Importing that sub SDWebImage folder, and then utilizing Libor Zapletal's answer: #import "UIImageView+WebCache.h" is what finally got this thing working for me.
This worked in my case:
Add #import <SDWebImage/UIImageView+WebCache.h> in your bridging header
In project Build Settings, set the path of the bridging header file in Objective-C Bridging Header. Ex. My Project/BridgingHeader.h
I have a project that uses CocoaPods and uses the 'SCLAlertView-Objective-C' pod. That pod uses the #import UIKit; module style import. I've set "Enable Modules (C & Objective-C)" and the "Link Frameworks Automatically" to YES in both my target and project settings. I am still getting the "Use of '#import' when modules are disabled" error.
Is there anything that could prevent Xcode from being able to enable Modules such as the use of a .pch file, any linker flags, or anything else I haven't mentioned? I also tried to clean the project and the project build folder. That didn't have any effect.
Also worth noting is that my project has multiple targets and also has a deployment target of iOS 7.0. My Base SDK is set to iOS 8.3.
I guess your project contains XXX.mm files, however, the xcode only enable C and objective-c modules.
Please have a look at this answer for your reference:
Using #import in objective C in conjunction with __cplusplus
my solution is modify the #import xxx into #import .
Good luck.
I just solved this in a primarily ObjC++ project I was working on that needed to use Firebase.
Simply make a ObjC (.m) file which contains the following.
#import <Foundation/Foundation.h>
#import Firebase; // << swap this for your specific import
That's it, then simply use #include in your .mm files for the specific headers you need. For me that meant:
#include <"Firebase/Firebase.h">
#include <"FirebaseAuth/FirebaseAuth.h">
Just to stress the point, no amount of fiddling with link options made any difference to this "Enable Modules (C & Objective-C)" was already YES. Upgrading to XCode7 didn't seem to help.
Hope this helps someone :)
The build option does not really work as it should. I've solved this problem by adding -fcxx-modules (Objective C++) or -fmodules (Objective C) manually to "C Flags"/"C++ Flags".
Worked for me.
xcode will not compile a FRESH project with only libxml2 and its requirements installed. it returns this error every time.
http://puu.sh/bYc7D/b37d7c6e99.png
I do not know how to resolve this, has anyone had this before?
Most of the standard project templates include a prefix header called project_name-Prefix.pch (and a reference to it in build settings, search for 'prefix').
Since most classes use the Foundation library, including Foundation.h in that header is a good idea. Also make sure that Foundation.framework is included under "Build Phases" -> "Link Binary With Libraries".
If your project isn't setup that way, it might be useful to create a new project using the most basic template (like Single View), observe how its setup and do the same things to your project.
Looks like Foundation isn't imported. Do you have anything in your prefix header file?
Regardless, try importing it into your header:
#import <Foundation/Foundation.h>
Or alternatively if you use modules:
#import Foundation;
Import Fondation? I don't see it at the top of the file.
I have a small prefix header file
#ifndef UP_FOR_IT_PrefixHeader_pch
#define UP_FOR_IT_PrefixHeader_pch
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <Parse/Parse.h>
#import "ABConstants.h"
#import "ABCache.h"
#endif
#endif
it can't find Parse.h. I linked it from Link binary with libraries everything seems right but whatever I tried it does't compile. I tried removing the lib and import again but nothing changed. Removed indexes on derived data but still no clue.
What should I try? It took 2 hours and still not working.
Xcode 6. IOS 8
Goto Build Settings > Apple LLVM 6.0 - Language > Prefix Header
Add here: $(SRCROOT)/PrefixHeader.pch
If $(SRCROOT) not working for you, set the value of 'Prefix Header' to your PCH file name, with the project name - i.e. for project named 'Test-Project' and PCH file named 'Test-Project-Prefix.pch' and add the complete string 'Test-Project/Test-Project-Prefix.pch'
Select your project (named "Project" for example) and click on "ProjectTests" (in TARGETS section).
Then, go to Build Phases > Link Binary With Libraries and add Parse.framework
Just in case rest of the answers doesn't work for someone. Try changing Under "Target Membership", the scope of your targets from public to project. Hopefully it helps.
If you are using cocoapods, you may checkout this link.
I got this problem but none of the solution above worked for me.
I'm using cocoapods, the reason is that in the Podfile I only linked pods to default target. If you are going to add another one, you should add another target configuration in Podfile(target:'target' do). Usually the new one is the same to the original one, you could use link_with to make life easier.
But life is not always that easy. It looks like that link_with is deprecated. You may checkout this link.