我正在使用用Objective C编写的Sinch SDK(link)。

但是我正在制作一个Swift应用程序。我创建了桥头,并在视图控制器中添加了一些基本功能:

import UIKit

class ViewController: UIViewController, SINMessageClientDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

        initializeSinch()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    func initializeSinch()
    {
        // Instantiate a Sinch client object
        let sinchClient = Sinch.clientWithApplicationKey("xxxxxxxxxxxx", applicationSecret: "xxxxxxxxxx", environmentHost: "sandbox.sinch.com", userId: "user1")
        sinchClient.setSupportMessaging(true)
        sinchClient.start()

        let messageClient = sinchClient.messageClient()

        let message = SINOutgoingMessage(recipient: "user2", text: "Test 123, test 123")
        messageClient.sendMessage(message)
    }

    // Tells the delegate that a message has been received.
    func messageClient(messageClient: SINMessageClient, didReceiveIncomingMessage message: SINMessage) {
        // Present a Local Notification if app is in background
        if UIApplication.sharedApplication().applicationState == .Background {
            var notification: UILocalNotification = UILocalNotification()
            notification.alertBody = "Message from \(message.recipientIds[0])"
            UIApplication.sharedApplication().presentLocalNotificationNow(notification)
        }
        else {
            // Update UI in-app
        }

    }

    // Tells the delegate that a message for a specific recipient has been sent by the local user.
    func messageSent(message: SINMessage, recipientId: String) {
//        var a = 1
    }
//
    // Tells the delegate that a message has been delivered (to a particular recipient).
    func messageDelivered(info: SINMessageDeliveryInfo) {
//        var a = 1
    }

    func messageFailed(message: SINMessage, info messageFailureInfo: SINMessageFailureInfo) {
//        var a = 1
    }

}


这就是错误的样子。
ios - Sinch框架( objective-c )和Swift不兼容-LMLPHP

有人可以建议我该如何解决?

最佳答案

是否添加了所有必要的框架和链接器标志?

AudioToolbox.framework
AVFoundation.framework
Security.framework


需要添加一些其他链接器标志。在应用程序目标的“构建设置”窗格中,进行以下设置:

Other Linker Flags -> -ObjC -Xlinker -lc++


https://www.sinch.com/docs/voice/ios/

关于ios - Sinch框架( objective-c )和Swift不兼容,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34144346/

10-08 22:58