Could not build Objective-C module 'cocoaMQTT' - ios

I am building an app that should connect to my raspberry pi but after installing MQTT via cocoaPods the import CocoaMQTT gives me this error
"Could not build Objective-C module 'CocoaMQTT'"
I've already deleted my derivedData but thats not working either.
how can I fix this?
import UIKit
import CocoaMQTT -> Could not build Objective-C module 'CocoaMQTT'
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
#IBAction func test(_ sender: UISwitch) {
}
}

Ok i've fixed it by compiling for a lower iOS deployment.

Related

Xcode 7.3 doesn't autocomplete when using MapKit

In Xcode 7.3 (using Swift) I've created the most simple map example:
Imported MapKit
Created an outlet called mapView
For some reason, there's no autocomplete with my outlet. Even when I type 'ma' it does not come up with the outlet name 'mapView'.
Can anyone help get autocomplete working?
Code from: ViewController.swift
import UIKit
import MapKit
class ViewController: UIViewController {
#IBOutlet weak var mapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// mapView doesnt appear when I begin to type it
// also it doesn't show any functions when I type mapView.
}
I've also uploaded my project to dropbox:
https://www.dropbox.com/sh/rgefwafhanti1wa/AABhQt8TsbvesaO9zg-SydlRa?dl=0
You also need to add the MapKit framework in Build Phases for the target.

Setting up CVCalendar via Cocoapods: Views Aren't Showing

I've been trying to set up the CocoaPods CVCalendar for my app, but after integrating it into my Xcode project, the content fails to show through the UIViews. Essentially, whenever I connect the views to the CVCalendarView and CVCalendarMenuView variables, the views simply do not show. Here's the ViewController code I have so far, and help would be greatly appreciated!
import UIKit
import CVCalendar
class ViewController: UIViewController, CVCalendarViewDelegate, CVCalendarMenuViewDelegate {
#IBOutlet weak var menuView: CVCalendarMenuView!
#IBOutlet weak var calendarView: CVCalendarView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
calendarView.commitCalendarViewUpdate()
menuView.commitMenuViewUpdate()
}
func presentationMode() -> CalendarMode {
return .MonthView
}
func firstWeekday() -> Weekday {
return .Sunday
}
}
Your ViewController class is the class in the storyboard?
Did you hook up the delegates? Delegate setup
You're delegating the rendering to your ViewController/
You need to drag to the yellow view controller nub.
If for some reason you'd like to setup CVCalendar manually you have to do the following steps.
Refer here

Swift framework wouldn't work

I have created an Cocoa Touch framework with Swift and and created a CocoaPod from it. I imported that framework with CocoaPod into my app project in Swift. In the view-controller where I want to use the framework I add the following:
import UIKit
import swiftBAOS
class ViewController: UIViewController
{
override func viewDidLoad() {
super.viewDidLoad()
BAOS.login()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
There is no error, but when I want to use a class from the framework Xcode gives the following error: "Use of unresolved identifier BAOS"
I hope somebody can help. Thanks.

Xcode 6.1 upgrade - ViewController no longer conforms to protocol WKScriptMessageHandler

I'm using the WKScriptMessageHandler in my iOS App to receive messages from the Webkit. I'm using the WKScriptMessageHandler protocol, but apparently after upgrading Xcode to the most recent 6.1 upgrade, I am now getting this error message:
Type 'ViewController' does not conform to protocol 'WKScriptMessageHandler'
Any ideas on how this should be done now? Why did Apple change this
Here is my code below:
import UIKit
import WebKit
class ViewController: UIViewController, WKScriptMessageHandler {
#IBAction func fourButton(sender: UIButton){
performSegueWithIdentifier("login", sender: self)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func userContentController(userContentController: WKUserContentController!, didReceiveScriptMessage message: WKScriptMessage!){
println("got message: \(message.body)")
}
}
The function definition has changed, remove the exclamation marks:
func userContentController(userContentController: WKUserContentController, didReceiveScriptMessage message: WKScriptMessage)

UITextField - Can't unwrap Optional.None

I just started coding with Swift and I try to build a calculator. When I launch the simulator and I click the button '1' of the calculator it calls Tap0 function. I encountered the following issue: Can't unwrap Optional.None.
import UIKit
class ViewController: UIViewController {
#IBOutlet var display:UITextField
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
#IBAction func Tap0(sender:AnyObject){AddNumber("0")}
func AddNumber(x:String){
self.display.text="" //ERROR (Can't unwrap Optional.None)
println(self.display.text)
}
}
How I can solve it?
As what rdelmar suggested, to solve the error, connect display to the UITextField in StoryBoard:

Resources