Msmessagelivelayout Freeze/Crash in Transcript When Info.Plist Contains Privacy Request

MSMessageLiveLayout freeze/crash in transcript when info.plist contains privacy request

I have experienced the same thing with the camera plist entries.

It's an XCode bug, confirmed by Apple. You cannot do anything about it - once you have those entries in there you have crashes when you try to debug with XCode.

In my collection of iMessage samples I have a sample which explores this a bit further. It uses different plists so the Debug doesn't have camera permission.

How to avoid app crash if info.plist doesn't contain certain key?

You can check whether the key is added or not by the bellow code by reading info.plist file.

if let permission = Bundle.main.object(forInfoDictionaryKey: "NSCameraUsageDescription") as? String {
print(permission)
}

If permission is not there, we will not add code of request and show some alert like please add permission.

Also, there is one nice article that helps to identify missing permission before creating build.

https://medium.com/rosberryapps/swift-plist-and-two-smoking-scripts-94bb54cbeded

Error when invoke requestWhenInUseAuthorization for location permissions

There are couple of mistakes in your code like recursion in case user don’t give the permission for when in use so look at my code. Assuming you had added "Privacy - Location Always and When In Use Usage Description" and "Privacy - Location When In Use Usage Description" keys inside the info.plist. Below code works perfect without any issue and apple recommended.

import Foundation
import CoreLocation

typealias LocateMeCallback = (_ location: CLLocation?) -> Void

class LocationTracker: NSObject {

static let shared = LocationTracker()

var locationManager: CLLocationManager = {
let locationManager = CLLocationManager()
locationManager.activityType = .automotiveNavigation
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
locationManager.distanceFilter = 10

return locationManager
}()

var locateMeCallback: LocateMeCallback?
var currentLocation: CLLocation?
var isCurrentLocationAvailable: Bool {
return currentLocation != nil
}

func enableLocationServices() {
locationManager.delegate = self
switch CLLocationManager.authorizationStatus() {
case .notDetermined:
// Request when-in-use authorization initially
locationManager.requestWhenInUseAuthorization()
case .restricted, .denied:
// Disable location features
print("Fail permission to get current location of user")
case .authorizedWhenInUse:
// Enable basic location features
enableMyWhenInUseFeatures()
case .authorizedAlways:
// Enable any of your app's location features
enableMyAlwaysFeatures()
}
}

func enableMyWhenInUseFeatures() {
locationManager.startUpdatingLocation()
}

func enableMyAlwaysFeatures() {
locationManager.allowsBackgroundLocationUpdates = true
locationManager.pausesLocationUpdatesAutomatically = true
locationManager.startUpdatingLocation()
}

func locateMe(callback: @escaping LocateMeCallback) {
self.locateMeCallback = callback
enableLocationServices()
}

private override init() {}

}

// MARK: - CLLocationManagerDelegate
extension LocationTracker: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let location = locations.first else { return }
print("locations = \(location.coordinate.latitude) \(location.coordinate.longitude)")
locateMeCallback?(location)
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print(error.localizedDescription)
}
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
enableLocationServices()
}
}

Usage

LocationTracker.shared.locateMe {  location in
guard let location = location else {
print("Cann't retrieve current location of user")
return
}
// do what ever you want to do with location
}

xCode qlaunchsuccess Error

So far I tried everything on graver's post with no result, tried reinstalling XCode and resetting the device with no results.
I've submitted a bug report to Apple, #11740012. I hope it'll be answered, as this error is annoying the hell out of me, having to force reset the device each hour or two hours, and receiving this error many times an hour is a pain in the *!$!

UPDATED :Problem isn't solved for XCode 4.3, but upgrading to XCode 4.4 have solved the issue, so I recommend to upgrade to everyone with this problem



Related Topics



Leave a reply



Submit