Playground Xcode swift:WKWebView_scripting [..]无法获取路径的沙箱扩展

时间:2016-05-08 07:42:02

标签: ios iphone swift swift-playground

我使用WKWebView创建了一个新的游乐场。我从以下代码开始:

//: Playground - noun: a place where people can play

import UIKit
import WebKit

let frame = CGRect(x: 0, y: 0, width: 800, height:600)
let web = WKWebView(frame: frame)

然后我将以下明显错误输出消息写入控制台:

2016-05-08 09:31:50.261 WKWebView_scripting[1219:82092] Failed to obtain sandbox extension for path=/var/folders/3w/jr5wk3ls4rb2l6fvks5mthkm0000gn/T/com.apple.dt.Xcode.pg/containers/com.apple.dt.playground.stub.iOS_Simulator.WKWebView-scripting-63C77091-F9CA-4CBE-AD9B-376D4857F44B/Library/Caches    /com.apple.dt.playground.stub.iOS_Simulator.WKWebView-scripting-63C77091-F9CA-4CBE-AD9B-376D4857F44B. Errno:1
2016-05-08 09:31:50.263 WKWebView_scripting[1219:82092] Failed to obtain sandbox extension for path=/var/folders/3w/jr5wk3ls4rb2l6fvks5mthkm0000gn/T/com.apple.dt.Xcode.pg/containers/com.apple.dt.playground.stub.iOS_Simulator.WKWebView-scripting-63C77091-F9CA-4CBE-AD9B-376D4857F44B/Library/Caches/com.apple.dt.playground.stub.iOS_Simulator.WKWebView-scripting-63C77091-F9CA-4CBE-AD9B-376D4857F44B. Errno:1

我在这里做错了什么?

1 个答案:

答案 0 :(得分:4)

你没有做错任何事。

此错误消息表示Playgrounds已沙箱化 - WKWebView无法使用缓存。

但是webview仍然有用。

import UIKit
import XCPlayground
import WebKit

let frame = CGRect(x: 0, y: 0, width: 800, height:600)
let web = WKWebView(frame: frame)
let rq = NSURLRequest(URL: NSURL(string: "http://apple.com")!)
web.loadRequest(rq)
XCPlaygroundPage.currentPage.liveView = web