IOS: #import <AddressBook/AddressBookUI.h> file not found - iphone

I have included both frameworks and import header files. But xCode throws an error because of the missing AddressBookUI.h file.
#import "PersonViewController.h"
#import <AddressBook/AddressBook.h>
#import <AddressBook/AddressBookUI.h>
#interface PersonViewController () <UITextFieldDelegate, UIActionSheetDelegate>
{
}
Any advice?

AddressBookUI.h is in the AddressBookUI framework, not the AddressBook framework.
#import <AddressBookUI/AddressBookUI.h>

In your project explorer, select your project, then go to target>build phases>link binary with libraries and then add the library to your project, after that the import will work.

Related

Cannot find interface declaration for 'UIView' in iOS Swift Project

I have a swift project which I'm making use of MBProgressHUD in through a Bridging header file. The issue I'm having is that UIView doesn't appear to be recognised as type and I don't know why.
In my bridging header I have:
#import "MBProgressHUD.h"
The errors I get when I try to build are all along the same lines:
Cannot find interface declaration for 'UIView', superclass of MBProgressHUD.
I have checked the MBProgressHUD file and I can see that it definitely imports the following:
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>
#import "MBProgressHUD.h"
#import "CSNotificationView.h"
Has anyone else seen a similar issue? If so do you know what the issue is and how can I fix it?
I also come across the same issue and thats what i did to use MBProgressHud with swift 2
1) Specify use_frameworks! in your Podfile to use frameworks.
2) Add #import in your bridging header, use angle brackets instead of double quotes e.g -
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>
#import <MBProgressHUD/MBProgressHUD.h>
3) in your swift file also import MBProgressHUD e.g.
import UIKit
import MBProgressHUD
Now you can use MBProgressHud like -
MBProgressHUD.showHUDAddedTo(self.view, animated: true);
Hope it will help.
Remove your existing bridging header file and add a new one.
Make sure you are adding your bridging header path in SWIFT_OBJC_BRIDGING_HEADER under the target section instead of the project section.
You could also try adding a precompiled prefix header file (.pch) to your project. You'll find it under File/New/Other, there add the #import <UIKit/UIKit.h>clause, and then in the target's build settings, under Apple LLVM 7.0 - Language, set the Precompile Prefix Header flag to yes and add the .pch file like this "YourProjectName/YourProject-Prefix.pch".
See also this answer.
If you include the MBProgressHUD library with CocoaPods try to include a line similar to this
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>
#import "MBProgressHUD.h"
in
BridgeHeader.h and in Objective-C Bridging Header key in Build Settings choose the header.
For test if the library is correctly added I try to show a progress with this instruction in the ViewController:
MBProgressHUD.showHUDAddedTo(self.view, animated: true);
I tried it in a new project and it works.

How to prevent Liferay from prepending theme portlet path in my images in CSS

I developed a theme plugin in Liferay 6.2. In my css files, I use this to reference images:
background-image: url('../images/main_bck.jpg');
It works perfectly in my local machine, but after I deployed it on our staging server it is showing different path and so my images are not showing properly:
background-image: url("/express-portal-theme/css//express-portal-theme/css/../images/main_bck.jpg");
I've not yet found any solution in google. Please help.
Cheers!
Rio
Have you tried changing it to:
background-image: url('/express-portal-theme/images/main_bck.jpg');
I manage to fix it, the problem is due to nested file includes:
In my docroot/_diff/css/custom.css I included these imports:
#import url(express-portal.css);
#import url(fonts.css);
#import url(frontend_login.css);
#import url(frontend_landing.css);
and in my docroot/css/main.css:
#import url(base.css);
#import url(application.css);
#import url(layout.css);
#import url(dockbar.css);
#import url(navigation.css);
#import url(portlet.css);
#import url(extras.css);
#import url(custom.css);
So, I modify main.css to include all my custom css files and then it works!
My modified main.css looks like this:
#import url(base.css);
#import url(application.css);
#import url(layout.css);
#import url(dockbar.css);
#import url(navigation.css);
#import url(portlet.css);
#import url(extras.css);
#import url(express-portal.css);
#import url(fonts.css);
#import url(frontend_login.css);
#import url(frontend_landing.css);

Adding Existing Framework to Xcode (iPhone) error

I have added the <QuartzCore/QuartzCore.h> to my Frameworks folder in my iPhone project and added the #import "<QuartzCore/QuartzCore.h>" statement at the top of a custom UIView class.
However the custom UIView class gives me a "No such file or directory" compliation error in relation to the <QuartzCore/QuartzCore.h> framework. Is there something else I need to set so that the compiler can see the framework.
I'm not expert on the Xcode IDE so any assistance would be extremely welcome.
try removing the quotes around the <QuartzCore/QuartzCore.h>
you don't need them when you are importing a framework.
This is the correct syntax:
#import <QuartzCore/QuartzCore.h> // not #import "<QuartzCore/QuartzCore.h>"

Why do I get this error "error: expected specifier-qualifier-list before 'NSManagedObjectContext'?

1) I have the CoreData.framework imported. In Groups & Files I see it in the Framworks list together with UIKit.framework, Foundation.framework, CoreGraphics.framework.
2) I have this code, which should actually work. Don't know what that error means...
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#interface RootViewController : UITableViewController <CLLocationManagerDelegate> {
NSMutableArray *dataArray;
NSManagedObjectContext *managedObjectContext; // HERE's THE ERROR LINE
}
Edit: After importing CoreData, the error disappeared. BUT: Actually UIKit contains it, or not??
#import <CoreData/CoreData.h>
I have an Apple example code and they NEVER import CoreData, and it works.
Apple is taking advantage of the precompiled header (.pch file). Your projects do too when you start with a template and check the "Use Core Data for storage" option.
Also, you can use the precompiled header file to add any header files you wish to import for all source files in your target and project.
You need to link the CoreData framework and import CoreData/CoreData.h in the header file. UIKit does not contain the Core Data framework.

Unable to build project with CoreData classes

I am trying to migrate my sandpit code into my main project but for some reason I am getting the following strange error when trying to compile
syntax error before 'NSManagedObjectModel'
At first I thought this was because coredata wasnt in the prefix.pch file but I have added it in there too.
This is the top of AppDelegate where the code is being used (straight out of an Apple example)
#import <UIKit/UIKit.h>
#import "AppSettings.h"
#import "Skin.h"
#interface JeanieAppDelegate : NSObject <UIApplicationDelegate> {
NSManagedObjectModel *managedObjectModel;
NSManagedObjectContext *managedObjectContext;
NSPersistentStoreCoordinator *persistentStoreCoordinator;
#import <CoreData/CoreData.h> and don't forget to link it in.
Also, beware adding just anything to your .pch file. When you do so, those header files will be included all throughout your projectYou should only really put things there that are truly going to be universally required all through your project.