So, my App (iOS, Swift 2.2, Xcode 7.3) got rejected by Beta App Review team because it crahsed on launch.
UPDATE Got an answer from the App Review Team...it's only crashing on iPad, not on iPhone.
The thing is that I can't reproduce this crash. Not even when testing on my 3 physical devices (iPhone 4S, iPhone6 and iPad Air) with a clean install nor update through TestFlight Internal Testing (so exactly the same build & archive as App Review Team is reviewing)
Extract of crash log (received from App Review Team) (symbolicated):
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000010032ced8
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 AppName 0x000000010032ced8 MapViewController.viewDidLoad() -> () (MapViewController.swift:210)
1 AppName 0x000000010032cf2c @objc MapViewController.viewDidLoad() -> () (MapViewController.swift:0)
2 UIKit 0x0000000187394b40 -[UIViewController loadViewIfRequired] + 996
MapViewController is the rootViewController of the UINavigationController and line 210 contains: self.view.backgroundColor = UIColor.blackColor()
UPDATE:
Removed that line and submitted another build. Same crash log, now crashing on the next line: imageview.hidden = true
Tried to run in "Release" config directly from Xcode on my Device, in the hope it would crash and point me in the right direction, however, no crash :-/ Also, very interesting, I had the same in a previous build of the same app (also got rejected). I sent the review team a reply similar to this story and they approved it for external beta testing (without any changes). Only one of my beta testers (aprox 300 total) reported a similar crash on startup.
Did a lot of googling on the Sigtrap breakpoint, but haven't found anything similar to what I'm experiencing. So, I'm really at a loss here. I can't reproduce it and the the crash log doesn't point me in any direction I could investigate.
UPDATE: Here is the complete (symbolicated) crash report I got from the App Review Team. (excl. Binary Images, all looked fine there). Perhaps something in there (other threads perhaps?) rings a bell for someone. Any help or suggestions would be appreciated.
Incident Identifier: 5A47A678-EDD0-400B-873F-4BF466E13218
CrashReporter Key: 31c74ad5c3da4b8205dc32464f9bc6fde2f4edea
Hardware Model: xxx
Process: AppName [2081]
Path: /private/var/containers/Bundle/Application/065CA51D-8981-419B-BEB8-3BD5255073E8/AppName.app/AppName
Identifier: com.pinguido.scenic
Version: 1 (1.08)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2016-05-06 20:56:49.49 -0700
Launch Time: 2016-05-06 20:56:49.49 -0700
OS Version: iOS 9.3.1 (13E238)
Report Version: 105
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000010032d7fc
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 AppName 0x000000010032d7fc MapViewController.viewDidLoad() -> () (MapViewController.swift:216)
1 AppName 0x000000010032d850 @objc MapViewController.viewDidLoad() -> () (MapViewController.swift:0)
2 UIKit 0x0000000187520b40 -[UIViewController loadViewIfRequired] + 996
3 UIKit 0x00000001875e1118 -[UINavigationController _layoutViewController:] + 72
4 UIKit 0x00000001875e0ff0 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 416
5 UIKit 0x00000001875e0238 -[UINavigationController _startTransition:fromViewController:toViewController:] + 144
6 UIKit 0x00000001875dfddc -[UINavigationController _startDeferredTransitionIfNeeded:] + 868
7 UIKit 0x00000001875dfa04 -[UINavigationController __viewWillLayoutSubviews] + 60
8 UIKit 0x00000001875df96c -[UILayoutContainerView layoutSubviews] + 208
9 UIKit 0x000000018751c0e4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 656
10 QuartzCore 0x0000000184ec2a28 -[CALayer layoutSublayers] + 148
11 QuartzCore 0x0000000184ebd634 CA::Layer::layout_if_needed(CA::Transaction*) + 292
12 QuartzCore 0x0000000184ebd4f4 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
13 QuartzCore 0x0000000184ebcb24 CA::Context::commit_transaction(CA::Transaction*) + 252
14 QuartzCore 0x0000000184ebc86c CA::Transaction::commit() + 512
15 QuartzCore 0x0000000184eb5dd8 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 80
16 CoreFoundation 0x00000001823947b0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
17 CoreFoundation 0x0000000182392554 __CFRunLoopDoObservers + 372
18 CoreFoundation 0x00000001822bcd30 CFRunLoopRunSpecific + 416
19 UIKit 0x000000018758f834 -[UIApplication _run] + 460
20 UIKit 0x0000000187589f70 UIApplicationMain + 204
21 AppName 0x000000010042be50 main (AppDelegate.swift:16)
22 libdyld.dylib 0x0000000181e5a8b8 start + 4
Thread 1:
0 libsystem_kernel.dylib 0x0000000181f78b48 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x0000000182041530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x0000000182041020 start_wqthread + 4
Thread 2 name: Dispatch queue: com.apple.libdispatch-manager
Thread 2:
0 libsystem_kernel.dylib 0x0000000181f794d8 kevent_qos + 8
1 libdispatch.dylib 0x0000000181e3c7d8 _dispatch_mgr_invoke + 232
2 libdispatch.dylib 0x0000000181e2b648 _dispatch_source_invoke + 0
Thread 3:
0 libsystem_kernel.dylib 0x0000000181f78b48 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x0000000182041530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x0000000182041020 start_wqthread + 4
Thread 4:
0 libsystem_kernel.dylib 0x0000000181f78b48 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x0000000182041530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x0000000182041020 start_wqthread + 4
Thread 5:
0 libsystem_kernel.dylib 0x0000000181f7841c __semwait_signal + 8
1 libsystem_c.dylib 0x0000000181e9522c nanosleep + 212
2 libsystem_c.dylib 0x0000000181e9514c usleep + 68
3 AppName 0x000000010086ac48 recvTimeout + 196
4 AppName 0x000000010086f864 ConnectionWrapper::recv() + 192
5 AppName 0x000000010086fed4 HttpUtils::readHttpStatusLine(ConnectionWrapper&, unsigned short&) + 68
6 AppName 0x000000010086de90 skobbler::HTTP::HttpRequest::receiveAnswerImpl(bool) + 64
7 AppName 0x000000010086d878 skobbler::HTTP::HttpRequest::receiveAnswer(bool) + 44
8 AppName 0x000000010086c4ec skobbler::HTTP::HttpManager::HttpWorkerThread::processRequest() + 88
9 AppName 0x000000010086c938 skobbler::HTTP::HttpManager::HttpWorkerThread::runHelper(void*) + 48
10 libsystem_pthread.dylib 0x0000000182043b28 _pthread_body + 156
11 libsystem_pthread.dylib 0x0000000182043a8c _pthread_body + 0
12 libsystem_pthread.dylib 0x0000000182041028 thread_start + 4
Thread 6:
0 libsystem_kernel.dylib 0x0000000181f77f24 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x0000000182042ce8 _pthread_cond_wait + 648
2 AppName 0x000000010080b7ec RouteManager::run() + 2588
3 AppName 0x0000000100807d74 RouteManager::runHelper(void*) + 12
4 libsystem_pthread.dylib 0x0000000182043b28 _pthread_body + 156
5 libsystem_pthread.dylib 0x0000000182043a8c _pthread_body + 0
6 libsystem_pthread.dylib 0x0000000182041028 thread_start + 4
Thread 7:
0 libsystem_kernel.dylib 0x0000000181f7841c __semwait_signal + 8
1 libsystem_c.dylib 0x0000000181e9522c nanosleep + 212
2 libsystem_c.dylib 0x0000000181e9514c usleep + 68
3 AppName 0x000000010086ac48 recvTimeout + 196
4 AppName 0x000000010086f864 ConnectionWrapper::recv() + 192
5 AppName 0x000000010086fed4 HttpUtils::readHttpStatusLine(ConnectionWrapper&, unsigned short&) + 68
6 AppName 0x000000010086de90 skobbler::HTTP::HttpRequest::receiveAnswerImpl(bool) + 64
7 AppName 0x000000010086d878 skobbler::HTTP::HttpRequest::receiveAnswer(bool) + 44
8 AppName 0x000000010086c4ec skobbler::HTTP::HttpManager::HttpWorkerThread::processRequest() + 88
9 AppName 0x000000010086c938 skobbler::HTTP::HttpManager::HttpWorkerThread::runHelper(void*) + 48
10 libsystem_pthread.dylib 0x0000000182043b28 _pthread_body + 156
11 libsystem_pthread.dylib 0x0000000182043a8c _pthread_body + 0
12 libsystem_pthread.dylib 0x0000000182041028 thread_start + 4
Thread 8:
0 libsystem_kernel.dylib 0x0000000181f77f24 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x0000000182042d20 _pthread_cond_wait + 704
2 AppName 0x00000001007b64e4 SkTimer<MapMatcher, &(MapMatcher::positioningRoutineWrapper(MapMatcher*))>::entryPoint(void*) + 120
3 libsystem_pthread.dylib 0x0000000182043b28 _pthread_body + 156
4 libsystem_pthread.dylib 0x0000000182043a8c _pthread_body + 0
5 libsystem_pthread.dylib 0x0000000182041028 thread_start + 4
Thread 9:
0 libsystem_kernel.dylib 0x0000000181f77f24 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x0000000182042ce8 _pthread_cond_wait + 648
2 AppName 0x00000001006d1354 ThreadWorker::run() + 72
3 AppName 0x000000010080107c RunInThread::runHelper(void*) + 28
4 libsystem_pthread.dylib 0x0000000182043b28 _pthread_body + 156
5 libsystem_pthread.dylib 0x0000000182043a8c _pthread_body + 0
6 libsystem_pthread.dylib 0x0000000182041028 thread_start + 4
Thread 10:
0 libsystem_kernel.dylib 0x0000000181f77f24 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x0000000182042ce8 _pthread_cond_wait + 648
2 AppName 0x0000000100622cf0 TileLoader<MapRenderer>::run() + 2512
3 AppName 0x0000000100770974 TileLoader<MapRenderer>::runHelper(void*) + 12
4 libsystem_pthread.dylib 0x0000000182043b28 _pthread_body + 156
5 libsystem_pthread.dylib 0x0000000182043a8c _pthread_body + 0
6 libsystem_pthread.dylib 0x0000000182041028 thread_start + 4
Thread 11:
0 libsystem_kernel.dylib 0x0000000181f77f24 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x0000000182042d20 _pthread_cond_wait + 704
2 AppName 0x00000001007748c4 SkTimer<ReRenderTimer, &(ReRenderTimer::reRenderRoutine(ReRenderTimer*))>::entryPoint(void*) + 120
3 libsystem_pthread.dylib 0x0000000182043b28 _pthread_body + 156
4 libsystem_pthread.dylib 0x0000000182043a8c _pthread_body + 0
5 libsystem_pthread.dylib 0x0000000182041028 thread_start + 4
Thread 12:
0 libsystem_kernel.dylib 0x0000000181f77f24 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x0000000182042d20 _pthread_cond_wait + 704
2 AppName 0x00000001007747f0 SkTimer<AnimationTimer, &(AnimationTimer::animationTimerRoutine(AnimationTimer*))>::entryPoint(void*) + 120
3 libsystem_pthread.dylib 0x0000000182043b28 _pthread_body + 156
4 libsystem_pthread.dylib 0x0000000182043a8c _pthread_body + 0
5 libsystem_pthread.dylib 0x0000000182041028 thread_start + 4
Thread 13:
0 libsystem_kernel.dylib 0x0000000181f77f24 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x0000000182042ce8 _pthread_cond_wait + 648
2 AppName 0x00000001006a46c4 WorldTextures::WorkerThreadRoutine(void*) + 100
3 libsystem_pthread.dylib 0x0000000182043b28 _pthread_body + 156
4 libsystem_pthread.dylib 0x0000000182043a8c _pthread_body + 0
5 libsystem_pthread.dylib 0x0000000182041028 thread_start + 4
Thread 14:
0 libsystem_kernel.dylib 0x0000000181f77f24 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x0000000182042ce8 _pthread_cond_wait + 648
2 AppName 0x00000001006aa2ac EarthSphere::WorkerThreadRoutine(void*) + 120
3 libsystem_pthread.dylib 0x0000000182043b28 _pthread_body + 156
4 libsystem_pthread.dylib 0x0000000182043a8c _pthread_body + 0
5 libsystem_pthread.dylib 0x0000000182041028 thread_start + 4
Thread 15:
0 libsystem_kernel.dylib 0x0000000181f77f24 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x0000000182042ce8 _pthread_cond_wait + 648
2 AppName 0x00000001006e2fdc MapSearch::runLoop(void*) + 128
3 libsystem_pthread.dylib 0x0000000182043b28 _pthread_body + 156
4 libsystem_pthread.dylib 0x0000000182043a8c _pthread_body + 0
5 libsystem_pthread.dylib 0x0000000182041028 thread_start + 4
Thread 16:
0 libsystem_kernel.dylib 0x0000000181f77f24 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x0000000182042d20 _pthread_cond_wait + 704
2 AppName 0x000000010077fa34 SkTimer<FcdCollector, &(FcdCollector::timerRoutineWrapper(FcdCollector*))>::entryPoint(void*) + 120
3 libsystem_pthread.dylib 0x0000000182043b28 _pthread_body + 156
4 libsystem_pthread.dylib 0x0000000182043a8c _pthread_body + 0
5 libsystem_pthread.dylib 0x0000000182041028 thread_start + 4
Thread 17:
0 libsystem_kernel.dylib 0x0000000181f7841c __semwait_signal + 8
1 libsystem_c.dylib 0x0000000181e9522c nanosleep + 212
2 libsystem_c.dylib 0x0000000181efe09c sleep + 44
3 AppName 0x00000001008010a4 TimerTarget::run() + 20
4 AppName 0x000000010080107c RunInThread::runHelper(void*) + 28
5 libsystem_pthread.dylib 0x0000000182043b28 _pthread_body + 156
6 libsystem_pthread.dylib 0x0000000182043a8c _pthread_body + 0
7 libsystem_pthread.dylib 0x0000000182041028 thread_start + 4
Thread 18:
0 libsystem_kernel.dylib 0x0000000181f78b48 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x0000000182041530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x0000000182041020 start_wqthread + 4
Thread 19:
0 libsystem_kernel.dylib 0x0000000181f78b48 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x0000000182041530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x0000000182041020 start_wqthread + 4
EDIT
As some people asked in the comments, here is the code from my AppDelegate's didFinishLaunchingWithOptions
and my rootVC's viewDidLoad
As I mentioned, I don't think it's anything in my viewDidLoad as it always crashes on the first line of the viewDidLoad. I'm guessing it's something in my AppDel or perhaps something global... i.e. something that is executed before my rootVC's viewDidLoad.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
print("APPDEL: applicationDidFinishLaunching")
appWasCompletelyClosed = true
// Set SKMaps API Key & Light Map
let initSettings: SKMapsInitSettings = SKMapsInitSettings()
initSettings.mapDetailLevel = SKMapDetailLevel.Light
initSettings.showConsoleLogs = false
SKMapsService.sharedInstance().initializeSKMapsWithAPIKey(SKMapsAPIKey, settings: initSettings)
if UD.appVersion == nil || UD.appVersion != "\(NSBundle.mainBundle().infoDictionary!["CFBundleVersion"]!)" {
startClean()
UD.appVersion = "\(NSBundle.mainBundle().infoDictionary!["CFBundleVersion"]!)"
}
// Get IAP Products & Prices
IAPHelper.sharedInstance.requestProducts(){(success) -> Void in
if !success {
printError("Error getting IAP Products")
}
}
if UD.userID == nil {
print("First Launch")
copyCleanDBtoApplicationsFolder()
MagicalRecord.setupCoreDataStackWithStoreNamed("scenic.sqlite")
LastSync.resetAll()
firstLaunch = true
UD.userID = NSUUID().UUIDString
print(UD.userID)
let newUser = User.MR_createEntity()
newUser.id = UD.userID
newUser.addedOn = NSDate()
newUser.lastChanged = NSDate()
newUser.points = 0
newUser.pointsToNextLevel = 5
newUser.level = 0
newUser.rankWorld = 0
newUser.rankCountry = 0
#if DEBUG
newUser.offlineMapCredits = 100
#else
newUser.offlineMapCredits = 5
#endif
saveContext()
self.setUserDefaultsForFirstTime()
self.createSubDirs()
Sync.user() {(error) -> Void in
if error {
print("There was an error creating the new user on the server. Will try again before next sync action.")
}
else {
print("User succesfully created on the server.")
UD.userUploadedFirstTime = true
}
}
}
else {
MagicalRecord.setupCoreDataStackWithStoreNamed("scenic.sqlite")
}
// Initialize cache with offline map regions
SKMapsService.sharedInstance().mapsVersioningManager.delegate = self
SKTDownloadManager.sharedInstance()
//cachedMapRegions = Array<MapRegion>()
// Set Map to Offline if "Get Map Data Online" is set to No
setMapConnectivityMode()
if TripLogger.sharedInstance.logFileExists() {
appClosedDuringTrip = true
}
print("APPDEL: end of applicationDidFinishLaunching")
return true
}
viewDidLoad:
override func viewDidLoad() {
super.viewDidLoad()
print("MAPVC: viewDidLoad")
//self.view.backgroundColor = UIColor.blackColor()
// UI Stuff
profilePicImageView.hidden = true
profilePicShadowView.hidden = true
profilePicImageViewTopConstraint.constant -= 30
profilePicShadowViewTopConstraint.constant -= 30
searchBar.hidden = true
searchBarTopConstraint.constant -= 30
settingsButton.hidden = true
settingsButtonTopConstraint.constant -= 30
centerOnCurrentLocationButton.hidden = true
centerOnCurrentLocationButtonLeadingConstraint.constant -= 30
locationsButton.hidden = true
locationsButtonLeadingConstraint.constant -= 30
startButton.hidden = true
startButtonBottomConstraint.constant -= 30
routesButton.hidden = true
routesButtonTrailingConstraint.constant -= 30
locationsMenuWidth.constant = 0
locationsMenuHeight.constant = 0
routesMenuWidth.constant = 0
routesMenuHeight.constant = 0
self.view.layoutIfNeeded()
routesMenu.hidden = true
locationsMenu.hidden = true
centerOnCurrentLocationButtonIsHidden = centerOnCurrentLocationButton.hidden
navInfoView.hidden = true
searchResultsTableView.hidden = true
cancelSearchButton.hidden = true
profileTableView.hidden = true
profileTableView.layer.cornerRadius = theme.cornerRadius
profileTableView.layer.masksToBounds = false
profileTableView.backgroundColor = theme.buttonBackgroundColor
profileTableView.clipsToBounds = true
searchResultsTableView.hidden = true
searchResultsTableView.layer.cornerRadius = theme.cornerRadius
searchResultsTableView.layer.masksToBounds = false
searchResultsTableView.backgroundColor = theme.buttonBackgroundColor
searchResultsTableView.clipsToBounds = true
// ForceTouchRecognizer
let forceTouches: Array<DFContinuousForceTouchGestureRecognizer> = [forceTouchRoutesButton, forceTouchLocationsButton]
for f in forceTouches {
f.timeout = 0.5
f.forceTouchDelay = 0.3
f.baseForceTouchPressure = 3.0
f.triggeringForceTouchPressure = 6.0
f.delegate = self
}
locationsButton.addGestureRecognizer(forceTouchLocationsButton)
routesButton.addGestureRecognizer(forceTouchRoutesButton)
// Search Bar
HNKGooglePlacesAutocompleteQuery.setupSharedQueryWithAPIKey(GooglePlacesAPIKey)
searchBar.delegate = self
searchResultsTableView.delegate = self
searchResultsTableView.dataSource = self
self.automaticallyAdjustsScrollViewInsets = false
searchBar.setBackgroundImage(UIImage(), forBarPosition: .Any, barMetrics: .Default)
searchBar.barTintColor = UIColor.clearColor()
// Vehicle TableViewSlider
vehiclesImageSliderView = PRSlideView()
vehiclesImageSliderView.delegate = self
vehiclesImageSliderView.dataSource = self
vehiclesImageSliderView.scrollDirection = .Horizontal
vehiclesImageSliderView.infiniteScrollingEnabled = false
vehiclesImageSliderView.registerClass(
PRAlbumPage.self,
identifier: PRAlbumPage.description()
)
// Browse Routes
routesInMapAreaView.hidden = true
filterView.hidden = true
configureFilters()
// Profile TableView
tvc = UITableViewController()
tvc.tableView = self.profileTableView
profileTableView.delegate = self
profileTableView.dataSource = self
let refreshControl = UIRefreshControl()
refreshControl.frameHeight = 40
refreshControl.attributedTitle = NSAttributedString(string: String.localizedStringWithFormat(NSLocalizedString("Last update: %@",comment:"Refreshcontrol subtitle"),LastSync.users.timeAgoSinceNowOrNever()), attributes: [NSForegroundColorAttributeName:theme.textColor])
weak var weakSelf: MapViewController? = self
refreshControl.addTarget(weakSelf, action: #selector(MapViewController.tableRefresh), forControlEvents: UIControlEvents.ValueChanged)
tvc.refreshControl = refreshControl
let appDelegate = UIApplication.sharedApplication().delegate! as! AppDelegate
if appDelegate.appWasCompletelyClosed && UD.mapUnfolding! {
foldMapOpen()
}
else {
switch CLLocationManager.authorizationStatus() {
case CLAuthorizationStatus.NotDetermined:
self.locManager = CLLocationManager()
self.locManager.delegate = self
self.locManager.requestAlwaysAuthorization()
case CLAuthorizationStatus.Denied:
dispatch_async(dispatch_get_main_queue()) {
self.initializeAndAnimateMap(false)
}
default:
dispatch_async(dispatch_get_main_queue()) {
self.initializeAndAnimateMap(true)
}
}
}
let subMenuButtons: Array<UIButton> = [favoriteRoutesButton, createRouteButton, importRoutesButton, showRoutesButton, favoriteLocationsButton, createLocationButton, importLocationButton]
for subMenuButton in subMenuButtons {
subMenuButton.setLayerProperties(backgroundColor: UIColor.clearColor(), opacity: nil, cornerRadius: 12, borderColor: theme.tintColor, borderWidth: theme.borderWidth, shadowOffset: nil)
}
myTripsButton.setLayerProperties(backgroundColor: UIColor.clearColor(), opacity: nil, cornerRadius: 12, borderColor: theme.okGreenColor, borderWidth: theme.borderWidth, shadowOffset: nil)
let closeButtons: Array<UIButton> = [closeNavInfoButton, closeRoutesInMapAreaButton, closeFilterViewButton]
for button in closeButtons {
button.layer.cornerRadius = 10
button.setTitle("✕", forState: .Normal)
button.titleLabel?.textAlignment = NSTextAlignment.Center
button.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0)
button.titleLabel?.font = UIFont(name: "HelveticaNeue-Bold", size: 14)
button.backgroundColor = theme.tintColor
}
routeAvoidanceSelector = WLHorizontalSegmentedControl(items: ["avoid Tolls","avoid Highway","avoid Ferries"])
routeAvoidanceSelector.allowsMultiSelection = true
routeAvoidanceSelector.addTarget(weakSelf, action: #selector(MapViewController.routeAvoidanceChanged), forControlEvents: UIControlEvents.ValueChanged)
let segControlFont = UIFont.systemFontOfSize(11, weight: UIFontWeightMedium)
let attr = Dictionary(dictionaryLiteral: (NSFontAttributeName, segControlFont))
routeModeSelector.setTitleTextAttributes(attr, forState: UIControlState.Normal)
routeModeSelector.selectedSegmentIndex = UD.routeMode!.rawValue
vehicleTypeSelector.selectedSegmentIndex = UD.vehicleType!.rawValue
setSelectedRouteAvoidances()
routeAvoidanceSelector.tintColor = theme.tintColor
guidanceToStartSwitch.setOn(UD.guideToStart!, animated: false)
navInfoView.layer.masksToBounds = true
vehicleTypeImageView.roundCorners(UIRectCorner.BottomRight, radius: theme.textViewCornerRadius)
vehicleTypeImageView.roundCorners([UIRectCorner.TopLeft,UIRectCorner.BottomRight], radius: theme.textViewCornerRadius)
vehicleTypeImageView.layer.masksToBounds = true
NSNotificationCenter.defaultCenter().addObserver(
self,
selector: #selector(MapViewController.resigningActive),
name: UIApplicationWillResignActiveNotification,
object: nil
)
NSNotificationCenter.defaultCenter().addObserver(
self,
selector: #selector(MapViewController.becomeActive),
name: UIApplicationDidBecomeActiveNotification,
object: nil
)
NSNotificationCenter.defaultCenter().addObserver(
self,
selector: #selector(MapViewController.deviceRotated),
name: UIDeviceOrientationDidChangeNotification,
object: nil
)
}
Haha,
--@RJE... it was your comment that made me double check if I was forcefully unwrapping an optional. If you want the bounty, post an answer and I'll assign it to you! Thanks! – guido 5 hours ago"--
Bounties are always important,
Anyway it is very important to know that what is SIGTRAP means. It is basically a run-time exception not an error. So if you cannot really find the issue you have to check that if there are any places which can course an exception. (specially with Swift optional types)
Usually it can be array index out of bound or unwrapping nil or any thing similar. Also if it only occurs sometimes or only on some device there is a possibility of a issue due to various delays of UI animations.(e.g. presentViewController withAnimation and trying some thing before its completion.)
But honestly I don't see any issue with your original code. It shouldn't have crashed.
Unless if Storyboard's initial point is a UINavigationController and you forgot to set its class as a CustomNavigationController. Then it will crash at below code. (this is expected in Swift).
let navController = window!.rootViewController as! CustomNavigationController
But I don't think that this is the issue. Coz it should have crashed every time on any device.
And also by the time applicationDidBecomeActive called window wont be nil. So it can be some thing else you are doing with navController after this point.
Or may be Apple's review team tested your app on a faulty device :)