After installing a framework into my project with Pod, I got the error message "Use of undeclared type ..." when I tried to create my own class by inheriting the class in the Library of the framework. But I can find the class in the Library by command-clicking the class in my file. Has anyone suffered from this problem before?
You need to import Former (the module of the library you are using) to use its functions.
import UIKit
import Former // <---
final class YourCell: UITableViewCell, LabelFormableRow {
...
Related
Playing around with Bloc in Flutter.
In the Bloc event, I faced a problem regarding Equatable.
At first, I cannot import equatable package: import 'package:equatable/equatable.dart'; The error says:
"The part-of directive must be the only directive in a part. Try removing other directives, or moving them to the library for which this is a part".
Later on, when I create the Event and extends Equatable, the error says:
"Classes can only extend other classes. Try specifying a different superclass, or removing the extends clause".
(FYI: I put into the pubspec.yaml the equitable dependency).
I will appreciate your assistance, as always!
The part-of directive must be the only directive in a part. Try removing other directives, or moving them to the library for which this is a part.
That error message means you can't import any package from bloc_event.dart because bloc_event.dart is part of bloc_bloc.dart. Try to import the equatable package in bloc_bloc.dart. And don't forget to flutter pub get.
import 'package:equatable/equatable.dart';
part 'bloc_event.dart';
class BlocBloc ...
It's returning an error because bloc_event.dart is part of bloc_bloc.dart.
Try to:
import the equatable package in bloc_bloc.dart
import your state class,
remove all the part imports
import them normally without the part.
import 'package:equatable/equatable.dart';
class BlocBloc...
I just converted a git repository to Swift Package Manager (spm), all good, it compiles and I can import it in the project.
What is not good is that the project doesn't compile, is not seeing the protocol. My lib is a single generic class and i'm supposed to create an enum that implements the protocol then use the enum as a generic of the class.
enum LocalPreferences: String, RCPreferencesProtocol {
I get: Use of undeclared type RCPreferencesProtocol
Then I get further errors when trying to use the enum but i think this are only because the enum had an error:
private let localPreferences = RCPreferences<LocalPreferences>()
I get: Cannot specialize a non-generic definition
Anybody had this problem and fixed it?
Here is reference to the library is the lib for reference.
I made a stupid mistake, didn't declared the protocol and class public in the package. Strange though that the unit tests of the package passed instead giving the same error.
I am writing UITest for my app. In some parts of the UITest, I should call functions from Main target. When I create an Object from the Class(that has the implementation of the function), I get the error "use of undeclared of type CLASSNAME". I added the Class to the Compile Source of the test target.Then I get the same error but this time for the super class.
I added Classes to the compile source again and again, till I get this error "use of undeclared of UITextField, UIColor."
UITextField and UIColor are part of UIkit, then I import UIkit to my test Class , but did not work.
Any idea how to solve it?
In generell, How should we call functions in main target from test target?
Thanks a lot.
import your target with #testable import
import XCTest
#testable import MyProject
I'm learning java and I'm told this package is provided by default, to every class, because its methods are so common. I thought I would try to import it, any way to see what would happen. I know its not practical and probably expensive but I'm curious as to why it's doesn't work from a technical point of view.
import javax.lang.*;//why doesn't this work.
javax.lang contains only a single package: model
https://docs.oracle.com/javase/7/docs/api/index.html?javax/lang/model/package-summary.html
you're not doing anything by importing this package. Maybe you're confusing it with java.lang ?
You don't need to import java.lang.*
There is one exception to the import rule. All classes in the java.lang package are imported by default. Thus you do not need to import java.lang.*; to use them without fully qualified names.
Consider the System.out.println() method we've been using since the first day of class.
System is really the java.lang.System class. This class has a public static field called out which is an instance of the java.io.PrintStream class. So when you write System.out.println(), you're really calling the println() method of the out field of the java.lang.System class.
I have a class Comment declared as such:
public class Comment: NSManagedObject {
vars and methods...
}
When I try to compile my project, I get an error that reads:
Redefinition of 'Comment' as different kind of symbol
It highlights this line in the generated .h file: #interface Comment : NSManagedObject, and it tells me that the original declaration of Comment is in AIFF.h (something part of Foundation) and the line of the declaration is: typedef struct Comment Comment;.
I've only recently gotten this problem, and I've built the project with a Comment object successfully before. Why would an error like this happen in Swift?
Edit
If I remove the NSManagedObject superclass it compiles...
It may be a case that your class Comment is defined somewhere else in Foundation framework. What you need to do is importing only specific classes that you need inside your file. First remove all import statements in the source file and then import NSManagedObject like this:
import class CoreData.NSManagedObject
Then you will gain access to the NSManagedObject class you need for your Comment subclass. If you need any classes or structs from Foundation framework (for example NSError) you should import them like this:
import class Foundation.NSError
This will eliminate compiler errors about redefinition of class Comment.
Also make sure to clean the project and clean build folder by using Command + Shift + K and Command + Shift + alt + K