Prefix.pch not included at compilation time - ios

I have defined many constants in GlobalVar.h and other .h files. I import these files in the Prefix.pch file like this :
//
// Prefix header for all source files of the 'XXX' target in the 'XXX' project
//
#import "GlobalVar.h"
[...]
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iPhone SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#endif
But when I compile the project all the #defined identifiers are missing and reported as "Use of undeclared identifier XXX".
I searched in the Build settings and the PCH file is set as "Prefix Header"... I am on Base SDK 4.3 and XCode 4.0.2
Do you have hints to debug this ?
Thanks for your help

I came across this error yet, after cleaning DerivedData and restart Xcode I fix it. Hope to help.

move your import to like so
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "GlobalVar.h"
#endif

Related

I have a ios project in objective-c i got some errors like PubNub/PubNub.h' file not found and more files

I have a ios project in objective-c i got some errors like PubNub/PubNub.h' file not found and more files
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import "LoadingViewClass.h"
#import <PubNub/PubNub.h>
#import "BaseTabController.h"
#import "Constants.h"
#import "Reachability.h"
i have this all file but i got this error and i am new in ios development
thanks for help

PFFacebookUtils.h (1.7.1) imports non-existent FacebookSDK.h

I've installed the Parse and Facebook iOS SDKs for my project in Xcode. My project is written in Swift so I have the following in my bridging header:
#import <Parse/Parse.h>
#import <ParseUI/ParseUI.h>
#import <ParseCrashReporting/ParseCrashReporting.h>
#import <Intercom/Intercom.h>
#import <ParseFacebookUtils/PFFacebookUtils.h>
When I build the app, I get 2 errors:
error: 'FacebookSDK/FacebookSDK.h' file not found
error: failed to import bridging header '/Users/ben/AppFolder/MyApp/Bridging-Header.h'
The bridging header is at the directory as shown, so it seems that is dependent on the first error. FacebookSDK.h is in an #import statement at the top of PFFacebookUtils.h:
#import <Foundation/Foundation.h>
#import <FacebookSDK/FacebookSDK.h>
#import <Parse/PFConstants.h>
#import <Parse/PFNullability.h>
#import <Parse/PFUser.h>
FacebookSDK.h does not exist in either the Parse iOS SDK 1.7.1 or the Facebook SDK (presumably 4.0.1) from Facebook's Getting Started page, though I know that FacebookSDK.h was in previous versions.
I tried the approved answer from this SO question without success. Do I need to add something to my bridging header? Should I change the import statement for FacebookSDK.h to reference a different file? Other ideas on how to fix this?
Instead of
#import <ParseFacebookUtils/PFFacebookUtils.h>
use :
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>
Make sure to add that V4

Conditional compiling of Objective-C in a Swift project

I have an Objective-C category that I've been using for a while for both iOS and OSX projects and I want to use it in a Swift project as-is...until I have the time to translate it to Swift.
Here's the top of my category's .h file:
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif
I've included it in the bridging header, but when I build the project for iOS, I get an error saying that it can't find the file Cocoa/Cocoa.h.
Why is it even looking for it? Doesn't the conditional compile still work even in a Swift project? It's still compiling an Objective-C file.
Thanks.
Add #import "TargetConditionals.h" in your source file.
#import "TargetConditionals.h"
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif
Or add "-DTARGET_OS_IPHONE" to the "Other C Flags" section of the target build options.

AFNetworking Clang Error with Exit code 254 - Xcode 4.6.2

I am trying to use AFNetworking with Xcode 4.6.2 in my projects. I have added the AFNetworking to my project. I have also added 'SystemConfiguration' and 'MobileCoreServices' framework to the project. I have included the framework header files in the .pch file like below
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "AFNetworking.h"
#import <SystemConfiguration/SystemConfiguration.h>
#import <MobileCoreServices/MobileCoreServices.h>
When I try to run the project, I get Clang error from file AFHTTPClient as follows
Command/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 254
Ok , I solved the problem. The issue was with order of import statements in .pch file
I changed the order to as follows basically added 'AFNetworking.h' after import statements for and frameworks.
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <MobileCoreServices/MobileCoreServices.h>
#import "AFNetworking.h"
Also another tip. You also need to add 'Security' framework for AFNetworking to work smoothly. Thanks

Failing to import c-file in objective-c

I'm currently trying to compile my project just after adding some C code.
I'm using the Paul Kocher's blowfish algorithm implementation available on Bruce Schneier's website.
Since I included blowfish.c & blowfish.h in my workspace, my compiler is running crazy. Like if it did not recognize Objective-c code, pointing errors on NSObject class!
I tried to .mm the calling class but the problem stays.
Each answer found on SO talks about including C++ file, but it's not my pb...
Maybe a compiler directive that i'v missed ?
Most likely, what is happening is that the compilation of blowfish.c is using your previously established precompiled header (.pch) file, and that is including an Objective-C framework. Just disable the precompiled header and you should be OK. You might be able to conditionalize those frameworks, but personally, I find precompiled headers more trouble than they’re worth.
Thanks to microtherion, I found the problem.
My .pch file was declared as :
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
#import "AppDelegate.h"
#import "UINavigationController+Rotation.h"
#import "Categories.h"
The 3 last #import'ed files are objective-C.
I've just changed the #endif place to:
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "AppDelegate.h"
#import "UINavigationController+Rotation.h"
#import "Categories.h"
#endif

Resources