title: How to get flutter run to work reliably on OSX with iPhone?
body: <p><strong>Environment</strong></p>
  
  <ul>
  <li>Laptop: MacOS Mojave 10.14.4 </li>
  <li>Flutter: Flutter MacOS v1.2.1 stable</li>
  <li>iPhone: iPhone X running ios 12.2 (16E227)</li>
  <li>Xcode: 10.2 (10E125)</li>
  </ul>
  
  <p><strong>Problem</strong></p>
  
  <p>If I try enough times of disconnect, connect, "trust this computer", enter pass code, I will eventually be able to issue </p>
  
  <pre><code>$ flutter run
  </code></pre>
  
  <p>and it work.</p>
  
  <p>Nine out of ten times, I get this result:</p>
  
  <pre><code>$ flutter run
  ideviceinfo returned an error:
  ERROR: Could not connect to lockdownd, error code -19
  </code></pre>
  
  <p>At this point, the iphone will display "Trust this computer?" dialog.  Note, prior to generating this info, I made clean, build, run on this phone using xcode a regular objective c based app and it worked without any issues.</p>
  
  <p>Regarding <code>$ flutter doctor</code>results</p>
  
  <p>At one point, it requests I do this <code>$ brew install --HEAD usbmuxd</code>.  When I do so, I get this truncated error log:</p>
  
  <pre><code>checking how to hardcode library paths into programs... immediate
  ./configure: line 16735: syntax error near unexpected token `libplist,'
  ./configure: line 16735: `PKG_CHECK_MODULES(libplist, libplist &gt;= $LIBPLIST_VERSION)'
  
  READ THIS: https://docs.brew.sh/Troubleshooting
  </code></pre>
  
  <p>I work around this by doing:</p>
  
  <pre><code>$ brew install usbmuxd
  ==&gt; Downloading https://homebrew.bintray.com/bottles/usbmuxd-1.0.10_1.mojave.bottle.tar.gz
  Already downloaded:/Users/davis/Library/Caches/Homebrew/downloads/4c553d1494698a85e85d8dc6de76b96e23ab1ac6450b0f8200050c6cc994e2fe--usbmuxd-1.0.10_1.mojave.bottle.tar.gz
  ==&gt; Pouring usbmuxd-1.0.10_1.mojave.bottle.tar.gz
    /usr/local/Cellar/usbmuxd/1.0.10_1: 13 files, 120KB
  </code></pre>
  
  <p>Still later in the <code>$ brew doctor</code> suggestions I get an error with <code>$ brew install --HEAD libimobiledevice</code> but I simply re-issue the command without the <code>--HEAD</code> option like above and this step works.</p>
  
  <p><strong>Other datapoints</strong></p>
  
  <p>If I open XCode, choose a iphone X simulator (which is my phone model) and run the app, it will open and run the app in the simulator.</p>
  
  <p>If I then choose to deploy to my iPhone, it will run on the iPhone.  </p>
  
  <p>After I have run the app on the simulator or iPhone from XCode, I stop the app, close the simulator, close XCode.  Then when I <code>$ open -a Simulator</code> it will restart the simulator in iPhone X mode.  I can then <code>$ flutter run</code>.  If I then stop the app, close the Simulator, attach the iPhone, <code>$ flutter run</code> it prompts to trust this computer and prints the error message shown above.  If rerun <code>$ flutter run</code> it does not ask to trust the computer it simply prints the error message.</p>
  
  <p><strong>Yet another attempt</strong></p>
  
  <p>This <a href="https://github.com/flutter/flutter/issues/23341" rel="nofollow noreferrer">post</a> mentions using idevice_id and unpairing the device in xcode.  I attempted this but as soon as I unpair the phone, it will automatically appear in the list as paired.  If I quickly unplug the phone after I unpair, then it will prompt for a trust/dont trust message and say in the dialog the phone is connected but not activated.  If I then use idevice_id and turn off wi-fi, I get similar messages as shown in the post above but it never says "activated".  When I do the -u option, it will print the name of the phone.  Afterwards the error persists.</p>