iOS 12 Freeze application

Hello everyone I have a very strange issue with iOS 12, my application is a simple table of all the games I did in iOS, the project, I did with swift 4 for iOS 11 with XCode 9, I use a simple Storyboard with 2 view controllers with table views and also includes a Share Extension, everything works normally until iOS 11.4.1, now when I upgraded XCode 10 with iOS 12, it worked normally in the simulator and in an iPhone SE in debug mode, the problem arose when I uploaded a build to Testflight and the application was installed on an iPhone 6 Plus, the screen is completely frozen, the share extension works but the application does not I saw 2 questions related to this first and second, but without answer and that is why I also share my code:


// AppDelegate.swift
// MenuGames
// Created by Dennis Mostajo on 7/3/18.
// Copyright © 2018 MenuGames. All rights reserved.
//
import UIKit
import Fabric
import Crashlytics
import Firebase

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
{
  var window: UIWindow?
  var navigationVC: UINavigationController?
  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  debugPrint("applicationWillResignActive")
  Fabric.with([Crashlytics.self])
  DataBaseHelper.DBUpdate() // Run migrations
  self.initializeFCM(_application: application)
  debugPrint("AppDelegate: launch")
  return true
  }
  func applicationWillResignActive(_ application: UIApplication) {
  debugPrint("applicationWillResignActive")
  }
  func applicationDidEnterBackground(_ application: UIApplication) {
  debugPrint("applicationDidEnterBackground")
  }
  func applicationWillEnterForeground(_ application: UIApplication) {
  debugPrint("applicationWillEnterForeground")
  }
  func applicationDidBecomeActive(_ application: UIApplication)
  {
  debugPrint("applicationDidBecomeActive")
  } 
  func applicationWillTerminate(_ application: UIApplication) {
  debugPrint("applicationWillTerminate")
  }
  // MARK: - FIREBASE
  func initializeFCM(_application:UIApplication)
  {
  print("initializeFCM")
  FirebaseApp.configure()
  Messaging.messaging().delegate = self
  Messaging.messaging().shouldEstablishDirectChannel = true
  }
}

extension AppDelegate : MessagingDelegate {
  // [START refresh_token]
  func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
  print("Firebase registration token: \(fcmToken)")
  InstanceID.instanceID().instanceID
  {
  (result, error) in
  if let error = error
  {
  debugPrint("Error fetching remote instange ID: \(error)")
  }
  else if let result = result
  {
  debugPrint("Remote instance ID token: \(result.token)")
  }
  }
  let dataDict:[String: String] = ["token": fcmToken]
  NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
  }
  func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage) {
  print("Received data message: \(remoteMessage.appData)")
  }
  // [END ios_10_data_message]
}


// Home.swift
// MenuGames
// Created by Dennis Mostajo on 7/3/18.
// Copyright © 2018 MenuGames. All rights reserved.
//

import UIKit
import RealmSwift
import Foundation
import MessageUI
import PKHUD
import Toast_Swift

class Home: UIViewController, UITableViewDelegate, UITableViewDataSource, MFMailComposeViewControllerDelegate
{
let imgView = UIImageView(frame: CGRect(x: 8, y: 6, width: 33, height: 33))
let titleLabel = UILabel(frame:CGRect(x:45, y:12, width:140, height:21))
@IBOutlet var table: UITableView!
var reachability: Reachability!
fileprivate var offlineToast: UIView!
var isToastShowing: Bool {
  get {
  return !((self.offlineToast?.isHidden) ?? true)
  }
}

// MARK: - viewDidLoad
override func viewDidLoad() {
  super.viewDidLoad()
  // Do any additional setup after loading the view.
  self.checkConnections()
}
override func didReceiveMemoryWarning() {
  super.didReceiveMemoryWarning()
  // Dispose of any resources that can be recreated.
}
override func viewWillAppear(_ animated: Bool) {
  super.viewWillAppear(animated)
  self.setupCustomNavigationBar()
  self.showNavBarItems()
}
override func viewWillDisappear(_ animated: Bool) {
  super.viewWillDisappear(animated)
  self.hideNavBarItems()
}
// MARK: - Methods
func setupCustomNavigationBar()
{
  let settings = DataBaseHelper.getSettings(settings_id: 1)
  var themeColor:ThemeColor!
  var imgIcon:UIImage!
  if (settings?.isDefaultThemeColor)!
  {
  themeColor = DataBaseHelper.getThemeColor(theme_color_id: 1)
  let imgBackground = UIImage(named:"background")
  self.navigationController?.navigationBar.setBackgroundImage(imgBackground?.resizableImage(withCapInsets: UIEdgeInsetsMake(0, 0, 0, 0), resizingMode: .stretch), for: .default)
  imgIcon = UIImage(named:"icon")
  }
  else
  {
  themeColor = DataBaseHelper.getThemeColor(theme_color_id: 2)
  imgIcon = UIImage(named:"darkIcon")
  }
  self.table.separatorColor = self.hexStringToUIColor(hex: themeColor.settings_navigation_text_color)
  self.table.tableFooterView = UIView()
  self.navigationController?.navigationBar.barTintColor = self.hexStringToUIColor(hex: themeColor.settings_navigation_background_color)
  self.imgView.contentMode = .scaleAspectFit
  self.imgView.image = imgIcon
  self.titleLabel.font = UIFont.boldSystemFont(ofSize: 17)
  self.titleLabel.textColor = self.hexStringToUIColor(hex: themeColor.settings_navigation_text_color)
  self.titleLabel.text = "Menu Games"
  self.navigationController?.navigationBar.addSubview(imgView)
  self.navigationController?.navigationBar.addSubview(titleLabel)
}
func showNavBarItems()
{
  self.imgView.isHidden = false
  self.titleLabel.isHidden = false
}
func hideNavBarItems()
{
  self.imgView.isHidden = true
  self.titleLabel.isHidden = true
}
func showAlertGlobally(_ alert: UIAlertController) {
  let alertWindow = UIWindow(frame: UIScreen.main.bounds)
  alertWindow.windowLevel = UIWindowLevelAlert
  alertWindow.rootViewController = UIViewController()
  alertWindow.makeKeyAndVisible()
  alertWindow.rootViewController?.present(alert, animated: true, completion: nil)
}
func redirectLogToDocuments() -> String {

  let allPaths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
  let documentsDirectory = allPaths.first!
  let pathForLog: String = documentsDirectory + "/logs.txt"

  return pathForLog
}
func checkConnections()
{
  do {
  reachability = Reachability()
  offlineToast = try self.view.toastViewForMessage(NSLocalizedString("NO_CONNECTION", comment: "You have no connection"), title: "", image: UIImage(named: "icon"), style: ToastStyle())
  } catch {
  debugPrint("Unable to create Reachability")
  }
  guard let _ = reachability, let _ = offlineToast else {
  return
  }

  reachability.whenReachable = { [weak self] reachability in
  DispatchQueue.main.async {
  self?.offlineToast.isHidden = true
  }
  }

  reachability.whenUnreachable = { [weak self] reachability in
  DispatchQueue.main.async {
  self?.showConnectiontoast()
  self?.offlineToast.isHidden = false
  }
  }

  do {
  try reachability.startNotifier()
  } catch {
  print("Unable to start notifier")
  }
}
func showConnectiontoast(){
  self.view.showToast(self.offlineToast, duration: TimeInterval.infinity, position: .center) { _ in
  self.showConnectiontoast()
  }
}
func hexStringToUIColor (hex:String) -> UIColor {
  var cString:String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()

  if (cString.hasPrefix("#")) {
  cString.remove(at: cString.startIndex)
  }

  if ((cString.count) != 6) {
  return UIColor.gray
  }

  var rgbValue:UInt32 = 0
  Scanner(string: cString).scanHexInt32(&rgbValue)

  return UIColor(
  red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
  green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
  blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
  alpha: CGFloat(1.0)
  )
}
// MARK: - MFMailComposeViewController
func mailComposeController(_ controller: MFMailComposeViewController,
  didFinishWith result: MFMailComposeResult, error: Error?) {
  // Check the result or perform other tasks.

  // Dismiss the mail compose view controller.
  controller.dismiss(animated: true, completion: nil)
}
// MARK: - UITableView
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat
{
  var height:CGFloat = 0
  if tableView == self.table
  {
  height = 25
  }
  return height
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
  var height:CGFloat = 0
  if tableView == self.table
  {
  height = 50
  }
  return height
}
func numberOfSections(in tableView: UITableView) -> Int {
  var sections:Int = 0
  if tableView == self.table
  {
  sections = 2
  }
  return sections
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
  var rows:Int = 0
  if tableView == self.table
  {
  switch section
  {
  case 0:
  rows = 2
  break
  case 1:
  rows = 4
  break
  default:
  break
  }
  }
  return rows
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
{
  let settings = DataBaseHelper.getSettings(settings_id: 1)
  var themeColor:ThemeColor!
  if (settings?.isDefaultThemeColor)!
  {
  themeColor = DataBaseHelper.getThemeColor(theme_color_id: 1)
  }
  else
  {
  themeColor = DataBaseHelper.getThemeColor(theme_color_id: 2)
  }
  let headerView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.bounds.size.width, height: 25))
  headerView.backgroundColor = self.hexStringToUIColor(hex: themeColor.settings_header_section_background_color)
  let label = UILabel(frame: CGRect(x: 10, y: 0, width: view.frame.size.width, height: 25))
  label.textColor = self.hexStringToUIColor(hex: themeColor.settings_header_section_text_color)
  label.font = UIFont.boldSystemFont(ofSize: 17)
  headerView.addSubview(label)
  if (section == 0) {
  label.text = NSLocalizedString("GENERAL_TITLE", comment: "General Title Section")
  } else {
  label.text = NSLocalizedString("HELP_TITLE", comment: "Help Title Section")
  }
  return headerView
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
  let settings = DataBaseHelper.getSettings(settings_id: 1)
  var themeColor:ThemeColor!
  if (settings?.isDefaultThemeColor)!
  {
  themeColor = DataBaseHelper.getThemeColor(theme_color_id: 1)
  }
  else
  {
  themeColor = DataBaseHelper.getThemeColor(theme_color_id: 2)
  }
  let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.subtitle, reuseIdentifier: "cell")
  cell.backgroundColor = self.hexStringToUIColor(hex: themeColor.settings_cell_background_color)
  cell.textLabel?.textColor = self.hexStringToUIColor(hex: themeColor.settings_cell_text_color)
  let cellHighLighting = UIImageView(frame: CGRect(x: 0, y: 0, width: cell.bounds.size.width, height: cell.bounds.size.height))
  cellHighLighting.image = UIImage(named: "Frame")
  cell.selectedBackgroundView = cellHighLighting
  if tableView == self.table
  {
  switch indexPath.section
  {
  case 0 :
  switch indexPath.row
  {
  case 0:
  cell.textLabel?.text = NSLocalizedString("ACCOUNT_TITLE", comment: "Account Title Row")
  break
  case 1:
  cell.textLabel?.text = NSLocalizedString("GAME_TITLE", comment: "Game Title Row")
  break
  default:
  break
  }
  break
  case 1 :
  switch indexPath.row
  {
  case 0:
  cell.textLabel?.text = NSLocalizedString("ABOUT_TITLE", comment: "About Title Row")
  break
  case 1:
  cell.textLabel?.text = NSLocalizedString("REPORT_TITLE", comment: "Report Title Row")
  break
  case 2:
  cell.textLabel?.text = NSLocalizedString("TUTORIAL_TITLE", comment: "Tutorial Title Row")
  break
  case 3:
  cell.textLabel?.text = NSLocalizedString("FEATURES_TITLE", comment: "Features Title Row")
  break
  default:
  break
  }
  break
  default:
  break
  }
  }
  return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
  if tableView == self.table
  {
  switch indexPath.section
  {
  case 0:
  switch indexPath.row
  {
  case 0:
  let user = DataBaseHelper.getUser()
  let user_type = DataBaseHelper.getUserTypeById(user_type_id: (user?.user_type_id)!)
  if (user_type?.name == "REGISTERED")||(user_type?.name == "PAID")
  {
  let storyboard = UIStoryboard(name: "Main", bundle: nil)
  let vc = storyboard.instantiateViewController(withIdentifier: "AccountVc") as! AccountVc
  self.navigationController?.pushViewController(vc, animated: true)
  }
  else
  {
  let alert = UIAlertController(title: "Menu Games", message: NSLocalizedString("IF_USER_NOT_LOGIN", comment: "if user not login"), preferredStyle: UIAlertControllerStyle.alert)
  alert.addAction(UIAlertAction(title: NSLocalizedString("SIGNUP", comment: "sign up"), style: .default, handler: { (action: UIAlertAction!) in
  debugPrint("sign up")
  let storyboard = UIStoryboard(name: "Main", bundle: nil)
  let vc = storyboard.instantiateViewController(withIdentifier: "LoginVc") as! LoginVc
  vc.isForLogin = false
  self.navigationController?.pushViewController(vc, animated: true)
  }))
  alert.addAction(UIAlertAction(title: NSLocalizedString("LOGIN", comment: "login"), style: .default, handler: { (action: UIAlertAction!) in
  debugPrint("login")
  let storyboard = UIStoryboard(name: "Main", bundle: nil)
  let vc = storyboard.instantiateViewController(withIdentifier: "LoginVc") as! LoginVc
  vc.isForLogin = true
  self.navigationController?.pushViewController(vc, animated: true)
  }))
  alert.addAction(UIAlertAction(title: NSLocalizedString("CANCEL", comment: "cancel"), style: .cancel, handler: { (action: UIAlertAction!) in
  debugPrint("cancel")
  }))
  self.showAlertGlobally(alert)
  }
  break
  case 1:
  let storyboard = UIStoryboard(name: "Main", bundle: nil)
  let vc = storyboard.instantiateViewController(withIdentifier: "GameVc") as! GameVc
  self.navigationController?.pushViewController(vc, animated: true)
  break
  default:
  break
  }
  break
  case 1:
  switch indexPath.row
  {
  case 0:
  let version = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String
  let build = Bundle.main.infoDictionary!["CFBundleVersion"] as! String
  let alert = UIAlertController(title: "Menu Games", message: String(format: "Version:%@\nBuild:%@",version,build), preferredStyle: UIAlertControllerStyle.alert)
  alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: { (action: UIAlertAction!) in
  debugPrint("OK")
  }))
  self.showAlertGlobally(alert)
  break
  case 1:
  let toEmail = "support@menugames.com"
  let subject = NSLocalizedString("REPORTED_TITLE_MESSAGE", comment: "Reported Title Message")
  let deviceName = UIDevice.current.model
  let country = "" //Not Today
  let date = Date(timeIntervalSinceNow: 1)

  var appVersion = "N/A"
  if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String {
  appVersion = version
  }

  var appBuild = "N/A"
  if let build = Bundle.main.infoDictionary?["CFBundleVersion"] as? String
  {
  appBuild = build
  }

  let osVersion = UIDevice.current.systemVersion
  let body = "Device: \(deviceName) \n Country: \(country) \n Date: \(date) \n App Version: \(appVersion) \n App Build: \(appBuild) \n OS Version: \(osVersion) \n"

  if MFMailComposeViewController.canSendMail() {

  let composeVC = MFMailComposeViewController()
  composeVC.mailComposeDelegate = self
  composeVC.setToRecipients([toEmail])
  composeVC.setSubject(subject)
  composeVC.setMessageBody(body, isHTML: false)
  if let filePath = redirectLogToDocuments() as String?
  {
  if let fileData = try? Data(contentsOf: URL(fileURLWithPath: filePath))
  {
  composeVC.addAttachmentData(fileData, mimeType: "text/plain", fileName: "user_report.txt")
  }
  self.present(composeVC, animated: true, completion: nil)
  }

  }
  break
  case 2:
  let storyboard = UIStoryboard(name: "Main", bundle: nil)
  let vc = storyboard.instantiateViewController(withIdentifier: "TutorialVc") as! TutorialVc
  vc.isFromDelegate = false
  self.navigationController?.pushViewController(vc, animated: true)
  break
  case 3:
  let storyboard = UIStoryboard(name: "Main", bundle: nil)
  let vc = storyboard.instantiateViewController(withIdentifier: "FeaturesVc") as! FeaturesVc
  vc.isFromDelegate = false
  self.navigationController?.pushViewController(vc, animated: true)
  break
  default:
  break
  }
  break
  default:
  break
  }

  }
  tableView.deselectRow(at: indexPath, animated: true)
}}


all logs printed are:


2018-10-03 11:55:50.203071-0400 Menu Games[30260:1011859] - <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2018-10-03 11:55:50.245379-0400 Menu Games[30260:1011795] libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.
"applicationWillResignActive"
2018-10-03 11:55:50.406678-0400 Menu Games[30260:1011795] [Crashlytics] Version 3.10.5 (130)
"--->DBUpdate"
2018-10-03 11:55:50.528725-0400 Menu Games[30260:1011868] Version 3.10.0 of Realm is now available: https://github.com/realm/realm-cocoa/blob/v3.10.0/CHANGELOG.md
"--->Path to realm file:Optional(\"This is confidential XD")"
initializeFCM
2018-10-03 11:55:50.595893-0400 Menu Games[30260:1011868] 5.5.0 - [Firebase/Analytics][I-ACS023007] Analytics v.50100000 started
2018-10-03 11:55:50.632665-0400 Menu Games[30260:1011858] Failed to create remote object proxy: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-10-03 11:55:50.632679-0400 Menu Games[30260:1011795] Failed to create synchronous remote object proxy: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-10-03 11:55:50.633502-0400 Menu Games[30260:1011795] [NetworkInfo] Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-10-03 11:55:50.634345-0400 Menu Games[30260:1011795] Failed to create synchronous remote object proxy: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-10-03 11:55:50.633217-0400 Menu Games[30260:1011858] Failed to ping server after delegate was set
2018-10-03 11:55:50.634761-0400 Menu Games[30260:1011795] [NetworkInfo] Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-10-03 11:55:50.635606-0400 Menu Games[30260:1011795] Failed to create synchronous remote object proxy: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-10-03 11:55:50.636167-0400 Menu Games[30260:1011795] [NetworkInfo] Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2018-10-03 11:55:50.621618-0400 Menu Games[30260:1011868] 5.5.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2018-10-03 11:55:50.651866-0400 Menu Games[30260:1011868] 5.5.0 - [Firebase/Crash][I-CRA000004] Successfully initialized
"AppDelegate: launch"
"Home: viewdidload"
"applicationDidBecomeActive"
2018-10-03 11:55:50.973891-0400 Menu Games[30260:1011795] [MC] System group container for systemgroup.com.apple.configurationprofiles path is This is confidential XD
2018-10-03 11:55:50.974605-0400 Menu Games[30260:1011795] [MC] Reading from private effective user settings.
2018-10-03 11:55:51.953420-0400 Menu Games[30260:1011877] TIC TCP Conn Failed [7:0x600001641bc0]: 12:8 Err(-65554)
2018-10-03 11:55:51.962866-0400 Menu Games[30260:1011877] Task <C4C960B3-82CD-4034-94AA-14F815ADD9E2>.<4> HTTP load failed (error code: -1003 [12:8])
2018-10-03 11:55:51.963445-0400 Menu Games[30260:1011877] Task <C4C960B3-82CD-4034-94AA-14F815ADD9E2>.<4> finished with error - code: -1003


https://i.stack.imgur.com/YPpbB.png


I thought there was some view overlapping, but everything is clean, it only happens when I run the application installed from Testflight, just in case, I also updated the iPhone 6 Plus with iOS 12.1 in Beta version but the same problem arises, the Testflight Build is frozen for that device

So any help?, or what else can I do to find the source of the problem or what I'm missing or doing wrong? Thank you very much

iOS 12 Freeze application
 
 
Q