title: iOS intercept all network traffic from my app?
body: <p>I'd like to add a proxy to all networks calls coming from my app. Something like</p>
  
  <pre><code>func intercept(request: URLRequest) {
    if isOk(request) {
      return // the request continues as normally
    } else if isIntercepted(request) {
      let res = HTTPURLResponse(url: url, statusCode: 200, httpVersion: "HTTP/2", headerFields: ["Content-Type": "application/json"])
      res.value = "{\"ok\":true}" // not that exactly work, but you get the idea
      request.end(res)
    } else {
      let res = HTTPURLResponse(url: url, statusCode: 401, httpVersion: "HTTP/2")
      res.value = "forbidden"
      request.end(res)
    }
  }
  </code></pre>
  
  <p>I'd like it to be applied to all calls coming from my app. Ie from my code and from all libraries and frameworks I'm using. Is it possible? </p>
  
  <p>I've found questions about reading traffic of other apps (not possible) and setting delegates on calls started from my code. I'd like to go further with something that 1) would automatically apply to all traffic and 2) include traffic from 3rd parties</p>