发布时崩溃 - ios 8.1因为添加了UIButton的子视图。 EXC_BREAKPOINT(SIGTRAP)

时间:2015-05-17 16:21:00

标签: ios tabs crash launch symbolicate

我刚被Apple拒绝了,原因如下:

  

我们无法检查您的应用,因为它在发布时崩溃了   以下设备:    - 运行iOS 8.1- iPhone 6的iPhone 5S运行iOS 8.1-运行iOS 8.1的iPhone 6 Plus

这是我做的:

我用模拟器ios 8.1,8.2中的设备测试了它。我还用读取设备测试了它:运行ios 7.1的iphone 4,运行ios 8.3的ipad。根本没有崩溃。

使用他们发送的崩溃日志,我使用Symbolicator生成以下符号化日志:

Process:             Meety [1125]
Path:                /private/var/mobile/Containers/Bundle/Application/12CA9A59-184C-4B7E-9D2A-0B4703363AA2/Meety.app/Meety
Identifier:          com.cungcode.Meety
Version:             1 (1.0)
Code Type:           ARM-64 (Native)
Parent Process:      launchd.development [1]

Date/Time:           2015-05-16 05:34:46.952 -0700
Launch Time:         2015-05-16 05:34:46.165 -0700
OS Version:          iOS 8.1 (12B411)
UDID:                d1c1574d0e021ab0d30ce26e69978227c7080d3c
Report Version:      105

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000010016bdf8
Triggered by Thread:  0

Filtered syslog:
2015-05-16 05:34:46.535 Meety[1125]: <Error> assertion failed: 12B411: libxpc.dylib + 71820 [AD580443-238D-3997-8D09-004C210D0C18]: 0x7d

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
__TFC5Meety20MainTabBarController24addCenterButtonWithImagefS0_FTCSo7UIImage14highlightImageGSqS1___T_ MainTabBarController.swift:227
__TFC5Meety20MainTabBarController11viewDidLoadfS0_FT_T_ MainTabBarController.swift:57
2   UIKit                           0x000000018a72ce80 0x18a71c000 + 69248
3   UIKit                           0x000000018a72cb90 0x18a71c000 + 68496
4   UIKit                           0x000000018a733258 0x18a71c000 + 94808
5   UIKit                           0x000000018a7309d8 0x18a71c000 + 84440
6   UIKit                           0x000000018a7a1a00 0x18a71c000 + 547328
7   UIKit                           0x000000018a9b5434 0x18a71c000 + 2724916
8   UIKit                           0x000000018a9b79ac 0x18a71c000 + 2734508
9   UIKit                           0x000000018a9b6044 0x18a71c000 + 2728004
10  FrontBoardServices              0x000000018e2c163c 0x18e2a8000 + 103996
11  CoreFoundation                  0x0000000185f36120 0x185e58000 + 909600
12  CoreFoundation                  0x0000000185f35228 0x185e58000 + 905768
13  CoreFoundation                  0x0000000185f3384c 0x185e58000 + 899148
14  CoreFoundation                  0x0000000185e611f0 0x185e58000 + 37360
15  UIKit                           0x000000018a797788 0x18a71c000 + 505736
16  UIKit                           0x000000018a792780 0x18a71c000 + 485248
_main AppDelegate.swift:16
18  libdyld.dylib                   0x0000000196dc6a04 0x196dc4000 + 10756

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x0000000196ec4c94 0x196ec4000 + 3220
1   libdispatch.dylib               0x0000000196dac97c 0x196d9c000 + 67964
2   libdispatch.dylib               0x0000000196d9f3b0 0x196d9c000 + 13232

Thread 2:
0   libsystem_kernel.dylib          0x0000000196edfc78 0x196ec4000 + 113784
1   libsystem_pthread.dylib         0x0000000196f79390 0x196f78000 + 5008
2   libsystem_pthread.dylib         0x0000000196f78fa4 0x196f78000 + 4004

Thread 3:
0   libsystem_kernel.dylib          0x0000000196edfc78 0x196ec4000 + 113784
1   libsystem_pthread.dylib         0x0000000196f79390 0x196f78000 + 5008
2   libsystem_pthread.dylib         0x0000000196f78fa4 0x196f78000 + 4004

Thread 4:
0   libsystem_kernel.dylib          0x0000000196edfc78 0x196ec4000 + 113784
1   libsystem_pthread.dylib         0x0000000196f79390 0x196f78000 + 5008
2   libsystem_pthread.dylib         0x0000000196f78fa4 0x196f78000 + 4004

Thread 5:
0   libsystem_kernel.dylib          0x0000000196edfc78 0x196ec4000 + 113784
1   libsystem_pthread.dylib         0x0000000196f79390 0x196f78000 + 5008
2   libsystem_pthread.dylib         0x0000000196f78fa4 0x196f78000 + 4004

Thread 6:
0   libsystem_kernel.dylib          0x0000000196edfc78 0x196ec4000 + 113784
1   libsystem_pthread.dylib         0x0000000196f79390 0x196f78000 + 5008
2   libsystem_pthread.dylib         0x0000000196f78fa4 0x196f78000 + 4004

Thread 7:
0   libsystem_kernel.dylib          0x0000000196edfc78 0x196ec4000 + 113784
1   libsystem_pthread.dylib         0x0000000196f79390 0x196f78000 + 5008
2   libsystem_pthread.dylib         0x0000000196f78fa4 0x196f78000 + 4004

Thread 8:
0   libsystem_kernel.dylib          0x0000000196edfc78 0x196ec4000 + 113784
1   libsystem_pthread.dylib         0x0000000196f79390 0x196f78000 + 5008
2   libsystem_pthread.dylib         0x0000000196f78fa4 0x196f78000 + 4004

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000196f71958   x2: 0x000000015fd233e0   x3: 0x000000000000001e
    x4: 0x0000000000000010   x5: 0x0000000000000001   x6: 0x0000000000000000   x7: 0x0000000000000000
    x8: 0x0000000000000000   x9: 0x000000015fe0c850  x10: 0x0000000000000000  x11: 0x000000000000005e
   x12: 0x0000000000000001  x13: 0x000000000017a17c  x14: 0x0000000000000015  x15: 0x0000000000000000
   x16: 0x0000000100a8217c  x17: 0x0000000000000000  x18: 0x0000000000000000  x19: 0x00000001740995a0
   x20: 0x00000001700997d0  x21: 0x000000015fe0c850  x22: 0x0000000000000000  x23: 0x000000015fd233e0
   x24: 0x0000000100ab30c8  x25: 0x0000000100856dd0  x26: 0x0000000100856dd0  x27: 0x000000019aa4a0a8
   x28: 0x0000000000000001  fp: 0x000000016fd1e160   lr: 0x000000010016b8c0
    sp: 0x000000016fd1e100   pc: 0x000000010016bdf8 cpsr: 0x80000000

所以在我看来,错误必须在以下代码中:

(在MainTabBarController中)

@IBOutlet weak var mapButton: UIButton!

override func viewDidLoad()
{

    super.viewDidLoad()
    self.delegate = self
    var middleImage:UIImage = UIImage(named:"MapButton")!
    var highlightedMiddleImage:UIImage = UIImage(named:"MapButtonHighlighted")!
    addCenterButtonWithImage(middleImage, highlightImage: highlightedMiddleImage) //Line 57 --> Correct!!
    self.tabBar.barTintColor = UIColor.blackColor()

}

func addCenterButtonWithImage(buttonImage: UIImage, highlightImage:UIImage?)
{
    mapButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton //UPDATE 1: LINE 206 --> CRASH HERE 
    mapButton.autoresizingMask = UIViewAutoresizing.FlexibleBottomMargin|UIViewAutoresizing.FlexibleLeftMargin|UIViewAutoresizing.FlexibleRightMargin|UIViewAutoresizing.FlexibleTopMargin

    mapButton.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height);
    mapButton.setBackgroundImage(buttonImage, forState: UIControlState.Normal)
    mapButton.setBackgroundImage(highlightImage, forState: UIControlState.Highlighted)
    //Center the button on tabbar        
    var heightDifference:CGFloat = buttonImage.size.height - self.tabBar.frame.size.height;

    if heightDifference < 0 {
        mapButton.center = self.tabBar.center;
    }
    else
    {
        var center:CGPoint = self.tabBar.center;
        center.y = center.y - heightDifference/2.0;
        mapButton.center = center;
    }

    mapButton.addTarget(self, action: "changeSelectedTabToMapTabController:", forControlEvents: UIControlEvents.TouchUpInside)

    self.view.addSubview(mapButton)
} //LINE 227: PROBABLY CRASH HERE, BUT I THINK IT CRASH ON LINE 206

上面代码的含义是,我想创建一个类似Instagram的标签栏。所以我在5项标签栏的3个标签前面添加了一个按钮。在模拟器ios 8.1中,它如下所示:

enter image description here

1)代码很简单,我无法找到它在ios 8.1中崩溃的原因。现在我没有运行ios 8.1的真实设备来测试它,所以我问你是否可以在代码中找到异常的东西。

2)由于配置资料有问题,应用程序是否可能崩溃?但我认为这不是我的情况,因为我使用分发配置文件存档,并通过iTunes和TestFlight将ipa安装到我的ipad,它可以正常运行。

很抱歉很长时间的问题。任何帮助将不胜感激!

更新1: 我用命令行象征着再次确认崩溃,正如西藏海岸在here中所回答的那样。然后我得到了崩溃必须在代码的第206行:

mapButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton

这种启蒙一定有问题。我没有使用Storyboard这个按钮,但我以编程方式创建。我的朋友使用XCode 6.3(我使用的是6.2),在打开我的项目时会看到很多与“as”,“!”相关的编译错误。和“?”。我想我要将我的XCode更新为6.3,看看我是否在第206行用“as”编译错误。

2 个答案:

答案 0 :(得分:1)

只需检查运行应用程序,方法是将编辑方案中的构建配置设置为发布 运行标签,看看崩溃是否仍然发生,它将帮助您进行调试,因为构建在发布模式下崩溃。我觉得它主要是一个快速的编译器问题,如果它是这样你可以通过将swift编译器优化从最快改为无来避免它。我不确定这是否是一个理想的解决方案,但看看这是否有帮助。 :

答案 1 :(得分:0)

最后,我设法获得了一个真正的测试设备。它崩溃在以下一行:

mapButton.autoresizingMask = UIViewAutoresizing.FlexibleBottomMargin|UIViewAutoresizing.FlexibleLeftMargin|UIViewAutoresizing.FlexibleRightMargin|UIViewAutoresizing.FlexibleTopMargin

原因:mapButton为零。这很奇怪,因为这条线就在上面:

mapButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton

因此,面对此初始化程序不会初始化我的按钮。所以我可能会同意Chandan005关于编译器问题的看法。我将代码更改为:

   let frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height)
    button = UIButton(frame: frame)

现在适用于iPhone 6,ios 8.1。我再次提交了我的应用程序,希望这次会通过。我在博客中写过这个错误here