OpenCV project on iPhone - opencv.hpp building issue - iphone

I've cloned https://github.com/niw/iphone_opencv_test and tried to replace
#import <opencv2/imgproc/imgproc_c.h>
#import <opencv2/objdetect/objdetect.hpp>
with
#import <opencv2/opencv.hpp>
in OpenCVTestViewController.m file. But XCode threw following error:
iphone_opencv_test/opencv_device/include/opencv2/opencv.hpp:55:10: fatal error: 'opencv2/calib3d/calib3d.hpp' file not found [2]
#include "opencv2/calib3d/calib3d.hpp"
So, I've tried to remove the line #include "opencv2/calib3d/calib3d.hpp" from the opencv.hpp file. The error below was thrown:
iphone_opencv_test/opencv_device/include/opencv2/ml/ml.hpp:2075:10: fatal error: 'map' file not found [2]
#include <map>
I've also tried to change .m to .mm, but it seemed futile. Where I'm wrong?

There's a conflict between OpenCV's MAX/MIN macros and Cocoa's MAX/MIN. It leads to strange errors like this one at compile time. To bypass this problem, you can either:
1. add at the top of the pre-defined header file
2. totally decouple opencv and obj-c code, so that no .m/.mm file includes . This can be done for example by using boost GIL in-between, or using custom vanilla C++ classes to pass image data from Cocoa frameworks to opencv C++ image processing classes.

Related

VS Code Compilation error while using SASS compiler

Apologies if this question has been asked before, just cannot figure this out for the life of me. I am new to coding though, so that could be a major factor.
I am using the latest vs code and Ritwick Dey live sass compiler 3.0.
I started a new project recently and have been having issues with the sass compiler. I have tested my code with both ATOM and Brackets and they work perfectly, however vs code is throwing up the following compilation error:
Error: no mixin named breakpoint-down
on line 61 of Users/simon/Documents/Training/Web Design/Frontend Mentor Challenges/easybank-landing-page-master/scss/_globals.scss
from line 1 of sass/Users/simon/Documents/Training/Web Design/Frontend Mentor Challenges/easybank-landing-page-master/scss/main.scss
>> #include breakpoint-down(medium) {
-----------^
It is also happening with variables and not recognising them. When I make changes to all files, they compile ok and show in the main.css file.
I loaded a previous project and that does recognise the variables and the mixins, however I have copied everything the same way, the file structure is exactly the same, so I am now in need of help.
Thanks in advance.
Seems that the file with the missing mixin has not been included to the stylesheet itself.
So you can check if
#import 'mixins' has been added to the stylesheet before the file in which you call the mixin.
(Just a little remark because we had that this week: I do not believe that that's the reason. But the compiler you use is not longer supported although it is still very popular. Inbetween there is an faster alternative or the same compiler can be loaded from another respirotory in github. See: Live Sass Compiler - #use causes compilation error)
I figured out the problem.
It seems that the compiler will compile files in the order that they are placed inside the main.scss file. As I had my mixins and variables files at the bottom, the error message appeared and stopped the import process and gave the compilation error.
Wrong way
#import "globals";
#import "header";
#import "mixins";
#import "variables";
Right way
#import "mixins";
#import "variables";
#import "globals";
#import "header";
I hope this helps someone else having the same issue.

Can't use debugger amongst Swift classes in Objective-C app

I have a large Xcode project which is 99% Objective-C and C code. I've just implemented the project's first Swift class.
When I pause the debugger and enter any command, I am greeted with this message:
error: in auto-import:
failed to get module 'Coventry_iPhone' from AST context:
error: /Users/ricky/Documents/Coventry/Config/Frameworks/iPhone/Coventry-iPhone-Bridging-Header.h:9:9: error: 'Silverlake-iPhone.h' file not found
#import "Silverlake-iPhone.h"
^
error: failed to import bridging header '/Users/ricky/Documents/Coventry/Config/Frameworks/iPhone/Coventry-iPhone-Bridging-Header.h'
Obviously something is wrong with importing a header file from another framework. Is there something akin to search paths I need to do with the debugger so it knows where to find this file? Or is the problem elsewhere?
After extensive trial and error, I found that #import <Silverlake-iPhone.h> was the syntax that worked.

Duplicate Interface Definition When Implementing FBConnect

I am trying to add FBConnect to my application which includes the SBJson framework. However, when I try to compile the project I get these two errors:
Duplicate interface definition for class 'SBJsonWriter'
Duplicate interface definition for class 'SBJsonParser'
What can I do to fix this error? Thanks for any help.
Delete
#import FacebookSDK/FacebookSDK.h
In your project
I start using FacebookSDK, but then I was disappointed with it's current state and tried to use the old "FBConnect", that's how I have got the error
There are two possibilities:
you have two interfaces with the same name. Use Xcode's find in project menu option to find instances of SBJsonWriter. Then rename one of the interfaces
somehow you have managed to import the .h file twice. Check to make sure you always use #import and not #include.
A bit more info on #import/#include:
include blindly includes the file at the location of the #include statement. This means that if you #include a file twice in your .m you will get two copies of the file. Almost all traditional C #include files have something like the following bracketing all the content:
// some_file.h
#if !defined SOME_FILE_H
#define SOME_FILE_H
// entire content of #include file
#endif
he above is sometimes referrwed to as an include guard macro.
In Objective-C, if you #import a file, a check is performed by the compiler to make sure it has not already been imported. Consequently the guards are usually omitted. So if you #include a file that was supposed to be #imported, neither check will be done and you will sometimes get duplicate definitions.

Typedef for STL Vector does not compile in XCode

I have some code written in C++ which I would like to use in my iPhone app. I added the source files to the XCode project, but I have problem with some parts of the source code, e.g. I have he following code:
#import <vector>
// (...) some other code
typedef std::vector<keypoint> keypointslist;
// (...) rest of the code
In the line with the typedef I'm getting:
Expected '=', ',', ';', 'asm' or 'attribute' before ':' token in
Exactly the same code was compiled with gcc on Linux machine, so I wonder why XCode has problem with it.
Any suggestions?
Are you sure, you told XCode to compile the file as C++ and not as C or Objective-C? Maybe you must use the file extension ".cpp".
It's called #include, not #import:
#include <vector>
+1 with Ludger,
youre adding that to an objective c app, you'll need to add a .cp/.mm/.cpp translation unit to the project to get that to compile - right click on project classes select add class make sure you add one from the cpp section.
If you include C++ code in a ".m" file you must rename the extension to ".mm" or ".M". this applies even if you reference a C++ class from an objective C one, the file must be renamed. Sometimes this renaming has a domino effect and so you end up with a lot of ".mm" files in your project.
Make sure you included <vector> header file before typedef. It looks like the compiler doesn't know std namespace.
You have to rename the ALL files that use the C++ code with .mm extension.
That includes your view controller files that could be importing the C++ class. eg. MyViewController.mm

Cannot find interface declaration for 'UIResponder'

I am running into this issue when trying to compile code for an iPhone app that I inherited from a previous developer. I've poked around on a couple forums and it seems like the culprit may be a circular #import somewhere.
First - Is there any easy way to find if this is the case/find what files the loop is in?
Second - Its definitely possible this isn't the problem. This is the full error (truncated file paths so its easier to view here):
In file included
from [...]/Frameworks/UIKit.framework/Headers/UIView.h:9,
from [...]/Frameworks/UIKit.framework/Headers/UIActivityIndicatorView.h:8,
from [...]/Frameworks/UIKit.framework/Headers/UIKit.h:11,
from /Users/wbs/Documents/EINetIPhone/EINetIPhone_Prefix.pch:13:
[...]/Frameworks/UIKit.framework/Headers/UIResponder.h:15: error: expected ')' before 'UIResponder'
[...]/Frameworks/UIKit.framework/Headers/UIResponder.h:17: error: expected '{' before '-' token
[...]/Frameworks/UIKit.framework/Headers/UIResponder.h:42: warning: '#end' must appear in an #implementation context
[...]/Frameworks/UIKit.framework/Headers/UIResponder.h:51: error: expected ':' before ';' token
[...]/Frameworks/UIKit.framework/Headers/UIResponder.h:58: error: cannot find interface declaration for 'UIResponder'
As you can see, there are other errors alongside this one. These seem to be simple syntax errors, however, they appear in one of Apple's UIKit files (not my own) so I am seriously doubting that Apple's code is truly producing these errors.
I'm stumped as to how to solve this issue. If anyone has any ideas of things I could try or ways/places I could get more info on the problem, I'd really appreciate it. I'm very new to Obj-C and iPhone coding.
Edit:
Just tried Clean All Targets - it actually found an extra warning but still have the same errors as above.
My EINetIPhone_Prefix.pch:
//
// Prefix header for all source files of the 'EINetIPhone' target in the 'EINetIPhone' project
//
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iPhone SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
Edit #2:
Interestingly, I tried removing the UIKit import from my prefix file and putting it into the specific .m files that need it. I still get the same errors, but now they occur in every file attempting to import UIKit.h. Is it possible that UIKit is messed up?
Perform a “Clean” (under the “Build” menu) and make sure to check “Also Remove Precompiled Headers”.