I am trying to use one of my Objective-C class from another target, in my Swift class inside extension target.
I created the <Project-Name>-Bridging-Header.h and included that objective-c file, but the build is not compiling because of build error in "Cryptor.h" and <CommonCrypto/CommonDigest.h>. I believe this has to do something with CommonCrypto framework.
This is how my Bridging-Header.h looks:
#import <UIKit/UIKit.h>
#import <FacebookSDK/FacebookSDK.h>
#import <GooglePlus/GooglePlus.h>
#import <Security/Security.h>
#import <CommonCrypto/CommonCrypto.h>
#import <CommonCrypto/CommonDigest.h>
I guess this is due to Common Crypto library. Has anybody encountered the same issue and solved it?
EDIT:
Specifically, i am getting build error - "Missing #end" in CommonDigest.h and because CommonDigest.h is not getting build hence the error in Cryptor.h.
I don't know if it will fix your problem, but the bridge-header is sometimes a bit buggy. At least it was the case for me.
Try to edit your header and import your files like that:
#import "FacebookSDK.h"
#import "GooglePlus.h"
#import "Security.h"
#import "CommonCrypto.h"
#import "CommonDigest.h"
I have removed the UIKit-header, because you don't really need it, because swift has it's own UIKit.
Related
All of a sudden, I'm getting "Expected unqualified-id" and "Type name declared as a reference to a reference" parsing issues from importing opencv2/opencv.hpp I tried relinking opencv3, upgraded from opencv 3 to 4 and restarted Xcode. How can this be resolved?
Used prebuilt opencv from here: https://opencv.org/releases/ and Xcode 10.2
See All Parsing Errors
Expected unqualified-id:
CODE - Removed everything and left with this, but it still has parsing errors.
-------
.mm
------
#import <opencv2/opencv.hpp>
#import <opencv2/imgcodecs/ios.h>
#import <Foundation/Foundation.h>
#import "OpenCVWrapper3.h"
#include <vector>
using namespace std;
#implementation OpenCVWrapper3
+ (NSString *) openCVVersionString
{
return [NSString stringWithFormat:#"OpenCV Version %s", CV_VERSION];
}
#end
----
.h
----
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#interface OpenCVWrapper3 : NSObject
+ (NSString *) openCVVersionString;
#end
Ok so... I don't have a clue what caused the error. I opened another ios project that uses opencv and it gave the same errors. Then I created a new project and added #include iostream, ostream and got the same error. So its was not isolated to opencv. So I deleted and reinstalled Xcode and now it works!! Bizarre!
I've seen some post that already reference my problem and solve it, but it was active 2 years ago and I tried to use it but it doesn't work for me (maybe a difference in Xcode or something)
here is the related posts :
Making Xcode ignore static library when building for iOS
Simulator
Xcode: Conditional Build Settings based on architecture (Device
(ARM) vs Simulator (i386))
I have a project that work with vuforia, a c++ library, but this library isn't compatible with the simulator. I want to compile my project for the simulator (even if the part using the lib obviously won't work) to test other functionalities of my app.
In my build settings, I had this :
Header Search Paths : ../../build/include
Library Search Paths : ../../build/lib/arm
I had nothing in Other Linker Flags
Following the posts, I tried to remove the lib exclusively for simulator, and I currently have :
The compilation error changes and it is now "Vuforia/Vuforia.h file not found" in one of my view controller that use the lib.
So I took care of it, and I added the preprocessor instruction
#if !(TARGET_OS_SIMULATOR)
....
#endif
It work for many of it, but one error is still there, even if it is inside a block like showed above
#if !(TARGET_OS_SIMULATOR)
#import <QuartzCore/QuartzCore.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#import <sys/time.h>
#import <Vuforia/Vuforia.h>
#import <Vuforia/State.h>
#import <Vuforia/Tool.h>
#import <Vuforia/Renderer.h>
#import <Vuforia/TrackableResult.h>
#import <Vuforia/VideoBackgroundConfig.h>
...
#endif
At the end I also tried to play with Other Linker Flags but it doesn't help...
Can you help me to find how to bind the library only for iOS device and run the app on the simulator ?
Thanks !
I'd avoid setting different header search paths.
Use TargetConditionals.h as you mentioned to disable the Vuforia when building for the simulator. Then, to take care of linking, I suggest using OTHER_LDFLAGS instead of the "Link with libraries" build phase since you cannot conditionalize that build phase by platform. You can easily do this with an xcconfig like:
OTHER_LDFLAGS = -framework Vuforia
OTHER_LDFLAGS[sdk=*simulator] =
Writing a program, using COM ADO library. Everything is working fine, all as it should be. Then low and behold I need to use a function from the ADOX library too. So I add the necessary #import command for ADOX and the compiler generated header throws over a 100 errors.
My import statements are
#import "msado15.dll" rename("EOF", "EndOfFile")
#import "msadox.dll" no_namespace
Note that I lifted those statements straight out of MSDN example, located here https://msdn.microsoft.com/en-us/library/windows/desktop/ms676148%28v=vs.85%29.aspx
Now I discovered that if I add a using command, it sort of works.
#import "msado15.dll" rename("EOF", "EndOfFile")
#import "msadox.dll" no_namespace
using namespace ADODB;
The above will compile and my program works as it should. However, it screws up Visual Studio's contextual visualization. All the type definitions are displaying in black instead of blue and has the red squiggly error indicator underlining it. Mouse over context help says "undefined identifier" even though it will compile fine. And you cant get the type information menu or definition by right clicking on the text.
What is going on here?
Thanks
I just started using QT. Right now I need to transfer some code I have on a Visual C++ project to QT.
The only thing the project does at the moment is open photoshop and set the visible flag to false (it will be used for automation, so a lot of things will be added later).
What I do is, I import 2 photoshop dlls (NOTE: I don’t have .h or .lib for them, just the .dll files)
The method I’m using to import these dlls is through import libid, since all the other methods I tried didn’t work. They are COM objects, btw.
This is my VC++ code:
//library ID of Photoshop.dll
#import "libid:E891EE9A-D0AE-4cb4-8871-F92C0109F18E"
//library ID of PhotoshopTypeLibrary.dll
#import "libid:4B0AB3E1-80F1-11CF-86B4-444553540000"
int main()
{
Photoshop::_ApplicationPtr app( __uuidof(Photoshop::Application));
app->Visible = false;
return 0;
}
Now, QT gives me some warnings and errors on the import lines:
warning: #import is a deprecated GCC extension
error: libid:E891EE9A-D0AE-4cb4-8871-F92C0109F18E: No such file or directory
And then, after that, it says (obviously) that “Photoshop” is not declared.
Now, I searched and the closest solution I found was to include the .tlh files that were created on my VC++ project, but when I did that, I got more than 1 thousand errors and warnings, so that obviously didn’t work.
Can someone please tell me what to do here? I’m seriously stuck!
I have the following Objective-C headers:
// Menu.h
#import <UIKit/UIKit.h>
#import "GameController.h"
#interface Menu : UIImageView {
GameController *gameController; // "Expected specifier-qualifier-list
// before GameController"
}
- (void)appear;
#end
and
// GameController.h
#import <UIKit/UIKit.h>
#import "Menu.h"
#interface GameController : UIView {
Menu *menu; // "Unknown type name 'Menu'"
}
- (void)startLevel0;
- (void)startLevel1;
- (void)startLevel2;
#end
When I try to build the project, Xcode (v4) yells at me, saying Expected specifier-qualifier-list before GameController and unknown type name 'Menu'. I'm sure that they are somehow related, but I have no idea how?
It's not good practice to have mutually-including header files. Instead of importing Menu.h, use the #class directive. Try removing #import "Menu.h" and adding #class Menu in its place. Ditto for Menu.h (remove GameController include, and add the #class directive)
You have a circular reference in your imports. The compiler builds a dependency tree from the import statements so when two Classes rely on each other it doesn't know how to compile one before the other.
Sadly, gcc kicks out a fairly nonsensical error statement when this happens "Expected specifier-qualifier-list". #yan is correct that you should use the #class directive. Check out this question for a solid explanation: #class vs. #import