質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Swift Playground

Swift Playgroundは、Swiftをインタラクティブに習得できるiPad向けのアプリケーション。コーディングの知識は一切必要なく、Swift Playgrounds上でプログラミングしたコードによりドローン・ロボットを自在に動かすことが可能です。

iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

ビルド

ソースコードを単体で実行可能なソフトウェアへ変換する過程をビルド(build)と呼びます

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Q&A

1回答

1547閲覧

Swift ビルド時のエラー

sennin2911

総合スコア4

Swift Playground

Swift Playgroundは、Swiftをインタラクティブに習得できるiPad向けのアプリケーション。コーディングの知識は一切必要なく、Swift Playgrounds上でプログラミングしたコードによりドローン・ロボットを自在に動かすことが可能です。

iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

ビルド

ソースコードを単体で実行可能なソフトウェアへ変換する過程をビルド(build)と呼びます

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

0グッド

0クリップ

投稿2020/05/24 14:23

編集2020/05/24 14:24

Swift

1import UIKit 2import MapKit 3import CoreLocation 4 5class ViewController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate { 6 7 8 @IBOutlet weak var mapView: MKMapView! 9 @IBOutlet weak var addressLabel: UILabel! 10 11 12 override func viewDidLoad() { 13 super.viewDidLoad() 14 15 mapView.delegate = self 16 17 let span = MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05) 18 let location = CLLocationCoordinate2D(latitude: 36.6895000, longitude: 139.6917100) 19 20 let region = MKCoordinateRegion(center: location, span: span) 21 mapView.setRegion(region, animated: true) 22 23 24 25 } 26 27 func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) { 28 let currentLocation = mapView.centerCoordinate 29 let location = CLLocation(latitude: currentLocation.latitude, longitude: currentLocation.longitude) 30 geoCode(location: location) 31 32 } 33 34 func geoCode(location: CLLocation){ 35 LocationManager.sharedInstance.reverseGeocodeLocationWithCoordinates(coord: location) { (reverseGecodeInfo, placemark, error) in 36 guard let info = reverseGecodeInfo else{ return} 37 print(info) 38 } 39 } 40 41 } 42

上記のコードにより、MAPの中心点の住所や緯度経度といった情報をコンドールに表示したいです。
ビルドすると100個以上のエラーが返ってきます。
大抵は[FIX]で修正できましたが、以下のエラーがBiuldTime上に出ており、解決できません。

Type 'LocationManagerDelegate' has no member 'locationManagerVerboseMessage'

Type 'LocationManagerDelegate' has no member 'locationManagerVerboseMessage'

'parseAppleLocationData' is inaccessible due to 'private'

'parseAppleLocationData' is inaccessible due to 'private' protection level

Cannot convert value of type '([CLPlacemark]?, NSError?) -> Void' to expected argument type 'CLGeocodeCompletionHandler' (aka '(Optional<Array<CLPlacemark>>, Optional<Error>) -> ()')

Type 'CharacterSet' has no member 'URLQueryAllowedCharacterSet'

Type 'CharacterSet' has no member 'URLQueryAllowedCharacterSet'

'parseGoogleLocationData' is inaccessible due to 'private' protection level

'getAddressDictionary' is inaccessible due to 'private' protection level

'getPlacemark' is inaccessible due to 'private' protection levelprotection level

足りない情報がありましたら、お申し付けください。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

hoshi-takanori

2020/05/24 16:31

そのソースだと Use of unresolved identifier 'LocationManager' というエラーしか出ませんけど、関係のないエラーが大量に出ていますね。何が起きてるんだろう…。
thyda.eiqau

2020/05/26 10:13

LocationManagerのバージョンも提示してください
thyda.eiqau

2020/05/26 10:45

あと、LocationManagerは開発規模を縮小するのでPromiseKit/CoreLocationに移行せよと書いてありますが、LocationManagerを使わなければならない事情があるのでしたらその旨もご提示ください。 https://github.com/futuredapp/LocationManager
guest

回答1

0

「残念ながら」と言わざるを得ないですが、LocationManagerを使う方法と使う理由がまったく当方にはわかりませんでした。CLLocationManagerを使いやすくするためのライブラリなのだと思うのですが、素のCLLocationManagerのほうがGooglabilityが高いように思います。
というか地図の中心地点の住所を出すだけならCLLocationManagerさえ不要です。

swift

1import UIKit 2import MapKit 3 4class ViewController: UIViewController, MKMapViewDelegate { 5 @IBOutlet weak var mapView: MKMapView! 6 @IBOutlet weak var addressLabel: UILabel! 7 let locationManager: LocationManager = LocationManager.sharedManager 8 9 override func viewDidLoad() { 10 super.viewDidLoad() 11 12 mapView.delegate = self 13 14 let span = MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05) 15 let location = CLLocationCoordinate2D(latitude: 36.6895000, longitude: 139.6917100) 16 17 let region = MKCoordinateRegion(center: location, span: span) 18 mapView.setRegion(region, animated: true) 19 } 20 21 func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) { 22 print("map moved") 23 let currentLocation = mapView.centerCoordinate 24 let location = CLLocation(latitude: currentLocation.latitude, longitude: currentLocation.longitude) 25 // locationManager.currentLocation = location 26 27 let geoCoder: CLGeocoder = CLGeocoder() 28 geoCoder.reverseGeocodeLocation(location) { (placemarks, error) in 29 if let placemark = placemarks?.first { 30 let addresses: [String?] = [ 31 placemark.subThoroughfare, 32 placemark.subLocality ?? placemark.thoroughfare, 33 placemark.locality, 34 placemark.administrativeArea, 35 placemark.country, 36 placemark.postalCode 37 ]; 38 self.addressLabel.text = [ 39 "lat: (location.coordinate.latitude)", 40 "lng: (location.coordinate.longitude)", 41 (addresses.filter { $0 != nil } as! [String]).joined(separator: ", ") 42 ].joined(separator: "\n") 43 } 44 } 45 } 46}

Screen Recording

投稿2020/05/26 11:53

thyda.eiqau

総合スコア2982

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

thyda.eiqau

2020/05/26 11:55

あと、もともとのご質問のエラーですが、LocationManagerのGitHubではSwift5に対応したCommitがされていて最新は2.1.0ですが、CocoaPods側に反映されていない(おそらくpod trunk pushしていない)ためpod installすると1.0.1がインストールされるためだと思います
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問