Help us understand the problem. What is going on with this article?

PonyDebuggerでiOSの通信を覗いてみる

More than 5 years have passed since last update.

PonyDebuggerはiOSアプリにクライアントライブラリを仕込み、OSX側のサーバ(ponyd)をChromeのDeveloperToolで見ることで、iOSアプリ内の動作を可視化できる便利なツールです。

今回は通信処理の可視化に絞ってご紹介します。

仕組み

20150214_通信のパフォーマンス改善_IOS__key.jpg

リクエスト単位で確認することができます。

20150214_通信のパフォーマンス改善_IOS__key.jpg

サーバのインストール @OSX

以下のコマンドでインストールします。

$ curl -s https://cloud.github.com/downloads/square/PonyDebugger/bootstrap-ponyd.py | python - --ponyd-symlink=/usr/local/bin/ponyd ~/Library/PonyDebugger

自分の環境ではponydebuggerが見つからないとエラーが発生しました。

New python executable in /Users/susieyy/Library/PonyDebugger/bin/python
Installing setuptools.............................done.
Installing pip.....................done.

... 

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/susieyy/.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 542, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Users/susieyy/Library/PonyDebugger/bin/pip', 'install', '-U', '-e', 'git+https://github.com/square/PonyDebugger.git#egg=ponydebugger']' returned non-zero exit status 1

こちらを参考に対応します。

@see Installations fails, missing requirement pybonjour

# Activate your virtualenv
$ source ~/Library/PonyDebugger/bin/activate
# 
$ 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

以上で、サーバのインストールが完了しました。

起動

$ cd ~/Library/PonyDebugger
$ source ~/Library/PonyDebugger/bin/activate
$ ponyd serve --listen-interface=0.0.0.0

クライアントのインストール @iOS

PodfileにPonyDebuggerを記述します。

$ vi Podfile
pod 'PonyDebugger', '~> 0.4.0'

$ pod install

AppDelegate.m の pplication:didFinishLaunchingWithOptions:メソッド内に以下を記述します。

    PDDebugger *debugger = [PDDebugger defaultInstance];   
    [debugger enableNetworkTrafficDebugging];
    [debugger forwardAllNetworkTraffic];

サーバへのAutoConnectがうまくいかない場合は、OSXのWifiのアドレスを直接指定します。

    [debugger autoConnect];

or 

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

確認

以下のURLにChromeでアクセスします。うまく接続できていれば、一覧にiOSが表示されます。

http://localhost:9000

REF

susieyy
フリーランス - スタートアップエンジニアリングアドバイザー - iOS技術顧問 - プロトタイプ開発
https://susieyy.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした