Last Updated: February 25, 2016
·
1.538K
· rane

Dealing with iPhone's flaky personal hotspot

Ever since iOS has had the Wi-Fi tethering option I've never found it fully reliable. Very often my Mac just can't see the network or the connection times out.

Recently I figured out a way have it working 95% of the time after these two steps:

  1. Enable Personal Hotspot in Settings and keep the view open
  2. networksetup -setairportnetwork en0 YOUR_IPHONE_SSID YOUR_WIFI_PASSWORD

Sometimes I have to run the command twice until it picks it up.

Update:

Here's a small ruby script you can run before you go to your phone and do step 1. It will keep connecting to your Personal Hotspot until it works.

#!/usr/bin/env ruby

def wifi_connect(wifi, sid, pw)
  out = `networksetup -setairportnetwork #{wifi} #{sid} #{pw}`
  puts out
  !(out =~ /could not find/i)
end

sid, pw = ARGV[0..1]
(wifi_connect("en0", sid, pw) and exit 0) while 1

https://gist.github.com/raine/053755ca8545edec7fdb

$ use-wifi rjv-iphone foobar123
Could not find network rjv-iphone
Could not find network rjv-iphone
Could not find network rjv-iphone

$ 

1 Response
Add your response

Very handy. I've been pretty frustrated dealing with this.

over 1 year ago ·