Reputation: 109
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.
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.
Upvotes: 1
Views: 181
Reputation: 650
you forgot to add the bridging header in the Build settings of the app
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
Upvotes: 3