问题
I just updated my XCode form 6.3 to 7.1 and thus also my project from Swift 1.2 to Swift 2.
Everyting seems to work except my app starts some 6 seconds slower then it used to.
I tracked the problem to this class initializer:
class TextPreviewAdapter {
private let themeProvider: ThemeProvider
private let containerView: UIView
private let previewText: UITextView
private let carretView: UIView
private var carretTextPosition: UITextPosition?
init(themeProvider: ThemeProvider) {
self.themeProvider = themeProvider
containerView = UIView()
let time = CACurrentMediaTime()
previewText = UITextView()
print("TextPreviewAdapter \(CACurrentMediaTime() - time)")
carretView = UIView()
}
//some unimportant code
}
The output of the print call is
TextPreviewAdapter 5.86848595833144
The time is different every time I run the up from XCode.
The app is keyboard extension. This might not be the only performance problem introduced by the migration. The whole app appear slugish, in particual rotation animations are slow, somethimes a fast swipe is not handled... Nothing of that was present before migration.
On output I have some suspicious logs (also not present before migration):
2015-10-23 00:39:55.591 ProductName Keyboard[3293:300203] _BSMachError: (os/kern) invalid capability (20)
2015-10-23 00:39:55.592 ProductName Keyboard[3293:300203] _BSMachError: (os/kern) invalid name (15)
2015-10-23 00:39:55.593 ProductName Keyboard[3293:300203] _BSMachError: (os/kern) invalid capability (20)
2015-10-23 00:39:55.593 ProductName Keyboard[3293:300203] _BSMachError: (os/kern) invalid name (15)
2015-10-23 00:45:02.532 ProductName Keyboard[3293:300964] host connection <NSXPCConnection: 0x147e459c0> connection from pid 3292 invalidated
Anybody had the same problem? Any ideas on how to solve this issues?
来源:https://stackoverflow.com/questions/33292099/calling-uitextview-takes-5-8-second-in-keyboard-extension-with-swift-2