Swift 游乐场在 Xcode 更新后无法正常运行
Swift Playgrounds aren't acting correctly after Xcode Update
我一直在制作一个 Swift playground,它使用 touchesBegan
方法来接受用户交互。它与我从互联网上下载的 NewtonsCradle 和其他 Swift 游乐场一起运行良好。但是我刚刚将 Xcode 更新为版本 8.3 和 NO Swift游乐场目前正在运作。
我的 Swift playground 不再接受任何用户输入。
例如,我设置了一个测试视图,当我点击它时 "touched" 不打印:
class TestView : UIView {
public init() {
super.init(frame:CGRect(x: 0, y: 0, width: 50, height: 50))
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
print("touched")
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
}
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
}
}
var controller = TestView()
PlaygroundPage.current.liveView = controller
PlaygroundPage.current.needsIndefiniteExecution = true
我也尝试了 运行 NewtonsCradle 代码(一个更新为 Swift 3.0,所以这不是问题)并且球 NOT 响应用户交互,他们只是自己摆动。看到这张他们卡在左上位置的照片:
任何人都知道出了什么问题,或者我能做什么?我真的很赶时间让这个工作。我也无法回滚到 Xcode 的先前版本,因为我需要 Playground 在最新版本上工作。
编辑:我刚刚更新到 MacOS 10.12.4,它仍然坏了。有帮助吗?
编辑 2:我已经让其他人确认这对他们来说是一个问题。也许其他人也可以证实这一点,如果可能的话,也可以提交 Apple 错误报告或提出修复。
有很多解决方案:
- 清理 Xcode (Shift+Command+K)
- 深度清理Xcode (Shift+Option+Command+K)
- 疯狂清理Xcode(删除
/Library/Developer/DevrivedData
)
如果还是不行,重新安装 Xcode:
运行:
sudo /Developer/Library/uninstall-devtools
sudo rm -rf /Developer
然后从 applications
文件夹中删除 Xcode.app
。
Here 是 Apple 工程师的快速修复
您只需要退出 Xcode 并在终端中执行以下命令:
defaults write com.apple.dt.xcode IDEPlaygroundDisableSimulatorAlternateFramebuffer -bool YES
这对我的情况有所帮助,在更新到 Xcode 8.3 后所有 UIPanGestureRecognizers
都停止工作。
另请注意,这会降低渲染游乐场的质量。
我一直在制作一个 Swift playground,它使用 touchesBegan
方法来接受用户交互。它与我从互联网上下载的 NewtonsCradle 和其他 Swift 游乐场一起运行良好。但是我刚刚将 Xcode 更新为版本 8.3 和 NO Swift游乐场目前正在运作。
我的 Swift playground 不再接受任何用户输入。 例如,我设置了一个测试视图,当我点击它时 "touched" 不打印:
class TestView : UIView {
public init() {
super.init(frame:CGRect(x: 0, y: 0, width: 50, height: 50))
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
print("touched")
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
}
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
}
}
var controller = TestView()
PlaygroundPage.current.liveView = controller
PlaygroundPage.current.needsIndefiniteExecution = true
我也尝试了 运行 NewtonsCradle 代码(一个更新为 Swift 3.0,所以这不是问题)并且球 NOT 响应用户交互,他们只是自己摆动。看到这张他们卡在左上位置的照片:
任何人都知道出了什么问题,或者我能做什么?我真的很赶时间让这个工作。我也无法回滚到 Xcode 的先前版本,因为我需要 Playground 在最新版本上工作。
编辑:我刚刚更新到 MacOS 10.12.4,它仍然坏了。有帮助吗?
编辑 2:我已经让其他人确认这对他们来说是一个问题。也许其他人也可以证实这一点,如果可能的话,也可以提交 Apple 错误报告或提出修复。
有很多解决方案:
- 清理 Xcode (Shift+Command+K)
- 深度清理Xcode (Shift+Option+Command+K)
- 疯狂清理Xcode(删除
/Library/Developer/DevrivedData
)
如果还是不行,重新安装 Xcode:
运行:
sudo /Developer/Library/uninstall-devtools
sudo rm -rf /Developer
然后从 applications
文件夹中删除 Xcode.app
。
Here 是 Apple 工程师的快速修复
您只需要退出 Xcode 并在终端中执行以下命令:
defaults write com.apple.dt.xcode IDEPlaygroundDisableSimulatorAlternateFramebuffer -bool YES
这对我的情况有所帮助,在更新到 Xcode 8.3 后所有 UIPanGestureRecognizers
都停止工作。
另请注意,这会降低渲染游乐场的质量。