iPhone Simulator - set HTTP proxy - cocoa-touch

I'm coding an iPhone app that needs to make small HTTP requests to the Internet. Within our corp LAN, all HTTP traffic has to go through Squid.
The simulator is clearly capable of using a proxy - since Mobile Safari works. But, how do I get/set the proxy settings in code?
A bunch of the headers are commented out for the simulator. For example,
CFNetworkCopySystemProxySettings
In CFProxySupport.h is not available to the simulator - only to the device. I've tried hardcoding like this:
CFReadStreamSetProperty(stream, kCFProxyHostNameKey, #"internal.proxy.servername");
CFReadStreamSetProperty(stream, kCFProxyPortNumberKey, [NSNumber numberWithInt:80]);
CFReadStreamSetProperty(stream, kCFProxyTypeKey, kCFProxyTypeHTTP);
But no joy.
Thoughts?

You can try:
"System Preferences" -> "Network" -> Select your network device -> "Advanced" -> "Proxies"

You can try using Proxifier: http://www.proxifier.com/mac/
It enables you to set a proxy to any program.
Not what you asked but it should solve your problem.

To close this off. It looks like this is fixed in iOS4 SDK - the network stack on the simulator will use the Mac's proxy for any HTTP calls.

Looks like XCode 4.0 (4A304a) has broke this again. If I set the stack to proxy http calls through Burp, works fine with every app (Safari, etc) but the simulator.

Simply restart the iPhone simulator.
for this i use the following trick
go to setting >> General >> Accessibility >> bold text to switch on >> picker view open and ask for restart for make it effective >> press continue >> iPhone simulator now restart
the pop-up ask for user name and password for proxy...
tested in ios simulator 7.1

This question is a bit old, but thought I would add my findings for reference. In the iOS 4.x SDK at least, the following code works on both the simulator and the iPhone.
CFDictionaryRef systemProxyDict = CFNetworkCopySystemProxySettings();
CFReadStreamSetProperty(m_resultRef, kCFStreamPropertyHTTPProxy, systemProxyDict);

The simulator is probably not capable of using a proxy. It is using the standard networking stack provided by Mac OS X, and that is what is using the proxy.
If the constants are commented out during simulator use, and you've tried hard-coding it with no luck, then this is probably one of the many things that is simply not the same between the simulator and a device, and you'll have to test this part of your application on a device.

Just close and reopen simulator after applying configuration.

Related

centralManagerDidUpdateState always return PoweredOff

In my app I check if bluetooth is turn on, if is turn off I show alert to the user in order to enable it. For this functionality I using centralManagerDidUpdateState and check [central state]. On iOs 10 device works fine, but, on iOs 11 doesn't work, always return CBCentralManagerStatePoweredOff after do this:
1.- I go to configuration and I turn off the bluetooth.
2.- I open the app, the centralManagerDidUpdateState call back is called and PoweredOff is detect.
3.- I go to configuration and I turn on the bluetooth.
4.- I back to the app, and centralManagerDidUpdateState is called and PoweredOff is still the state when the bluetooth is On.
Is this issue an iOs 11 bug?, anyone knows any solution for check the bluetooth is turn on?
Thanks
I also faced with the same issue. I was testing BLE functionality by using this sample project "https://github.com/jasonmgeorge/BLEScanner" one device on iOS 10.3.3 and another on iOS 11.2. On iOS 10.3.3 it was working fine but on the other device, I was getting the same error all the time. Then I realized that
NSBluetoothPeripheralUsageDescription
wasn't in Info.plist, so I added. Again I got "CBCentralManagerStatePoweredOff". I went to settings to power off Bluetooth and on again. It's working magically. It's a iOS 11 bug most probably. Please check your implementation. It's not very consistent but sometimes it works.

IBM MobileFirst 8.0 WLAuthorizationManager.obtainAccessToken() No Response

I'm previewing the MobileFirst app (Cordova) on both browser and iOS Emulator but there doesn't seem to be any response when I call WLAuthorizationManager.obtainAccessToken().
I've tried to allow cross origin request but still face the same issue. Does anyone have any suggestions for what I should look at?
I had a similar issue on the iOS emulator. I even used Wireshark to see what was happening and the app never fired the authorisation request.
In the end I found that if you're running XCode 8.x, you have to enable keychain sharing by selecting the project -> Capabilities -> Keychain Sharing, and setting it to On.
After that I had to register the app again and all worked fine.
Make sure when you register or push the app and you're prompted for the version number, that you enter x.x.x instead of x.x - otherwise the server will not recognise the app.
Another thing to double check is the mfp:server runtime and url values in the config.xml file, if your pc's ip address has changed then the url value could be incorrect.

Cannot view video from publisher using Chrome to iPad with OpenTok

I'm currently trying to set up a connection between my web client and my iOS app, but for some reason my iOS client only sees a black box when using Chrome (version 33). I can see the video just fine if I use Firefox (both in my app and when I put the browsers side-by-side, they can see each other).
This doesn't appear to be a documented known issue with the JavaScript SDK, and I can't see any recent discussion about this on the forums (last post was mine).
The iOS sample can be located here (samples/OpenTokHelloWorld) with the browser page in samples/OpenTokHelloWorld/browser_demo.html
I suggest cd'ing into samples/OpenTokHelloWorld and running python -m SimpleHTTPServer, as it can't be run from a file:/// path.
Here is what my iPad sees:
Chrome:
Firefox:
And Chrome/Firefox (respectively), both publishing video from the same camera
Edit: after testing on other machines, it may be something specific to my environment even though none of my extensions run in Incognito and I don't have any custom plugins installed.
It looks like the OpenTok mobile SDKs with the specific webcam I was using has issues. On Android the video stream will display for a brief moment then segfault, and on iOS there will be no video at all.
I have tested this many times and could not reproduce what you are seeing in your chrome.
Without seeing any console errors or iOS logs the best suggestion is to try clearing your cache, or maybe restarting your computer (longshot)

App Wireless Distribution not working in iOS7. Internet Connection needed?

In iOS6 I used to install some of my apps over an adhoc network without internet sharing. So the iPad had no internet connection. Therefore I use a typical html and plist file. Everything was alright.
Now, in iOS7 the installation is not working anymore. It is just stuck in "Waiting" and nothing more happens. (Note: It is still working on my iOS6 iPad)
First I thought something might be wrong with my plist, but then I copied the files to my IIS Server and installed it from there. Here I had a internet connection on my iPad and everything worked out.
Is it possible that the wireless distribution now needs an internet connection in iOS7 e.g. to check the ipa in the app store or something like that? Because this is the only difference I can see.
The app is signed with a valid distribution profile.
Thanks for your help.
It turned out the installation of apps over the air in iOS 7 really needs an internet connection now. The iPad tries to contact at least the following URLs before installing the app.
ax.init.itunes.apple.com: The device obtains the current file-size limit for downloading apps over the cellular network.
ocsp.apple.com: The device contacts this site to check the status of the distribution certificate used to sign the provisioning profile.
It seems in iOS6 it was ok if those URLs were not reachable and now in iOS 7 they have to be reachable.
Well i just had the same problem and I figured it out. At least on my xcode this is what happened. Turns out the application target release code siging identities auto set to developer and not their current state, from xcode 4.x, which is distribution. So when I went to distribute my application I kept getting the same error you had. So Click on your project name in your project explorer then click on the application target, not the project, and make sure the code signing identity is not set to developer for your releases. I have no idea why the code signing identities were automatically set to the developer profile, maybe there was some sort of bug when updating from xcdoe 4.x to xcode 5 that caused this. But now other devices are able to install the program. Hope this helps.

How to test iphone p2p aplications?

Is there a way to test iphone OS 3.0 p2p applications?
Can I run multiple iphone simulator instances? Aperantly no.
Any help?
I put up a detailed post on how to do this a couple weeks ago, so I'll just refer you to it: http://ramin.firoozye.com/2009/06/18/debugging-peer-to-peer-and-wifi-apps-on-the-iphone/
Try to get permission from work or someplace with several computers on a LAN to run several instances. This will let you test network stuff, too.
According to this forum post you will need to test it on two real devices.
You must use 2 hardware devices for testing gamekit p2p connections.
Untested, but you should be able to run two instances of the iPhone Simulator by duplicating it..
Run the simulator as normal for phone 1.
For the second, go to /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/ and copy (not move) the application somewhere (your Desktop?). When you run the copy, it will ask where the Developer Tools are installed and the application to run. Provide this and it should run a second copy.
Also, perhaps you could test it on both your real phone and the simulator?
I found a solution:
activate tethering on your iPhone
connect your mac with the simulator on it to the phone
Now you can test the gamekit on your sim and your iPhone
(I also have internet-sharing activated on my macbook - but I think the tethering-part is important... oh, this implies that bluetooth is running on the iPhone and the mac, of course)...
I'm pretty happy I found this solution - this was a major drawback...
I try to the same test on my macbook OS5.0 and iPhone 3gs , the iPhone simulator app can see the iPhone device via the app , but can not connected ... does this problem cause the bluetooth device is unauthorized ?
install VMware seem great but too trouble...