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

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.

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.

Xcode: I just got an Apple Mach-O Linker (Id) Error and don't know why

I'm new to iOS Development, I'm using the latest version of Xcode and just got an error that said Apple Mach-O Linker (Id) Error exit code 1 and I haven't got a clue why. I think this is relevant but I'm not sure what it means:
ld: duplicate symbol _OBJC_CLASS_$_Timing1ViewController in /Users/tomkenning/Library/Developer/Xcode/DerivedData/EggTimer-ciznfdheqrtybuavrtbbcxfywyyw/Build/Intermediates/EggTimer.build/Debug-iphonesimulator/EggTimer.build/Objects-normal/i386/Mediumhb.o and /Users/tomkenning/Library/Developer/Xcode/DerivedData/EggTimer-ciznfdheqrtybuavrtbbcxfywyyw/Build/Intermediates/EggTimer.build/Debug-iphonesimulator/EggTimer.build/Objects-normal/i386/Timing1ViewController.o for architecture i386
All I've done recently is initialise and set some integer values in a .m file and then link to them from .h file from another ViewController, using #import "suchandsuch.m", there's been no errors in the code, but is that not allowed?
Thanks in advance for any help you can offer!
Don't do this:
#import "suchandsuch.m"
Do this:
#import "suchandsuch.h"
You are probably compiling suchandsuch.m, which defines the class Timing1ViewController, normally (by including suchandsuch.m in your target's list of files to build). Then your #import "suchandsuch.m" causes that same code to be inserted into a different source file, which is compiled as well. The result: two different source files try to define Timing1ViewController.
To do your constants the right way -- by declaring them extern in suchandsuch.h and defining them in suchandsuch.m -- see this answer.
You probably have two Timing1ViewController classes with the same name. If you don't try to Product -> Clean and build again.

OpenCV project on iPhone - opencv.hpp building issue

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.

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”.

iphone error: expected '=', ',', ';', 'asm' or '__attribute__' before ' 'foo'

I'm trying to port the speakhere example into another app and I'm having issues. I copied all the files, and all the frameworks, but for some reason I get a bunch of compile errors that I've never seen before and thus don't know what to do. The only difference is that i'm not suing IB and so i had to change it slightly.
What does error: expected '=', ',', ';', 'asm' or '__attribute__' before 'foo' mean?... I get this error multiple times for different files
In my situation the first error is pointing at 'MeterTable'.. a class that includes <stdlib.h>,<stdio.h> and <math.h>. But those files seem to be importing fine (if i remove them i get more errors)
Any suggestions on how to debug this?
TIA!
EDIT:
I still can't seem to figure it out. I'm literally just copying files from the example into another project. Can someone check it out please ? SpeakHerePort.zip and the original is here SpeakHere.zip
Your problem is that you are compiling SpeakHerePortAppDelegate.m, which is an Objective C file, but it is indirectly including MeterTable.h which is a C++ header file.
Rename it to SpeakHerePortAppDelegate.mm (double m) so that it is compiled as Objective C++ and your problem is resolved.
Name all your files .mm and then all your code will be compiled as Objective C++
In my case, the .h and .m in question are built fine with regular target, and the App can run as well.
However after the subset of the files are moved under a static library target, it gets this compile error when the static library is built.
Was stuck for a while & tried the above mentioned techniques, unfortunately they didn't help in my case.
Noted that this error happened only for the NSString*, for e.g.,
extern double const kTimeout; // fine
extern NSString* const kImageType; // compile error
After the above analysis & little break, eventually the problem is resolved by adding the the following import to the .h - "Foundation/Foundation.h"
It sounds like an unfinished declaration, probably in a header file. Search for 'foo' (or whatever the symbol actually is) across all project files, using ⇧⌘F (Edit ▸ Find ▸ Find In Project...) in Xcode, and/or examine the headers you're including where MeterTable is declared. Sometimes the compiler gets confused about the actual location of the error, since header files are frequently #imported into other files, so the problem can be manifest in multiple locations.
This might not have applied to this exact situation, but I had this exact error too, which was caused by a bad forward declaration. In Objective-C, make sure your forward-declares begin with the # sign - e.g.
#class MyClass;
Those of us still on autopilot from C++ will forget the #, see that XCode has highlighted class as a reserved keyword, and think all is well with the world. It is not.
It means that you have a syntax error. If you paste the code in question, it's easier to debug.
I had a similar scenario to some of the posts above. I'd written a C++ class based off of the examples in the Audio Queue Services documentation, and had this compilation issue in a test project. This post helped a tremendous amount.
Today, I'm incorporating the C++ class in my project, and got the build error again. In my scenario, I had to also set the type (using the "Get Info" window) to sourcecode.cpp.objcpp for the objective-c class that was calling my C++ class.