1

I'm trying to add an objective-C/CocoaPods code (GBFlatButton) to an existing swift code. I read all about I found regarding Header settings and I did this, let me know if is well performed.

Header Bridging configuration

Also the Header file has the right import files added to it.

//
//  Use this file to import your target's public headers that you would like to expose to Swift.
//

#import <UIKit/UIKit.h>
#import <GBFlatButton/GBFlatButton.h>
#import <GBFlatButton/UIColor+GBFlatButton.h>

On the other hand the CocoaPods project doesn't give me an error when I compile the code. The error occurs when I use the button, maybe is the way I'm trying to use this objective-c code:

let MyButton: GBFlatButton! = GBFlatButton(frame: CGRect(x: 0.0, y: 0.0, width: 200.0, height: 40.0))

Also I tried to use it like this: @IBOutlet var FButton: GBFlatButton!

This is the final error I have:

/Users//Documents/Projects/party/party/party/partyStepViewController.swift:18:19: Use of undeclared type 'GBFlatButton'

/Users//Documents/Projects/party/party/party/partyStepViewController.swift:18:9: Could not infer type for 'MyButton'

Any clue will help :)

Thanks!!, if you need more info don't hesitate to ask me.

1
  • I add the the following code inside the swift code: import GBFlatButton . With this works fine. Thanks!! Commented Jun 9, 2015 at 18:08

1 Answer 1

3

you forgot to add the bridging header in the Build settings of the app

enter image description here

In ViewController:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let button: GBFlatButton! = GBFlatButton(frame: CGRectMake(0, 0, 200, 50))
        self.view.addSubview(button)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

just do this and then it will work

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.