内容拦截器在模拟器中工作,但不适用于iPhone设备

我正在研究内容拦截器,并阻止成人的网站,所以,这个代码是完美的工作在模拟器上,当我在iPhone 6上testing,然后它的没有一个网站是块

Alamofire.request(url).responseJSON { response in if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) { print("Data: \(utf8Text)") self.containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.domainName.contentBlocker") let path = self.containerURL?.appendingPathComponent("blockerList.json") self.text = utf8Text.description do { try self.text.write(to: path!, atomically: true, encoding: String.Encoding.utf8) }catch{ print(error) } print(path) } } 

然后在扩展处理程序文件上加载数据。 提前致谢。

我有一个类似的问题,阅读组的内容直接在模拟器上工作,但不是在设备上。 它通过在组中创build一个子目录来解决这个问题,并且在这个子目录下完成所有的阅读工作。

 if let root = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "YOUR_GROUP_NAME") { let url = root.appendingPathComponent("storage") try? FileManager.default.createDirectory(at: url, withIntermediateDirectories: true, attributes: nil) let fileCoordinator = NSFileCoordinator() var error: NSError? fileCoordinator.coordinate(readingItemAt: url, options: .withoutChanges, error: &error) { url in if let urls = try? FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: [.canonicalPathKey], options: []) { for u in urls { print("\(u.standardizedFileURL)") } } } }