I'm getting a really confusing error, I've import a class with his header from other project, both files are exactly the same but in my new project is not working. Even when I try to replace isKindOfClass: by myself the method does not find any UIwhatever object. What am I missing?
You need to import:
#import <UIKit/UIKit.h>
Related
I want to use both Parse & facebook SDK's with my app, I did everything and added every library from both Parse & facebook and edited my App Delegate file according to the docs, but I keep getting errors in my bridging-header file:
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>
#import <FacebookSDK/FacebookSDK.h>
#import <Parse/Parse.h>
Error:
'FBSDKCoreKit/FBSDKCoreKit.h' file not found
The errors are not specific to any statement, I delete one and the next gets an error. This file is called "MyApp-Bridging-Header.h"
The first thing I would try is to add the AVFoundation and CoreLocation frameworks to your target. Then delete the derived data from your project by going to window-->projects. Do this then clean and build your project.
Sidenote: Make sure when you type in "#import " the FBSDKCoreKit is autofilled in after you have typed a few letters. If the framework has been added already, it should give you the option to autofill the import. If it is not added this may not show up, and if this is the case, make sure your framework is added to your project in finder.
Hope this helps!
I added a MyHeaders.h header file from 'c and c++' section of iOS in xcode to import all other .h files in it, like how OCMock.h is having like below. It just has those 5 imports ignoring comments.
#import "OCMockObject.h"
#import "OCMockRecorder.h"
#import "OCMConstraint.h"
#import "OCMArg.h"
#import "NSNotificationCenter+OCMAdditions.h"
When i tried to add sixth line with #import code completion is showing up with valid values. But when i tried to do the same on MyHeaders.h code completion is not helping. What i might have missed? Please asssist.
Figured out that it works as long as this .h file is imported somewhere. As soon as you remove that import it stops helping code completion to choose framework or .h in its own import.
Curious to understand why it is behaving this? If someone knew, please let me know.
In a project that I have added AFNetworking to I keep getting the build errors as in the image below.
I have tried the usual deleting the build/ folder and restarting xcode, removing and re-adding the framework, cleaning and building. I also tried adding the following code to my Project-Prefix.pch file:
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
//START - ADDING IMPORT FOR ALL TARGETS DUE TO AFNETWORKING
#import <Cocoa/Cocoa.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <MobileCoreServices/MobileCoreServices.h>
//END
#endif
But that doesn't seem to fix the issue either. I then tried removing AFNetworking from the project but it still gets this Lexical error when I try to build.
I've seen these compile errors before in XCode 4 and it was usually fixed by quitting xcode and deleting the build/ folder and then re-building the project. But this time it does not work.
I do not understand what the error refers to or how to fix it. It may not be caused by AFNetworking.
Can somebody help me figure this out?
Linker failed messages typically mean that you are missing some frameworks that your code references but that you have not added to the frameworks list.
You can add these frameworks in Xcode 5 by going to the File Navigator > Project > Build Phases > Link Binary with Libraries (then type in the missing library).
To fix this I had to edit the .pch file and add the following lines:
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <MobileCoreServices/MobileCoreServices.h>
#endif
There's no referenced to this in the error message that was displayed so it was confusing and took ages to figure out. Hope it helps point somebody else with similar issue in the correct direction to solve their issue.
I'm working on a 3rd party UIKit replacement for iOS. I have it building as a framework using a seriously helpful project from GitHub. (Not mine, but if you have interest, it's here.
I'm trying to use my library in other projects I'm writing. Like I said, it's basically a drop-in replacement for much of UIKit, so I decided to import the framework in my project's *.pch file instead of everywhere I might wish to use a button, action sheet, alert view, etc...
When I DON'T have an #import directive in a header file and declare a property of type MBMButton, the compiler gives me an error of "Unknown type name 'MBMButton'; did you mean 'UIButton'?" Oddly enough, the code will still run (even though this is an error, not a warning). Adding #class MBMButton or #import <MBMUIKit/MBMUIKit.h> resolves this compiler complaint.
When I DON'T have an #import directive in an implementation file (or its header) and call a method that exists in MBMUIButton but NOT in UIButton, I get a compiler error of "No visible #interface for 'UIButton' declares the selector...". As before, the code will actually run, since it's a valid call.
Now, I've done some digging, and I've changed my project's settings. Where I didn't have any value in the GCC_PREFIX_HEADER, I added the file name. Noting the Quick Help description by Apple, I tried both "ProjectName-Prefix.pch" and "./ProjectName-Prefix.pch". Neither seemed to resolve the problem. I eventually figured out that the Target-level settings override the Project-level settings, and that the Target-level settings already specified "ProjectName/ProjectName-Prefix.pch". So that was a dead end. (Nice to learn exactly what the relative path settings are, though!)
I'm OK with not using the *.pch file. It's only a convenience, and I can definitely use appropriate #class and #import directives. What's bugging me is not understanding the issue. How should one use the *.pch file?
The prefix header file is automatically included in every .m file in your project but not in any .h files.
Therefore, any references to classes will require the header to be included or a forward declaration:
#class MyClass;
However for #protocols you'll need the full header, a forward declaration won't work:
#protocol MyProtocol; //this won't work
#interface MyController : UIViewController <MyProtocol>
…
#end
I type in simply the following line:
NSManagedObject ...
But Xcode doesn't recognise NSManagedObject. I've never done this before and I'm following a Stanford tutorial, so I was hoping someone could point out where I might have gone wrong?
Have you included the CoreData framework in your project?
Have you a #import <CoreData/CoreData.h> in the file?