Giter Club home page Giter Club logo

netfox's Introduction

Version CI Status Cocoapods Compatible Carthage Compatible Platform License

Netfox provides a quick look on all executed network requests performed by your iOS or OSX app. It grabs all requests - of course yours, requests from 3rd party libraries (such as AFNetworking, Alamofire or else), UIWebViews, and more

Very useful and handy for network related issues and bugs

Supports Swift 5 and above - bridged also for Objective-C.

For Swift 4 support, use version 1.19.0.

For Swift 3.2 support, use version 1.12.1.

Feel free to contribute :)

Overview

Installation

SPM (beta, only iOS)

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

To add netfox as a package dependency to your Xcode project, select File > Add Packages and enter as repository URL the https://github.com/kasketis/netfox (always choose the latest release)

For more info, please check here

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. To integrate netfox into your Xcode project using CocoaPods, specify it in your Podfile:

use_frameworks!
pod 'netfox'

To bundle only on some build configurations specify them after pod.

use_frameworks!
pod 'netfox', :configurations => ['Debug', 'Test']

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate netfox into your Xcode project using Carthage, specify it in your Cartfile:

github "kasketis/netfox"

Manually

If you prefer not to use dependency managers, you can integrate netfox into your project manually.

You can do it by copying the "netfox" folder in your project (make sure that "Create groups" option is selected)

The above folder contains 3 subfolders: Core, iOS and OSX.

  • If you target on iOS keep only Core and iOS folders (remove OSX folder)
  • If you target on OSX keep only Core and OSX folders (remove iOS folder)

Start

Swift

// AppDelegate
import netfox
NFX.sharedInstance().start() // in didFinishLaunchingWithOptions:

Objective-C

// AppDelegate
[NFX.sharedInstance start]; // in didFinishLaunchingWithOptions:

Just simple as that!

Note: Please wrap the above line with

#if DEBUG
. . .
#endif

to prevent library’s execution on your production app.

You can add the DEBUG symbol with the -DDEBUG entry. Set it in the "Swift Compiler - Custom Flags" section -> "Other Swift Flags" line in project’s "Build Settings"

Usage

Just shake your device and check what's going right or wrong! Shake again and go back to your app!

Stop

Call

NFX.sharedInstance().stop()

to stop netfox and clear all saved data. If you stop netfox its view will not be displayed until you call start method again.

If you want to just enable/disable logging functionality or clear the data please use the buttons provided in the settings view

Custom gestures

By default the library registers for shake motion. If you want to open the logs with a different gesture, add the following line after the installation one

NFX.sharedInstance().setGesture(.custom)

Then you can use

NFX.sharedInstance().show()

when you want to show the logs and

NFX.sharedInstance().hide()

when you want to hide them.

Prevent logging for specific URLs

Use the following method to prevent requests for specified URL from being logged. You can ignore as many URLs as you want

NFX.sharedInstance().ignoreURL("the_url")

Tip: You can use the url of the host (for example "https://www.github.com") to ignore all paths of it

Features

  • Search: You can easily search among requests via
    • Request url: github.com, .gr, or whatever you want
    • Request method: GET, POST, etc
    • Response type: Like json, xml, html, image and more
  • Sharing: You can share your log via email with backend devs or someone who can help.
    • Simple log option includes only request/response headers and small request/response bodies (when applicable)
    • Full log option includes request/response headers and request/response bodies (as attachments)
  • Filtering: Select what types of responses (JSON/XML/HTML/Image/Other) you want to see
  • Enable/disable logging within the app
  • Clear data within the app
  • Statistics: Check cool things like average response time, total response size and more for your selected types of responses
  • Info: Check your IP address, your app version and build number and other things within the app
  • More to come.. ;)

Integrations

Droar: A modular, single-line installation debugging window.

Other

  • If you experience any problems with request logging please check this. If you don't get your answer please open an issue
  • Due to the large size of request/response bodies, the library provides disk storage for low memory overhead

Sponsors

EmergeTools

Thanks

Special thanks to tbaranes and vincedev for their contribution on OSX library!

Licence

All source code is licensed under MIT License. Which means you could do virtually anything with the code. I will appreciate it very much if you keep an attribution where appropriate.

netfox's People

Contributors

abeansits avatar adelinofaria avatar bd-jhunter avatar chrispix avatar dannypier avatar felipeflorencio avatar freak4pc avatar janglinator avatar jasoncabot avatar jasonlagaac avatar kasketis avatar krzysztofpelczarinfullmobile avatar matt-freedmanpi avatar maxvodafone avatar michaelfransen avatar petrosdemetrakopoulos avatar petrprazak avatar seviu avatar simonrice avatar skychiarottoa avatar sroebert avatar stefansuciu avatar tabynbayev1 avatar tanpengsccd avatar tbaranes avatar touyu avatar tzatzosm avatar vgubriienko avatar vincedev avatar vysotsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netfox's Issues

Crash in NFXProtocol's startLoading()

Even with the latest changes to Netfox, there still remains a rare crash in NFXProtocol's startLoading(), during client.URLProtocolDidFinishLoading(self).

EXC_BREAKPOINT (code=1, subcode=0x1815e97d0)

Call stack of crash:
Thread 10Queue : NSOperationQueue 0x12effa0a0 :: NSOperation 0x1300bf730 (QOS: LEGACY) (serial)
#0 0x00000001815e97d0 in _os_lock_corruption_abort ()
#1 0x00000001815e97d0 in _OSSpinLockLockSlow$VARIANT$wfe ()
#2 0x0000000181f7b570 in CFURLProtocol_NS::forgetProtocolClient() ()
#3 0x000000010019f038 in NFXProtocol.(startLoading() -> ()).(closure #1) at .../netfox/netfox/NFXProtocol.swift:89

It appears others doing NSURLProtocol work have this exact same crash. See this: https://forums.developer.apple.com/thread/26081

And see the threading rules mentioned in that discussion thread here: https://developer.apple.com/library/ios/samplecode/CustomHTTPProtocol/Listings/Read_Me_About_CustomHTTPProtocol_txt.html

Maybe someone with more experience with Netfox's code can research and fix this? I receive reports of this crash routinely via Crashlytics, and I just hit it again in a local build I was debugging today upon launch of my app, which is using current root source of netfox (6/15/16).

Requests don't show for applications that use a custom NSURLSessionTask

I was seeing some of my frameworks requests but I wasn't seeing them from my own app. I did some debugging and found that if your app uses a NSURLSessionConfiguration class and uses NSUrlSessionTasks, you must set the protocol class yourself.

Also, in NFXProtocol, you must implement the following method.

override public class func canInitWithTask(task: NSURLSessionTask) -> Bool {
        if !NFX.sharedInstance().isEnabled() {
            return false
        }

        if let url = task.currentRequest?.URL {
            if (!(url.absoluteString.hasPrefix("http")) && !(url.absoluteString.hasPrefix("https"))) {
                return false
            }

            for ignoredURL in NFX.sharedInstance().getIgnoredURLs() {
                if url.absoluteString.hasPrefix(ignoredURL) {
                    return false
                }
            }
        } else {
            return false
        }

        if NSURLProtocol.propertyForKey("NFXInternal", inRequest: task.currentRequest!) != nil {
            return false
        }

        return true
    }

I will try to get around to making a pull request, but I wanted to post this in case other people weren't seeing all of their traffic.

Using Netfox without modal presentation

I've created a project where I having a large selection of debugging tools built into one debugging window. Netfox is spectacular, and I'd like to add it as another section of the pod. However I don't wish to present it modally, but rather push it onto my existing navigation controller. Is there any way we could publicly expose the NFXListController class for custom usage?

P.S. my library is in ObjC, so an @objc at the top would also be awesome!

Remote Logging

This is REALLY useful for individual testing and debugging. It would be even better if when this is enabled it would post logs to a database periodically. Could be Dynamo, Elasticsearch, Mongo etc. This would allow broader profiling among Test and Beta users. Its important to understand your API consumption so you don't put out an app thats going to blow your API quota or violate a 3rd Party TOS and this could do that easily I think.

Caching broken with Netfox protocol

When creating a custom manager to work with Alamofire:

    static let sharedManager: TIFAlamofireManager = {
        let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
        configuration.protocolClasses?.insert(NFXProtocol.self, atIndex: 0)
        configuration.HTTPAdditionalHeaders = Manager.defaultHTTPHeaders
        let manager = TIFAlamofireManager(configuration: configuration)
        manager.startRequestsImmediately = false
        return manager
    }()

The caching of URLRequests seems to be broken.

After disabling this line:

configuration.protocolClasses?.insert(NFXProtocol.self, atIndex: 0)

Caching works as expected.

Anyone else encountering this issue?

Pretty Printing

Pretty printing request responses could be a very nice enhancement! Nice work, thank you.

Encryption?

More of a mental note, but we should be using encryption in our storage of these request bodies, if we're not already.

Format long responses

Is it possible to format long responses (the view that just shows all the response when it's too big to fit) with the prettyPrint option?

I saw that's a textfield and it's just loading a plain string.

Why is NFXProtocol internal?

Awesome little library! I wonder, though -- why is NFXProtocol internal? When importing this as a pod, I'm unable to create a custom NFXManager to support Alamofire.

Netfox & Parse: can't see my Parse requests

Not sure what could be the reason for that... Any idea?
I see other requests (such ax Mixpanel and Facebook graph) but not Parse ones.

But beside it - great idea and really really great and cool implematation!

Thanks a lot!!

OSX support

Starting a first suggestion in #28 for OSX support, you seemed to be interested in it. Is there any work started yet? If no, would you be interested in a PR to handle it? (if I have the time to work on it...) Or just some helps?

We are really interested on this since we already using Netfox in our iOS application :)

NSURLSession not working (3rd party i.e.:Alamofire neither)

It's not catching requests/responses that go through Alamofire ("Equivalent" to AFNetworking in Swift)

Most basic case:

let request = ...
Alamofire.Manager.sharedInstance.request(request).validate().responseJSON() { 
...
}

My guessing is that it's not working for any NSURLSession request, this is not working either:

let request = NSURLRequest(URL: url)
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) { data, response, error in

Is it AppStore safe?

Are you using any private API's or anything that apple would find a reason to reject the app?

Issue with Carthage

I'm trying to use this with Carthage, but it doesn't work for me. I'm only building for iOS with:
carthage build --platform iOS

The issue is that the framework is defined as netfox_ios instead of netfox (and the same for the module name). Is there any way to make the framework and module name be "netfox" as with Cocoapods?

Using netfox with Moya

Moya uses Alamofire to make request but I couldn't figure out how I can embed NFXManager for Alamofire. Any suggestion?

Alternatives.

It seems the developer for this project has gone AWOL. Does anyone have an alternative? Or has someone taken over active development on a fork somewhere?

Problem facing in integration with objective - c project.

Hi,

I am integrating netfox manually (by dragging the swift files folder in xcode). Xcode compiling it fine, but problem is how i can import them in my objective-c project. i even tried with this statement

import "netfox-Swift.h"

but it didn't worked for me and xcode is giving error that file not found. I am in middle of it please help.

Thanks.

Build warnings

In NFXHTTPModel.swift, func prettyPrint (line 239)
return NSString(data: prettyPrintedString, encoding: String.Encoding.utf8.rawValue) as? String
should be
return NSString(data: prettyPrintedString, encoding: String.Encoding.utf8.rawValue) as String?

Large increase in memory usage with netfox enabled

I have an app which is doing somewhat large JSON imports very often in the background, like every 8-20s. The JSONs are parsed and saved into Core Data, all on the same backgorund thread/MOC.

With netfox compiled in, the memory usage became very large.
I was not aware of at first that netfox is the cause of this, so I was removing my background operations one my one until I was left with just one call. Without netfox, app would take 40-44MB. With netfox, it was 84MB. When I added another JSON call following the first one, without netfox memory usage was around 54MB, with netfox it was 150MB. This was all without netfox UI ever being triggered - it was just doing its thing in the background.

If it helps - both of these JSON calls cause reading/updating and creating a lot of NSManagedObjects from my Core Data store. This all happens in background MOC/thread, thus it's gone from memory as soon as it's processed. But if netfox is somehow keeping something from that thread retained, then it could be a reason that all of the objects from the thread are staying in memory.

My app is Objective-C based and I really don't know Swift thus can't help debugging this.
Still, though it's worth reporting this.

No longer supported

My coworkers and myself LOVE Netfox. However the last commit was made 4 months ago. I'd love to support it, is there any way I may have write access?

Thanks!

How do I use with Objective-C project

I am not sure how to use this framework with an Objective C project? Should there be a bridging header included in the framework, or do I need to somehow create one in xCode?

Thanks.

netfox UI doesnt show up

Hi,

I am using netfox in my project and I have been facing weird situation. After changing the account -which is logging out and signing in again- netfox UI does not show up both in simulator and device in debug mode. After shaking again, it closes my main.storyboard and opens up my login view controller which is in another storyboard. Maybe it does not have anything with netfox but I just wanted to ask you guys, I do not know how to figure out what causes this and you know maybe you can help. Any thougths?

Dissmiss Button

Please add Dissmiss Button, because i use shake gesture for other stuff

Filter by type

Can we make a method to configure Netfox to ignore certain types of requests or url extensions?

I'm thinking about an app that loads many images, and we just want the main interaction between app <=> server and not those resources.

New features

Hello folks,

I'm searching for new cool things to add in the next releases of netfox!

Please contribute your ideas here! :)

Add Travis CI?

Would you mind if I added a Travis config to this repo? I'll configure it to build against Swift 3.2 and 4.0, to make sure we don't cause build issues for anybody again.

Proper casing in project naming

I've noticed that this is the only framework that I use that has the framework name lowercased. @kasketis - Was this intentional? Do you mind if we update it to Netfox instead of netfox?

SSL pinning support

Hello, I think it'll be very useful to have an ability to use netfox with server with SSL pinning. Nowadays many apps avoid security issues, so they have pinning switched on connected server.

Any thoughts?

Swift 3.0

Would love to see this update to Swift 3.0 to begin testing soon :)

Fix missing request body

As mentioned in the help docs, users have to manually write:

if let bodyData = mutableURLRequest.HTTPBody {
    NSURLProtocol.setProperty(bodyData, forKey: "NFXBodyData", inRequest: mutableURLRequest)
}

It would be spectacular if there was a way to do this internally using swizzling

No HTTP body for requests

All requests that send data show as "Request body is empty" for the request body despite having the correct Content-Length set in the header

The reason is because when startLoading() is called in NFXProtocol the getNFXBody() is nil

I believe this is the same issue as:

https://github.com/AliSoftware/OHHTTPStubs/wiki/Testing-for-the-request-body-in-your-stubs

I'm currently seeing if there's a different place to trap and save this data

I'm also using Alamofire but I'm not sure it's related to that

Crash "configForObject"

This method is crashing, you should never unwrap variables without using 'guard' or 'if let' or define a default value

func configForObject(obj : NFXHTTPModel)
{

...

    setStatus(obj.responseStatus!)
    setTimeInterval(obj.timeInterval!)
    setRequestTime(obj.requestTime!)
    setType(obj.responseType!)
    setMethod(obj.requestMethod!)
}

I propose not using them if they're not present and handle those cases, or simplest way:

    setStatus(obj.responseStatus ?? 999)
    setTimeInterval(obj.timeInterval ?? "-")
    setRequestTime(obj.requestTime ?? "-")
    setType(obj.responseType ?? "-")
    setMethod(obj.requestMethod ?? "-")

You're the father, your call :D

Request body is empty

On the request details screen, request body is empty, but it filled in URLRequest.httpBody

Override/Change gesture/Way to show logs

It would be nice to have the ability to define our own method/gesture and call everything with one access method. Imagine this mixes up with shaking in some application, or we want to have a button always there to just display when the tester taps, etc.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.