Backendless class doesn't exist - swift

I created a swift application in Xcode.

I created the bridging header and followed all the setup instructions.
In my app delegate everything works fine.
In all my other files if I try to use the backendless class it doesn’t exist.

You should create a ‘backendless’ var in all your class where you use Backendless SDK methods:

var backendless = Backendless.sharedInstance()

That is the first thing I tried but it says use of unresolved identifier

Did you do step 9 from this guide when you setup your xcode project?

https://backendless.com/mobile-developers/quick-start-guide-for-ios/

Hi Abdullaah,

Can you send me your project (without ‘lib’ folder) for investigation?
My email: slavav@themidnightcoders.com

Regards,
Slava

I think I found the problem.

The back endless class only doesn’t work if I copy files from another project.
So I recreated my project but instead of coping the files I created new ones and copied the code.
Thanks for your help.

Hi Slava,

Can I send you my project, I have the same problem,

Regards,
Alexander

Sure, Alexander. Upload it to Dropbox or Google Drive and provide its link here.

Vyacheslav,

Hello, how are you?
Could you look at this code?
func register(email: String?, firstname: String?, lastname: String?, password: String?, confirm: String?, avatarImage: UIImage?) {

    if avatarImage == nil {

       self.newUser!.setProperty("Avatar", object: "")

    }

    self.newUser!.name = self.name as NSString!

    self.newUser!.setProperty("lastname", object: lastname)

    self.newUser!.email = email as NSString!

    self.newUser!.password = password as NSString!

    self.newUser!.setProperty("confirm", object: confirm)

    

    backendless?.userService.registering(newUser, response: {(registeredUser:  BackendlessUser!)-> Void in

        

    }) {(fault:Fault!)->Void in

        print("Server reported an error, couldnt register new user: \(fault)")

This is my Error: Cannot convert value of type ‘(BackendlessUser!) -> Void’ to expected argument type ‘((BackendlessUser?) -> Void)!’

Please try:

backendless!.userService.registering(newUser, response: {(registeredUser: BackendlessUser?)-> Void in
}) {(fault:Fault?)->Void in
print("Server reported an error, couldnt register new user: \(fault!)")

Thank you for your attention, the problem is resolved, but the code does not work, it doesn’t register user in the system.

Please take a look, of course, if you have the time

import UIKit

class RegistrationViewController: UIViewController {

@IBOutlet weak var firstNameTextField: UITextField!




@IBOutlet weak var lastNameTextField: UITextField!

    

@IBOutlet weak var emailTextFiled: UITextField!




@IBOutlet weak var passwordTextFiled: UITextField!

    

@IBOutlet weak var confirmPasswordTextField: UITextField!

    

    var backendless = Backendless.sharedInstance()

    

    var newUser: BackendlessUser?

    var name: String?

    var lastname: String?

    var email: String?

    var password: String?

    var confirm: String?

    var avatarImage: UIImage?

    

    

    

    

    

    

    override func viewDidLoad() {

        super.viewDidLoad()

        

        

        newUser = BackendlessUser()

        

        

        

        // MARK: - White color for place holder

        let textField = UITextField()

        textField.attributedPlaceholder = NSAttributedString(string:"",attributes:[NSForegroundColorAttributeName: UIColor.white])

        

        // Do any additional setup after loading the view.

    }

    

    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

        // Dispose of any resources that can be recreated.

    }

    

    

    

    // MARK: - Register Button

    

    @IBAction func registerButton(_ sender: UIButton) {

        

        if firstNameTextField.text != "" && lastNameTextField.text != "" && emailTextFiled.text != "" && passwordTextFiled.text != "" && confirmPasswordTextField.text != "" {

            

            name = firstNameTextField.text

            lastname = lastNameTextField.text

            email = emailTextFiled.text

            password = passwordTextFiled.text

            confirm = confirmPasswordTextField.text

            

            register(email: self.email!, firstname: self.name!, lastname: self.lastname!, password: self.password!, confirm: self.confirm!, avatarImage: self.avatarImage)

            

        } else {

            // MARK: - Warning to user

            

        }

    }

    

    // MARK: - Backendless User Registration

    

    func register(email: String?, firstname: String?, lastname: String?, password: String?, confirm: String?, avatarImage: UIImage?) {

        

        

        if avatarImage == nil {

            self.newUser!.setProperty("Avatar", object: "")

        }

        self.newUser!.name = self.name as NSString!

        self.newUser!.setProperty("lastname", object: lastname)

        self.newUser!.email = email as NSString!

        self.newUser!.password = password as NSString!

        self.newUser!.setProperty("confirm", object: confirm)

        

        backendless!.userService.registering(newUser, response: {(registeredUser:  BackendlessUser?)-> Void in

            

            // login new user

            self.loginUser(email: email, password: password)

            

            self.firstNameTextField.text = ""

            self.lastNameTextField.text = ""

            self.emailTextFiled.text = ""

            self.passwordTextFiled.text = ""

            self.confirmPasswordTextField.text = ""

            

            

            

        }) {(fault:Fault?)->Void in

            print("Server reported an error, couldnt register new user: \(fault)")

            

            

            

        }

    }

    

    func loginUser(email: String?, password: String?) {

        

        backendless!.userService.login(email, password: password, response: { (user: BackendlessUser?) -> Void in

            

            //here segue to recents vc

            

            let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MainVC") as! UITabBarController

            self.present(vc, animated: true, completion: nil)

            

        }) {(fault: Fault?) -> Void in

            print("Server reported an error: \(fault)")

            

        }

        

    }

    

}

Alexander, please clarify, what happens when you register the user: you got some error, app has crashed, etc.

Slava, nothing happens, so it has become a problem for me, app does not work. but there is no error

I’m picking up an old project where I left off, somewhere in February 2016.

Updated the pod (Installing Backendless (3.0.44))
But ending up with "use of unresolved identifier ‘Backendless’ " all over the place.
Also ‘Fault’ seem to upset Xcode 8.
P.S. Using Swift 3

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier; color: #00a400; background-color: #dfdbc3}
span.s1 {font-variant-ligatures: no-common-ligatures}

Screen Shot 2017-02-08 at 13.34.08.png

I’m picking up an old project where I left off, somewhere in February 2016, upgraded to Swift 3

Updated the pod (Installing Backendless (3.0.44))
But ending up with "use of unresolved identifier ‘Backendless’ " all over the place. Adding var backendless = Backendless.sharedInstance() doesn’t seem to help at all.
Also ‘Fault’ seem to upset Xcode 8.

Screen Shot 2017-02-08 at 13.34.08.png