Using ASIHTTPRequest in an iPhone project
1) Add the files
Copy the files you need to your project folder, and add them to your Xcode project. An overview of the ASIHTTPRequest source files appears here.
If you aren't sure which files you need, it's best to copy all the following files:
- ASIHTTPRequestConfig.h
- ASIInputStream.h
- ASIInputStream.m
- ASIHTTPRequest.h
- ASIHTTPRequest.m
- ASINSStringAdditions.h
- ASINSStringAdditions.m
- ASIFormDataRequest.h
- ASIFormDataRequest.m
- ASINetworkQueue.h
- ASINetworkQueue.m
iPhone projects must also include:
- ASIAuthenticationDialog.h
- ASIAuthenticationDialog.m
- One of the Reachability classes - see below
2) Link against CFNetwork, SystemConfiguration and zlib
Choose Project -> Edit Active Target from the menu.
Click the plus button in the bottom left of the window.
Choose CFNetwork.framework from the list, and click Add.
Click the plus button again, choose SystemConfiguration.framework and click Add.
Click the plus button once more, and this time, choose libz.1.2.3.dylib and click Add.
3) Configure Reachability
ASIHTTPRequest uses Apple's Reachability class on iPhone OS
There are two versions of Apple's Reachability class, both of which are included in the source distribution of ASIHTTPRequest in the External/Reachability folder.
- Version 2.0 is the latest version. You should use this if you are targeting iPhone OS 3.x and later
To use Version 2.0, include Reachability.h + Reachability.m from the Reachability 2.0 folder in your project, and ensure REACHABILITY_20_API (in ASIHTTPRequestConfig.h) is set to 1. - Version 1.5 is the old version, but it is compatible with both iPhone OS 2.2.1 and iPhone OS 3.0 and later. You should use this if your application needs to work on iPhone OS 2.2.1.
To use Version 1.5, include Reachability.h + Reachability.m from the Reachability 1.5 folder in your project, and ensure REACHABILITY_20_API (in ASIHTTPRequestConfig.h) is set to 0.
Using ASIHTTPRequest in a Mac OS X project
To use ASIHTTPRequest in a Mac project, you'll need to link against:
- SystemConfiguration.framework + zlib (as above)
- CoreServices.framework
CFNetwork is part of the CoreServices framework on Mac OS X. Unless you are writing a console-based application, your application is probably already setup to link with CoreServices, but if not, simply add CoreServices.framework in the same way as described above.
Building the unit tests
As of version 0.97, GHUnit is included with ASIHTTPRequest, so running the tests should be as easy as changing to the test target.
Some of the tests require additional information to run:
- To run the S3 tests, you need to specify your S3 access details in the top of ASIS3RequestTests.m
- To run the proxy tests, you need to specify details of your proxy server, and a PAC file if you want to run the PAC tests. Note that the proxy tests require a proxy server, while all the other tests require that you don't have a proxy server.
Support ASIHTTPRequest - buy Space Harvest - my new real-time strategy game for iPod Touch & iPhone!
