收到错误“无法将模块'MapKit'加载为'MapKit'”

ADK*_*ADK 1 iphone objective-c mapkit ios swift

这是我的第一个程序。而且,我正在实现MapKit。以下是代码:

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.
}}
Run Code Online (Sandbox Code Playgroud)

如果我不导入MapKit,则会收到错误消息,因为“弱可能仅适用于类和类绑定的协议类型”。如果这样做,我会得到标题中提到的错误。

我不明白我要去哪里错了。

Anb*_*hik 5

原因:您使用的框架名称和项目名称一样,根本不能相同。而且,这引起了冲突。只需修改您的项目名称,然后重试。它肯定会工作。