Claudio
Claudio

Reputation: 2037

iOS Simulator - offline mode

Does anybody know how to make the iPhone/iPad simulator become offline?

Regards!

Upvotes: 46

Views: 41588

Answers (8)

Juli T.
Juli T.

Reputation: 9

iOS Simulators Offline Mode:

In terminal: sudo nano /etc/hosts Add: 127.0.0.1 your-domain.com

more info step by step : medium guide

Upvotes: 0

Ramis
Ramis

Reputation: 16549

Install Network Link Conditioner from Apple. And you will have possibility to change to offline mode.

enter image description here

Upvotes: 5

Arnaud Moret
Arnaud Moret

Reputation: 753

On macos, turning off wifi and plugging your phone with USB hotspot mode on works a treat. Simple and reliable for everything including testing reachability.

Upvotes: -1

xius
xius

Reputation: 595

Ideally, all app's network communication goes through one point. By commenting out a relevant code or creating a dummy error it's rather straightforward to make it look like all the responses have timed out.

[[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
//          if (error) {
              if (self.delegate) {
                  [self.delegate networkError: error];
              }
//          } else {

I find it good enough for the actual development. It's quick and cheap, even if a bit dirty, while allowing to continue working without the hassle of a constant WiFi toggling. Once successfully enabled, even pretty specific scenarios are easy to simulate.

When the work is finished, turning off macOS WiFi for the final testing is a good idea, though.

Upvotes: 0

Apollo
Apollo

Reputation: 1986

If you want to test something in the local environment like a web app for iOS with cached features, you can add a rule to your hosts file pointing to your localhost, then you can comment the line every time you desire to make it inaccessible.

Upvotes: 0

Piotr B
Piotr B

Reputation: 69

There's a tool called "Network Link Conditioner" but it seems that its only for OX Lion and xCode 4.1+ installed. Take look at: http://osxdaily.com/2011/08/10/simulate-internet-connectivity-bandwidth-speeds-network-link-conditioner/ - i use it almost everyday :)

Upvotes: 2

Peter Kazazes
Peter Kazazes

Reputation: 3628

Install Little Snitch and temporarily block all connections from iOS Simulator when the dialog comes up.

Upvotes: 13

HaloWebMaster
HaloWebMaster

Reputation: 928

If you set os x offline, the iPad simulator will be offline. Otherwise, no.

Upvotes: 6

Related Questions