沐风白桦

大圣休得胡闹

使用charles远程调试iOS移动应用

| Comments

做iOS移动应用很多开发者会喜欢抓网络发包、回包来联调服务端借口以及定位其他网络问题。如果在Windows系统可以使用fiddler来做iOS的远程代理,只要fiddler所在系统与iOS设备同时连上同一个局域网即可。但是在OSX系统上没有fiddler,相信做iOS开发用windows系统的不多,其实不要纠结:其实跨平台http抓包工具charles也可以做远程代理,也就是说iOS也可以通过charles来调试,charles调试的相关技术都可以对iOS适用。

那怎么才能实现charles做iOS的远程代理呢?先看charles官网的文档。

USING CHARLES FROM AN IPHONE

To use Charles as your HTTP proxy on your iPhone you must manually configure the HTTP Proxy settings on your WiFi network in your iPhone's Settings.

Go to the Settings app, tap Wi-Fi, find the network you are connected to and then tap the blue disclosure arrow to configure the network. Scroll down to the HTTP Proxy setting, tap Manual. Enter the IP address of your computer running Charles in the Server field, and the port Charles is running on in the Port field (usually 8888). Leave Authentication set to Off.

All of your web traffic from your iPhone will now be sent via Charles. You should see a prompt in Charles when you first make a connection from the iPhone, asking you to allow the traffic.

Remember to disable the HTTP Proxy in your Settings when you stop using Charles, otherwise you'll get confusing network failures in your applications!

AppleScript:循环

| Comments

AppleScript是一个比较接近自然语言脚本语言,习惯了传统编程的程序猿一时还真难以适应这种表达和思考方式,不过了解其中的规律后,你就会发现AppleScript其实是一种非常容易、非常生活化的编程语言。在这篇文章里面着重介绍循环控制指令。

Install git with macport

| Comments

不知道怎么回事儿,我的git有时候会抽风,现在又抽风了:我的git-svn不见了,这里是用macport安装的脚本,以备下次重装又要google半天…

install git with svn
1
sudo port install git-core +svn +doc +bash_completion +gitweb

BitmapData.draw() 和 DisplayObject.blendMode

| Comments

BitmapData.draw()如果遇到DisplayObject.blendMode有时候效果会异常,这里有个陷阱…oops

simple exmaple
1
2
3
4
5
6
7
8
9
10
11
var container:Sprite = new [some DisplayObjectContainer class]();
var childA:Sprite = new [some DisplayObject class]();
var childB:Sprite = new [some DisplayObject class]();

childA.blendMode = BlendMode.ADD;

container.addChild(childA);
container.addChild(childB);

var data:BitmapData = new BitmapData(container.width, container.height, true, 0);
data.draw(container);

如上面这段代码,看起来没有什么问题,但是如果把data通过Bitmap显示出来,就会发现效果有些诡异,这是因为BitmapDatadraw的时候,会自动忽略childA.blendMode属性,除非把childA的父级容器设置为container.blendMode = BlendMode.LAYER