使用运行iOS 10.1.1的iPhone6,Xcode 8.1,执行以下操作
我不断得到的Swift代码

错误消息出现在我的第一个ViewController甚至加载之前。
我搜索了类似(但不相同)的CarrierName问题的解决方案。他们中的大多数建议导入CoreTelephony。我添加了CoreTelephony,但我仍然遇到相同的错误。以下是显示viewDidLoad和控制台输出的代码段。对这个错误有任何见解吗?

//  ViewController.swift
//  MapLocator

import UIKit
import MapKit
import CoreLocation
import CoreTelephony


class ViewController: UIViewController, UISearchBarDelegate, MKMapViewDelegate,UINavigationControllerDelegate {
    var searchController:UISearchController!
    var annotation:MKAnnotation!
    var localSearchRequest1:MKLocalSearchRequest!
    var localSearchRequest2:MKLocalSearchRequest!
    var localSearch1:MKLocalSearch!
    var localSearch2:MKLocalSearch!
    var localSearchResponse1:MKLocalSearchResponse!
    var localSearchResponse2:MKLocalSearchResponse!
    var error:NSError!
    var pointAnnotation:MKPointAnnotation!
    var pinAnnotationView:MKPinAnnotationView!
    var placeMark1:MKPlacemark!
    var myRoute : MKRoute?
    var coord1 : CLLocationCoordinate2D!
    var coord2 : CLLocationCoordinate2D!
    //    var newPt : MKMapPoint!

    //    var lineArrayPtr = [MKMapPoint]()
    var lineArrayPtr:UnsafeMutablePointer<MKMapPoint>? = nil
    var pointIndex : Int = 0

    var lp1 : MKMapPoint!
    var lp2 : MKMapPoint!
    var lp3 : MKMapPoint!
    var lp4 : MKMapPoint!

    var searchButtonClicked = 0
    var buttonTouchCount : Double = 0
    let tapsPerMeter : Double = 2
    var pointsPerMeter : Double!
    var tapDistance : Double!

    //**************
    override func viewDidLoad() {
        super.viewDidLoad()
        mapView.delegate = self
        print("Entered viewDidLoad")

        let latitude_x: Double = 42.755139
        let longitude_x: Double = -71.584

        // Init the zoom level
        let coordinate:CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: latitude_x, longitude: longitude_x)
        //let span = MKCoordinateSpanMake(100, 80)
        let span = MKCoordinateSpanMake(0.01, 0.01)
        let region = MKCoordinateRegionMake(coordinate, span)
        self.mapView.setRegion(region, animated: true)
        print("mapView region set")

    }

最佳答案

CoreTelephony添加到AppDelegate的托盘也许吗?您的ViewController实现不访问任何CoreTelephony框架方法,因此您的问题出在其他地方。

10-08 05:42