PonyDebugger安装

ponyDebugger是一个远程调试工具包,通过使用 Chrome 开发者工具来调试 iOS 应用的网络流量和数据存储。https://github.com/square/PonyDebugger这有它的源码和使用方法。

下面我简单说明一下分别在模拟器和真机下配置使用ponyDebugger

一.在模拟器下使用ponyDebugger

1.配置服务器端

  • 1). 安装 Xcode's Command Line Tools
  • 2). 在shell里面执行下面命令


     
     
1
2

     
     
curl -sk https:/ /cloud.github.com/downloads /square/ PonyDebugger/bootstrap-ponyd.py | \
python - --ponyd-symlink= /usr/local /bin/ponyd ~ /Library/ PonyDebugger
        如果安装过程中处理如下问题:

     
     
1
2

     
     
curl -sk https:/ /cloud.github.com/downloads /square/ PonyDebugger/bootstrap-ponyd.py | \
python - --ponyd-symlink= /usr/local /bin/ponyd ~ /Library/ PonyDebugger
New python executable in /Users/wenchuang/Library/PonyDebugger/bin/python Installing setuptools................done. Installing pip..............done. Obtaining ponydebugger from git+https://github.com/square/PonyDebugger.git#egg=ponydebugger   Updating ./Library/PonyDebugger/src/ponydebugger clone   Running setup.py (path:/Users/wenchuang/Library/PonyDebugger/src/ponydebugger/setup.py) egg_info for package ponydebugger        Installing extra requirements: 'egg' Downloading/unpacking tornado (from ponydebugger)   Downloading tornado-3.2.tar.gz (400kB): 400kB downloaded   Running setup.py (path:/Users/wenchuang/Library/PonyDebugger/build/tornado/setup.py) egg_info for package tornado      Downloading/unpacking pybonjour (from ponydebugger)   Could not find any downloads that satisfy the requirement pybonjour (from ponydebugger)   Some externally hosted files were ignored (use --allow-external pybonjour to allow). Cleaning up... No distributions at all found for pybonjour (from ponydebugger) Storing debug log for failure in /Users/wenchuang/.pip/pip.log Traceback (most recent call last):   File "<stdin>", line 2462, in <module>   File "<stdin>", line 946, in main   File "<stdin>", line 1794, in after_install   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 511, in check_call     raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['/Users/wenchuang/Library/PonyDebugger/bin/pip', 'install', '-U', '-e', 'git+https://github.com/square/PonyDebugger.git#egg=ponydebugger']' returned non-zero exit status 1
      解决办法:

    
         
         
    
         
         
     在shell里面执行下面命令
    # activate your virtualenv
    source ~/Library/PonyDebugger/bin/activate
    # update the ponyd source
    pip install -U -e git+https://github.com/square/PonyDebugger.git#egg=ponydebugger --allow-external pybonjour --allow-unverified pybonjour
    # updates chrome dev tools source
    ponyd update-devtools

    • 3). 安装成功以后,在shell里面执行
    
         
         
    1
    
         
         
    ponyd serve --listen-interface= 127.0.0.1 注意:这时候如果弹出-bash: ponyd: command not found,修改成:~/Library/PonyDebugger/bin/ponyd serve --listen-interface=127.0.0.1 就ok了

    如果看见的是这样 test1test1说明服务器端已经安装好了。

    2.IOS 端

    (1)安装cocoapoads

    $ sudo gem install cocoapods
    $ pod setup
    
    (2)cd到文件目录,编辑Profile文件
    $ cd 文件目录
    $ vim Profile
    (3)点击i进行编辑,退出编辑(点击esc键,插入:wq)
    platform :ios, '5.0'
    pod 'PonyDebugger', '~> 0.3.1'
    (4)安装
    $ pod install

    3.使用

    在你的工程中,输入下面的代码:

    didFinishLaunchingWithOptions中添加如下代码

        PDDebugger *debugger = [PDDebugger defaultInstance];

        [debugger enableNetworkTrafficDebugging];

        [debugger forwardAllNetworkTraffic];

        [debugger enableCoreDataDebugging];

       [debugger connectToURL:[NSURL URLWithString:@"ws://127.0.0.1/device"]];

    4.然后编译工程,运行,在浏览器中就可以浏览到信息了。

    二:在真机下使用ponyDebugger工具

    在真机下运行ponyDebugger这个工具,其它的地方都相似,唯一不同的地方有3:

    (1)要确保手机和pc在统一网络下(手机和pc要连接到统一无线网络中)

    (2)确认你的ip地址

            直接在concle模式下,输入 ifconfig,查找出你的ip地址(我的是en1下inet ,为什么我也不懂,我是试出来的结果,那位高人知道给我解释下行吗?)

    (3).将所有地址修改为2中的ip地址,主要设计到3个地方,

    一是~/Library/PonyDebugger/bin/ponyd serve --listen-interface=你的ip

    二是浏览器地址栏中:://你的ip:9000

    三是代码中:[debugger connectToURL:[NSURL URLWithString:@"ws://你的ip/device"]];

    这样ponyDebugger在真机或是模拟器中都搭建起来了,要想多了解,多看看源码。。。
    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值