iOS AFNetworking (AFJSONRequestOperation) works in

2019-08-30 12:21发布

问题:

I'm using AFJSONRequestOperation in an iPhone app (targeting iOS 5) - basically making a post to my website with various form data (including an image). This worked fine, and the live app-store version worked fine. I made some changes and Apple finally accepted my new binary - oddly the POST never hits my server now.

First thoughts: I broke it. Rolled back to the original release and sure enough, it is still broken.

Now the weird part: In XCode, when I deploy the app to my iPhone (or simulator) it works, my server gets the POST and all is well. As soon as I deploy a release binary, it doesn't. Tried a few different IPAs via Testflight, and it is clear that the version Apple approved doesn't work.

Problem is, I obviously can't debug it because it works when debugging, and did previously.

Anyone had this experience, or know of a potential trip-up here?

I'm totally stumped.

回答1:

You can change the xcode 'Run app' scheme to use a release build, goto 'edit scheme', select 'run', then 'Build configuration' (under the 'Info' tab) to 'Release'.

It won't be perfect though, you'll get some oddities when debugging due to the optimiser having reordered code etc. You may have to add a large number of NSLog()s to trace through what path the code takes.