error: expected specifier-qualifier-list before 'cv' - iphone

I am using OpenCV framework for image processing, i am identifying edge in photo for
normal iOS project, now i am converting this code in cocos2d project, i have imported all
required headers but while compiling i am getting this error:expected specifier-qualifier-list before 'cv'. here is my code
#import "cocos2d.h"
#import "CameraController.h"
#import "Globals.h"
#interface BotoxEffectController : CCLayer
{ cv::VideoCapture *_videoCapture; cv::Mat _lastFrame;}//this is line where i am
getting error
#property (nonatomic, retain) CCSprite *sprite2D;
+(CCScene *) scene;
#end
here is code in .pch file.
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iPhone SDK 3.0 and later."
#endif
#ifdef __cplusplus
#import <OpenCV/opencv2/opencv.hpp>
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
Please refer below screen shot BotoxEffectController class interface where error is & implementation file has extension .mm.
here is .pch file where i am importing opencv.hpp

I think I know what's going on here. Try adding the OpenCV header to your BotoxEffectController header file:
#import <OpenCV/opencv2/opencv.hpp>
If this fixes the compile errors, the problem is with the prefix.pch. For some reason it doesn't parse the #if __cplusplus part. You can verify it by adding a warning to it, see if it triggers:
#ifdef __cplusplus
#warning "ok so it DID import the OpenCV header"
#import <OpenCV/opencv2/opencv.hpp>
#endif
If that is the issue, I can't tell you why the opencv header in the prefix.pch won't work. I only remember having had this issue once or twice before, but can't remember how I fixed it. One thing you should check: the BotoxEffectController.h should have its File Type set to "Default - C Header" and not C++ header.

Related

Objective-C using a class without creating multiple instances [duplicate]

I have been mixing Swift and Objective C just fine but I'm having issues gaining access to a Swift class from the HEADER file of Objective C. I can do so successfully in the .m file.
Within the .h file I import the Xcode generated file that has the format "Appname-Swift.h". However, in doing so I get the message that the file is not found. I can do this same import in my .m file with no issue. However, I need it in the .h file as I reference a Swift class that I need access to with public API.
How can I make use of the Swift class from the .h portion of Objective C?
Example:
#import <UIKit/UIKit.h>
#import "MyApp-Swift.h"
#interface SelectedContactsVC : UIViewController
#property (nonatomic,strong) MapVC *mapVC;
#end
MapVC above is a Swift class.
Move #import "MyApp-Swift.h" to .m file.
And make your .h file as:
#import <UIKit/UIKit.h>
#class MapVC;
#interface SelectedContactsVC : UIViewController
#property (nonatomic,strong) MapVC *mapVC;
#end
Swift cannot generate "MyApp-Swift.h", if it's imported from Objective-C header, sort of mutual dependency thing maybe.

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);

Duplicate symbol _OBJC_METACLASS_$_SBJsonParser

I just included AWSIOSSDK.framework and Facebook SDK together in my project, then got a build error:
ld: duplicate symbol _OBJC_METACLASS_$_SBJsonParser in /Users/tom8/Desktop/site1/site1/facebook-ios-sdk/libfacebook_ios_sdk.a(SBJsonParser.o) and /Users/tom8/Desktop/AWSiOSSDK.framework/AWSiOSSDK(SBJsonParser.o) for architecture i386
I use iOS Facebook SDK Static Library, so i could not simply delete sbjson files in facebooksdk folder. I also tried to delete sbjson files in AWSIOSSDK folder, but it also did not work. Could someone give me some advice?
Almost without exception, when I get duplicate symbol build errors, it's because I was #include-ing .h files too prolifically from other .h files. The solution is almost always these two simple steps:
move as many #include directives into .m files as possible
use #protocol and #class forward-declarations in .h files.
The only cases where you need to #include an .h from an .h is when you actually extend a class or implement a protocol. If you just need to use a class name or protocol name in a signature, use forward declarations and move the #include to the .m file.
Example:
foo.h
#include "Bar.h"
#include "BazProtocol.h"
#include "BarDelegateProtocol.h"
#interface Foo:NSObject <BarDelegate>
#property (strong, nonatomic) id<Baz> myBaz;
#property (strong, nonatomic) Bar *myBar;
#end
becomes
#include "BarDelegateProtocol.h"
#class Bar;
#protocol Baz;
#interface Foo:NSObject
#property (strong, nonatomic) id<Baz> myBaz;
#property (strong, nonatomic) Bar *myBar;
#end
I had the same problem too. You can delete the files from the Facebook Project itself, but you cannot delete from the framework.
So click:
facebook-ios-sdk.xcodeproj (to open up file contents) -> FBConnect (to view folder contents) -> JSON (to view folder contents) -> remove SBJsonWriter and SBJsonParser.
Try compiling. You should be good to go!
Eva

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

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.