Flutter Run - lost connection to device (Simulator iPhone 11 Pro Max)

Viewed 842

everytime I intend run a project on the IOS simulator I have a message "Lost connection to device". It previously worked fine, i don't remember exactly to interfere in some way with Xcode or something. Everything OK on flutter doctor though...

The report I receive is:

Mariuss-MacBook-Pro:my_repository-15.10 mariuspruna$ flutter run -d D79DA193-4A54-4D3F-B029-E42F046EEFAF
Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Running Xcode build...                                                  

 ├─Assembling Flutter resources...                          13.8s
 └─Compiling, linking and signing...                        15.6s
Xcode build done.                                           34.2s
*** First throw call stack:                                             
(                                                                       
        0   CoreFoundation                      0x00007fff23b98bde __exceptionPreprocess + 350
        1   libobjc.A.dylib                     0x00007fff503b5b20 objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff23b98958 +[NSException raise:format:arguments:] + 88
        3   Foundation                          0x00007fff255eb6f5 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
        4   UIKitCore                           0x00007fff47163f36 -[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:] + 255
        5   UIKitCore                           0x00007fff471643d9 -[UIApplication statusBar] + 24
        6   Foundation                     <…>                          
Lost connection to device.                                              
Syncing files to device iPhone 11 Pro Max...                            

Mariuss-MacBook-Pro:my_repository-15.10 mariuspruna$ 

Thanks for any suggestions.

1 Answers

The problem for me was a permission error when the app was trying to access user geolocation but in order to first see that error (Android Studio was not helping), I needed to connect my physical iPhone to my laptop using a cable and try to deploy the app there directly from Xcode.

Then after seeing the error on Xcode. Inside the Info.plist file, I add these two lines lo fix it:

<key>NSLocationWhenInUseUsageDescription</key>
<string>This application requires location services to properly work</string>

<key>NSLocationAlwaysUsageDescription</key>
<string>This application requires location services to properly work</string>

Then, the app was successfully deployed in the emulator and my real device.

Related