Сбой HockeyApp, разветвленные очереди, iOS, Swift

Использование чужого фреймворка из GitHub для эффекта процесса UIButton. Работает нормально при установке через последний XCode, но приложение вылетает, как только кнопка запускает анимацию, если установлено через HockeyApp. Вот эта анимационная функция:

  private func startAnimating() {
    isAnimating = true
    views = []

    for i in 0..<colors.count {
        let view = UIView(frame: lineRect())
        view.backgroundColor = colors[i]
        views.append(view)
    }

         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { () -> Void in

        var count: Int = 0
        while self.isAnimating {
            if count == self.views.count {
                count = 0
            }

            var next = false
            dispatch_async(dispatch_get_main_queue(), {

                UIView.animateWithDuration(self.duration, delay: 0, options: [], animations: { () -> Void in
                    if self.isAnimating {

                        if !self.views.isEmpty {
                        self.addSubview(self.views[count])
                        self.views[count].frame.origin = CGPoint(x: self.bounds.origin.x, y: 0)
                        self.views[count].frame.size.width = self.frame.width
                        }
                    }
                    }, completion: { (Bool) -> Void in
                        if self.isAnimating {
                            var lastIndex = count - 1
                            if lastIndex < 0 {
                                lastIndex = self.colors.count - 1
                            }
                            self.views[lastIndex].frame = self.lineRect()
                            self.views[lastIndex].removeFromSuperview()
                        }
                        next = true
                })
            })

            // Let's wait until the current animation is done before moving forward
            while !next {
            }
            count++
        }
    })

}

HockeyApp указывает на первую ссылку 'views' во второй очереди, которая в данном случае является пустой проверкой (я добавил это, но если ее там нет, она будет указывать на следующую ссылку):

 UIView.animateWithDuration(self.duration, delay: 0, options: [], animations: { () -> Void in
                        if self.isAnimating {

                            if !self.views.isEmpty {
                            self.addSubview(self.views[count])
                            self.views[count].frame.origin = CGPoint(x: self.bounds.origin.x, y: 0)
                            self.views[count].frame.size.width = self.frame.width
                            }
                        }

Вот ключевая часть отчета о сбое HockeyApp:

Date/Time:       2016-02-03T18:01:01Z
Launch Time:     2016-02-03T18:00:33Z
OS Version:      iPhone OS 9.2.1 (13D15)
Report Version:  104

Exception Type:  SIGTRAP
Exception Codes: #0 at 0x100099080
Crashed Thread:  0

Application Specific Information:
Selector name found in current argument registers: release

Thread 0 Crashed:
0   barscan1                             0x0000000100099080 barscan1.ProcessView.((startAnimating in _126B4789AED4AC2C363037724C3D4FEF) (barscan1.ProcessView) -> () -> ()).(closure #1).(closure #1).(closure #1) (ProcessView.swift:78)
1   UIKit                                0x0000000185eb8210 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 616
2   UIKit                                0x0000000185ecfc58 +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 104
3   barscan1                             0x0000000100098d90 barscan1.ProcessView.((startAnimating in _126B4789AED4AC2C363037724C3D4FEF) (barscan1.ProcessView) -> () -> ()).(closure #1).(closure #1) (ProcessView.swift:94)
4   libdispatch.dylib                    0x0000000180be1630 _dispatch_call_block_and_release + 20
5   libdispatch.dylib                    0x0000000180be15f0 _dispatch_client_callout + 12
6   libdispatch.dylib                    0x0000000180be6cf8 _dispatch_main_queue_callback_4CF + 1840
7   CoreFoundation                       0x0000000181144bb0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
8   CoreFoundation                       0x0000000181142a18 __CFRunLoopRun + 1624
9   CoreFoundation                       0x0000000181071680 CFRunLoopRunSpecific + 380
10  GraphicsServices                     0x0000000182580088 GSEventRunModal + 176
11  UIKit                                0x0000000185ee8d90 UIApplicationMain + 200
12  barscan1                             0x00000001000aa32c main (AppDelegate.swift:15)
13  ???                                  0x0000000180c128b8 0x0 + 0

Любая помощь очень ценится! Спасибо!

1 ответ

Оказалось, что это проблема Apple Swift Optimization - установите для нее значение NONE, и теперь проблема исчезла.

Другие вопросы по тегам