首页 > 解决方案 > 无法找到为什么苹果拒绝我的构建的问题

问题描述

我的问题: 由于一段时间以来,我遇到了应用商店的应用拒绝。该应用程序在装有 iOS 14.3(最新)和模拟器的真实设备 ipad/iphone 上运行没有任何问题。但应用商店测试团队声称它崩溃了。苹果代表表示,该构建没有遵循他们的指导方针。我在这里做错了什么......

苹果留言:

We're looking forward to completing our review, but we are unable to continue because your 
app crashed during review. Please review the details below and the attached crash logs, then 
complete the next steps.

Review device details:

- Device type: iPad and iPhone
- OS version: iOS 14.3

Steps leading to crash:

1. Launch the app
2. Enter demo credentials
3. Tap the Login button
4. Observe the crash

崩溃报告:

Incident Identifier: 9A6712D7-1B52-4728-9FB9-F09B4E2058EA
CrashReporter Key:   97557ca51b483f1e2c8db0cbb5a8f94b14d1ceba
Hardware Model:      iPhone11,8
Process:             
Path:                
Identifier:          
Version:             
AppStoreTools:       12D4d
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           


Date/Time:           2021-01-27 12:41:00.1952 -0800
Launch Time:         2021-01-27 12:40:44.7791 -0800
OS Version:          iPhone OS 14.3 (18C66)
Release Type:        User
Baseband Version:    3.02.02
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  0

Application Specific Information:
abort() called

Last Exception Backtrace:
0   CoreFoundation                  0x197d6d86c 0x197c48000 + 1202284
1   libobjc.A.dylib                 0x1accdcc50 0x1accd6000 + 27728
2   CoreFoundation                  0x197c664a4 0x197c48000 + 124068
3   UIKitCore                       0x199f810d0 0x199b58000 + 4362448
4   UIFoundation                    0x1a0fe3374 0x1a0f64000 + 521076
5   UIFoundation                    0x1a0fe358c 0x1a0f64000 + 521612
6   UIFoundation                    0x1a0f6cc1c 0x1a0f64000 + 35868
7   UIKitCore                       0x199ff7f94 0x199b58000 + 4849556
8   Labyl                           0x102eddcc4 specialized AddBuildingViewController.init(coder:) + 629956 (AddBuildingViewController.swift:0)
9   Labyl                           0x102edc160 @objc AddBuildingViewController.init(coder:) + 622944 (<compiler-generated>:16)
10  UIKitCore                       0x19a32be54 0x199b58000 + 8207956
11  UIFoundation                    0x1a0fe3374 0x1a0f64000 + 521076
12  UIFoundation                    0x1a0fe358c 0x1a0f64000 + 521612
13  UIFoundation                    0x1a0f6cc1c 0x1a0f64000 + 35868
14  UIKitCore                       0x19a32b230 0x199b58000 + 8204848
15  UIKitCore                       0x199ff8148 0x199b58000 + 4849992
16  UIKitCore                       0x199f213d0 0x199b58000 + 3970000
17  UIFoundation                    0x1a0fe3374 0x1a0f64000 + 521076
18  UIFoundation                    0x1a0fe358c 0x1a0f64000 + 521612
19  UIFoundation                    0x1a0f6cc1c 0x1a0f64000 + 35868
20  UIKitCore                       0x19a32b230 0x199b58000 + 8204848
21  UIKitCore                       0x199ff8148 0x199b58000 + 4849992
22  UIKitCore                       0x199f030a8 0x199b58000 + 3846312
23  UIKitCore                       0x19a32be54 0x199b58000 + 8207956
24  UIFoundation                    0x1a0fe3374 0x1a0f64000 + 521076
25  UIFoundation                    0x1a0f6cc1c 0x1a0f64000 + 35868
26  UIKitCore                       0x19a33038c 0x199b58000 + 8225676
27  UIFoundation                    0x1a0fe3374 0x1a0f64000 + 521076
28  UIFoundation                    0x1a0fe358c 0x1a0f64000 + 521612
29  UIFoundation                    0x1a0f6cc1c 0x1a0f64000 + 35868
30  UIKitCore                       0x19a32b008 0x199b58000 + 8204296
31  UIKitCore                       0x19a32dae0 0x199b58000 + 8215264
32  UIKitCore                       0x19a8a5d9c 0x199b58000 + 13950364
33  UIKitCore                       0x19a8a5c34 0x199b58000 + 13950004
34  UIKitCore                       0x19a8a694c 0x199b58000 + 13953356
35  UIKitCore                       0x19a8a6b64 0x199b58000 + 13953892
36  UIKitCore                       0x199ffff48 0x199b58000 + 4882248
37  Labyl                           0x102ea4bf8 InitialViewController.viewDidAppear(_:) + 396280 (InitialViewController.swift:0)
38  Labyl                           0x102ea4c40 @objc InitialViewController.viewDidAppear(_:) + 396352 (<compiler-generated>:0)
39  UIKitCore                       0x19a002d8c 0x199b58000 + 4894092
40  UIKitCore                       0x19a003768 0x199b58000 + 4896616
41  UIKitCore                       0x19a003aa8 0x199b58000 + 4897448
42  UIKitCore                       0x199ede9a0 0x199b58000 + 3697056
43  UIKitCore                       0x199ede77c 0x199b58000 + 3696508
44  UIKitCore                       0x199ee8f54 0x199b58000 + 3739476
45  UIKitCore                       0x199ee2f80 0x199b58000 + 3714944
46  UIKitCore                       0x19a027bcc 0x199b58000 + 5045196
47  UIKitCore                       0x19ac29de8 0x199b58000 + 17636840
48  UIKitCore                       0x19ac29a94 0x199b58000 + 17635988
49  UIKitCore                       0x19ac619ac 0x199b58000 + 17865132
50  UIKitCore                       0x19ac33cc8 0x199b58000 + 17677512
51  UIKitCore                       0x19ac34230 0x199b58000 + 17678896
52  UIKitCore                       0x19ac34394 0x199b58000 + 17679252
53  QuartzCore                      0x19b19e5e4 0x19b029000 + 1529316
54  libdispatch.dylib               0x197961db0 0x19795e000 + 15792
55  libdispatch.dylib               0x19796f7ac 0x19795e000 + 71596
56  CoreFoundation                  0x197ce911c 0x197c48000 + 659740
57  CoreFoundation                  0x197ce3120 0x197c48000 + 635168
58  CoreFoundation                  0x197ce221c 0x197c48000 + 631324
59  GraphicsServices                0x1af7e6784 0x1af7e3000 + 14212
60  UIKitCore                       0x19a720fe0 0x199b58000 + 12357600
61  UIKitCore                       0x19a726854 0x199b58000 + 12380244
62  libswiftUIKit.dylib             0x1abf9e5bc 0x1abf88000 + 91580
63  Labyl                           0x102ec7da8 main + 540072 (AppDelegate.swift:0)
64  libdyld.dylib                   0x1979a26b0 0x1979a1000 + 5808


Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x00000001c5ae4414 0x1c5abc000 + 164884
1   libsystem_pthread.dylib         0x00000001e353eb40 0x1e353c000 + 11072
2   libsystem_c.dylib               0x00000001a110ab74 0x1a1094000 + 486260
3   libc++abi.dylib                 0x00000001acde2cf8 0x1acdcf000 + 81144
4   libc++abi.dylib                 0x00000001acdd3e4c 0x1acdcf000 + 20044
5   libobjc.A.dylib                 0x00000001accdcf64 0x1accd6000 + 28516
6   libc++abi.dylib                 0x00000001acde20e0 0x1acdcf000 + 78048
7   libc++abi.dylib                 0x00000001acde206c 0x1acdcf000 + 77932
8   libdispatch.dylib               0x0000000197961dc4 0x19795e000 + 15812
9   libdispatch.dylib               0x000000019796f7ac 0x19795e000 + 71596
10  CoreFoundation                  0x0000000197ce911c 0x197c48000 + 659740
11  CoreFoundation                  0x0000000197ce3120 0x197c48000 + 635168
12  CoreFoundation                  0x0000000197ce221c 0x197c48000 + 631324
13  GraphicsServices                0x00000001af7e6784 0x1af7e3000 + 14212
14  UIKitCore                       0x000000019a720fe0 0x199b58000 + 12357600
15  UIKitCore                       0x000000019a726854 0x199b58000 + 12380244
16  libswiftUIKit.dylib             0x00000001abf9e5bc 0x1abf88000 + 91580
17  Labyl                           0x0000000102ec7da8 main + 540072 (AppDelegate.swift:0)
18  libdyld.dylib                   0x00000001979a26b0 0x1979a1000 + 5808

笔记

在此处输入图像描述

在此处输入图像描述

添加建筑视图控制器

    import UIKit
    import MapKit
    import CoreLocation
    import PKHUD
    import Alamofire
    import AVFoundation
    
    class AddBuildingViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
     ............
     ............
    
     override func viewDidLoad() {
         super.viewDidLoad()
        
         .........
        
     }
    
     override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        print("from add new view controller view did appear")
        ..........
     }
    
     override func viewDidDisappear(_ animated: Bool) {
        .........
     }
    
     override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        .......
     }
    
     override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        
        .........
     }
    
    }

初始视图控制器

import UIKit

class InitialViewController: UIViewController {

    override func viewDidLoad(){
        super.viewDidLoad()
    }
    
    override func viewWillAppear(_ animated: Bool) {
        self.navigationController?.navigationBar.barTintColor = #colorLiteral(red: 0.2196078431, green: 0.4705882353, blue: 0.9137254902, alpha: 1)
        self.navigationController?.navigationBar.tintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        
        self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
        
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        print("Initial View Controller : ViewDidAppear")
        if UserDefaults.standard.object(forKey: "loginTokenDict") == nil {
            print("go to login")
            self.performSegue(withIdentifier: "loginSegue", sender: self)
        } else {
            print("go to dashboard")
            self.performSegue(withIdentifier: "viewDashBoard", sender: self)
        }
    }
}

应用委托文件:

import UIKit
import CoreData
import AVFoundation

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
//        
        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
        // Saves changes in the application's managed object context before the application terminates.
        self.saveContext()
    }

    // MARK: - Core Data stack

    lazy var applicationDocumentsDirectory: URL = {
        // The directory the application uses to store the Core Data store file. This code uses a directory named "com.essindia.Archguide" in the application's documents Application Support directory.
        let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
        return urls[urls.count-1]
    }()

    lazy var managedObjectModel: NSManagedObjectModel = {
        // The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
        let modelURL = Bundle.main.url(forResource: "Archguide", withExtension: "momd")!
        return NSManagedObjectModel(contentsOf: modelURL)!
    }()

    lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator = {
        // The persistent store coordinator for the application. This implementation creates and returns a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail.
        // Create the coordinator and store
        let coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
        let url = self.applicationDocumentsDirectory.appendingPathComponent("SingleViewCoreData.sqlite")
        var failureReason = "There was an error creating or loading the application's saved data."
        do {
            try coordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: url, options: nil)
        } catch {
            // Report any error we got.
            var dict = [String: AnyObject]()
            dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data" as AnyObject
            dict[NSLocalizedFailureReasonErrorKey] = failureReason as AnyObject

            dict[NSUnderlyingErrorKey] = error as NSError
            let wrappedError = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
            // Replace this with code to handle the error appropriately.
            // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
            NSLog("Unresolved error \(wrappedError), \(wrappedError.userInfo)")
            //abort()
        }
        
        return coordinator
    }()

    lazy var managedObjectContext: NSManagedObjectContext = {
        // Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) This property is optional since there are legitimate error conditions that could cause the creation of the context to fail.
        let coordinator = self.persistentStoreCoordinator
        var managedObjectContext = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
        managedObjectContext.persistentStoreCoordinator = coordinator
        return managedObjectContext
    }()

    // MARK: - Core Data Saving support

    func saveContext () {
        if managedObjectContext.hasChanges {
            do {
                try managedObjectContext.save()
            } catch {
                // Replace this implementation with code to handle the error appropriately.
                // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
                let nserror = error as NSError
                NSLog("Unresolved error \(nserror), \(nserror.userInfo)")
                //abort()
            }
        }
    }
    
    // MARK: UISceneSession Lifecycle
    
    @available(iOS 13, *)
    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
        // Called when a new scene session is being created.
        // Use this method to select a configuration to create the new scene with.
        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
    }
    
    @available(iOS 13, *)
    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
        // Called when the user discards a scene session.
        // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
        // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
    }


}

Scenedelegate 文件:(我为 iOS 14 手动添加)

import UIKit

@available(iOS 13.0, *)
class SceneDelegate : UIResponder, UIWindowSceneDelegate {
    
    var window: UIWindow?

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        //guard let _ = (scene as? UIWindowScene) else { return }
        
//        guard let windowScene = scene as? UIWindowScene else { return }
//        let window = UIWindow(windowScene: windowScene)
//        // Provide your apps root view controller
//        window.rootViewController = InitialViewController()
//        self.window = window
//        window.makeKeyAndVisible()
        
        if let windowScene = scene as? UIWindowScene {
                let storyboard = UIStoryboard(name: "Main", bundle: nil)
                    var vc : UIViewController = storyboard.instantiateViewController(withIdentifier: "InitialViewController") as UIViewController
                    self.window = UIWindow(windowScene: windowScene)
                    self.window?.rootViewController = vc
                    self.window?.makeKeyAndVisible()
                }
    }

    func sceneDidDisconnect(_ scene: UIScene) {
        // Called as the scene is being released by the system.
        // This occurs shortly after the scene enters the background, or when its session is discarded.
        // Release any resources associated with this scene that can be re-created the next time the scene connects.
        // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
    }

    func sceneDidBecomeActive(_ scene: UIScene) {
        // Called when the scene has moved from an inactive state to an active state.
        // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
    }

    func sceneWillResignActive(_ scene: UIScene) {
        // Called when the scene will move from an active state to an inactive state.
        // This may occur due to temporary interruptions (ex. an incoming phone call).
    }

    func sceneWillEnterForeground(_ scene: UIScene) {
        // Called as the scene transitions from the background to the foreground.
        // Use this method to undo the changes made on entering the background.
    }

    func sceneDidEnterBackground(_ scene: UIScene) {
        // Called as the scene transitions from the foreground to the background.
        // Use this method to save data, release shared resources, and store enough scene-specific state information
        // to restore the scene back to its current state.
    }
}

为新的 Scenedelegate 部分编辑了 plist:

<key>UIApplicationSceneManifest</key>
    <dict>
        <key>UIApplicationSupportsMultipleScenes</key>
        <false/>
        <key>UISceneConfigurations</key>
        <dict>
            <key>UIWindowSceneSessionRoleApplication</key>
            <array>
                <dict>
                    <key>UISceneConfigurationName</key>
                    <string>Default Configuration</string>
                    <key>UISceneDelegateClassName</key>
                    <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
                    <key>UISceneStoryboardFile</key>
                    <string>Main</string>
                </dict>
            </array>
        </dict>
    </dict>

在此处输入图像描述

由于我需要对 iOS 12 及更早版本和 13.0 + 的支持,我是否在将 Scenedelegate 引入项目时做错了什么?终止应用程序时,我的 Appdelegate 已被使用

标签: iosswiftappdelegatexcode12ipados

解决方案


推荐阅读