cannot find interface declaration for 'NSObject', superclass of 'GPXType' - ios

I have done some research on that issue , but I have not found anything similar just yet.
I am using iOS GPX framework to draw the path on map using GPX file. I have import iOS GPX.framework on my project. but I have face an issue.
Please Guide me, If anyone has any advice...

Just modify the header file, add this line on top of the file
#import <Foundation/Foundation.h>
Seems they thought that you will have a PCH file, where Foundation and UIKit will be imported, but Xcode 6 removed PCH default support, so the problem came. (See my previous answer)

Finally I have solved my problem
I have import #import < UIKit/UIKit.h> and change my Xcode 6 Architectures $(ARCHS_STANDARD_32_BIT).
Thanks so much Guys.

You haven't imported the header file #import ...
When compiling for both iOS and OsX, I had similar issue that I have resolved by importing TargetConditionals.h. The final thing looks like this:
#import <TargetConditionals.h>
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#elif TARGET_OS_MAC
#import <Cocoa/Cocoa.h>
#endif
#interface MyClass : NSObject
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
// Define UIKit methods
#elif TARGET_OS_MAC
// Define Cocoa methods
#endif
- (void)reloadRegisteredComponents;
#end

Related

XCode 9 - Error while importing #import <objc/runtime.h> - for Simulator Only

I am trying to import #import & it gives me below error:
Declaration of 'objc_property_t' must be imported from module 'ObjectiveC.runtime' before it is required
Here is the code:
#import <Foundation/Foundation.h>
#if TARGET_IPHONE_SIMULATOR
#import <objc/objc-runtime.h>
#else
#import <objc/runtime.h>
#import <objc/message.h>
#endif
Please Note: For Device, it's compiled successfully. It generates an error for Simulator only. This happens since I started using XCode 9. For XCode 8 it was working fine.
It looks like in iOS 11, objc-runtime.h has been removed.
You need to either remove if macro or import , inside it.

Xcode 8 (Swift): core.hpp header must be compiled as C++

I am using the OpenCV iOS Framework in a project. I followed the necessary steps to include the framework into the project.
The Project is written using Swift 3.
One of my classes that contains the core functionality of the App is written in Objective-C++. I included the header of the class in my Bridge-header file but when trying to run the project I get the following error:
error core.hpp header must be compiled as C++
After researching online and on SO, the most common solution presented was to create a Wrapper class that would be imported in the bridge header. However, after following this article I face the same problem.
The Header file of my class looks like this:
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#define IMAGE_CLASS UIImage
#elif TARGET_OS_MAC
#import <Cocoa/Cocoa.h>
#define IMAGE_CLASS NSImage
#endif
#import <AGGeometryKit/AGKQuad.h>
#import <stdio.h>
#import <opencv2/opencv.hpp>
#import <Foundation/Foundation.h>
typedef void (^DebugBlock)(cv::Mat current_image, std::string current_image_name);
#interface ImageScanner : NSObject
/**
* Singleton for access to the scanner.
*
* #return Shared scanner.
*/
+ (instancetype)sharedScanner;
Does anyone have an idea what I might be missing?
Thank you in advance!
G.
had the same problem.. solved by importing any file that use openCV in the wrapperClass.mm file ...
SO Answer here

Preventing duplicate entry messages

I have two classes that are pretty much identical but one is made for OS X and the other one is made for iOS. Then I have a header file like this:
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
#import "ClassForOSX.h"
#else
#import "ClassForIOS.h"
#endif
The problem is because both classes are included in the project, xcode compiles both and I have a lot of duplicate entries on the errors, because methods have the same name on both classes.
Is there a way to prevent a class from compiling, even if it is included on the project, unless the class is meant for the target?
Yes I know I can include/exclude classes from targets but I am dealing with hundreds of classes in both sides and multiple targets and that would generate a lot of include/exclude operations that will eventually go wrong. I was wondering if there is some solution in code that can just allow a class to compile if the target is right.
Use targets is best for your case. But You can do it in code
note add or remove __MAC_OS_X_VERSION_MIN_REQUIRED at Preprocessor Macros at target->Build Settings
ClassForIOS.h file
#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED
#import <Foundation/Foundation.h>
#interface ClassForIOS : NSObject
// interface
#end
#endif
ClassForIOS.m file
#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED
#import "ClassForIOS.h"
#implementation ClassForIOS
// implementation code
#end
#endif
ClassForOSX.h file
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
#import <Foundation/Foundation.h>
#interface ClassForOSX : NSObject
// interface
#end
#endif
ClassForOSX.m file
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
#import "ClassForOSX.h"
#implementation ClassForOSX
// implementation code
#end
#endif

Chartboost and swift integration

Ok, this is the first time I am trying to integrate chartboost and swift, so I will start from the beginning, maybe I missed something. First I have imported chartboost framework into my project, and then manually created the .h file, which I named BridgingHeader.h I added the needed import statements so that file looks like that now:
#ifndef appname_BridgingHeader_h
#define appname_BridgingHeader_h
#import <Chartboost/Chartboost.h>
#import <Chartboost/CBNewsfeed.h>
#import <CommonCrypto/CommonDigest.h>
#import <AdSupport/AdSupport.h>
#import <UIKit/UIKit.h>
#endif
I tried to build, everything went fine, but I noticed that it does not actually import this file. Hence I went to my project build settings, located Swift Compiler - Code Generation and found Objective-C Bridging Header and named it as appname/BridgingHeader.h . Now I am sure it did find the file and tried to import chartboost files, because I got 56 errors, of which all are in the chartboost files. Erros are such as "function definition is not allowed here" or "expected a type". The last error says that it failed to import bridging header. Anyone knows or has any ideas how to make this work?
Thanks
Ok, I my problem.
1) UIKit import should be done as follows:
#import <UIKit/UIKit.h>
#ifndef appname_BridgingHeader_h
#define appname_BridgingHeader_h
#import <Chartboost/Chartboost.h>
#import <Chartboost/CBNewsfeed.h>
#import <CommonCrypto/CommonDigest.h>
#import <AdSupport/AdSupport.h>
#endif
2) for the path, I should just went to the bridging file, in the file inspector copy the full path and paste it in the Swift Compiler - Code Generation.

OpenCV compiler error when using Stitcher under iOS

Whenever I try to use the OpenCV Stitcher class in iOS and I include the stitcher-header ( #include ) I end up with a compile error "Expected '{'" in exposure_compensate.hpp. Apparently the line
enum { NO, GAIN, GAIN_BLOCKS };
is causing some sort of error.
I am very new to openCV but using other functions like filter2d() work as expected. How can I resolve this?
Try
#import <opencv2/opencv.hpp>
then
#import <UIKit/UIKit.h>
Update: this answer only highlights the bare minimum fix of the problem, and perhaps the root cause: order of dependencies. Please refer to other answers for better code / setup that you put in your project.
In your project, create a Prefix Header, MyProject.pch, and set it in your project's build settings.
Then within that pch file, do something like this:
#ifdef __cplusplus
# include <opencv2/opencv.hpp>
# include <opencv2/stitching/detail/blenders.hpp>
# include <opencv2/stitching/detail/exposure_compensate.hpp>
#else
# import <Foundation/Foundation.h>
# import <UIKit/UIKit.h>
# import <Availability.h>
#endif
I also ran into this problem. As G. Führ ensure you include the opencv headers first. The easiest way to do this is add:
#ifdef __cplusplus
#include <opencv2/opencv.hpp>
#endif
near the top of the apps "Appname-Prefix.pch" header. This is a precompiled header and makes it easy to guarantee that your opencv header will be included before any of the apple headers.
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//
#import <Availability.h>
#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif
#ifdef __cplusplus
#include <opencv2/opencv.hpp>
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
This means you won't accidentally include an apple header before this anywhere else in the app.
I had a similar issue and I solved editing directly the opencv-framework files involved (in your case compensate.hpp) and comment from them the definition of the NO enum case definition. In this case the file was blender.hpp, but compensate.hpp has the same structure
Hope this helps
I solved this issue by importing any Apple headers before those of OpenCV, as mentioned in the beginning of the header:
#if defined(NO)
# warning Detected Apple 'NO' macro definition, it can cause build conflicts. Please, include this header before any Apple headers.
#endif
Hope that helps.
In my case, I create a vertical image stitching app with openCV, error show as screenshot below. It is from exposure_compensate.hpp and blenders.hpp. From the error description, the top file is ../CVWrapper.mm, which is in my project instead of openCV pod project.
As above guys said, there is some conflict issue between C++ and Apple MACRO. And we should put C++ header above Apple header.
First, I try a workaround from internet, which said "replace NO with NO_EXPOSURE_COMPENSATOR = 0". This worked, but it modified openCV source code, I don't want to do that because I will not do version control on Pod files, then if other guys clone my repo/project, they will need to do the same modification on those source code.
Then, I follow the error message in Xcode, I did following changes in my CVWrapper.mm file. After that, those two error disappear.
// Before change
#import "CVWrapper.h"
#import "UIImage+OpenCV.h"
#import "stitching.h"
#import "UIImage+Rotate.h"
// After change
#import "stitching.h"
#import "CVWrapper.h"
#import "UIImage+OpenCV.h"
#import "UIImage+Rotate.h"

Resources