iosandroid-studioflutterlibimobiledevice

Flutter Error : Getter not found : 'iMobileDevice' when trying to rebuild Flutter tool


Good afternoon,

I am following the tutorial on Windows 7 for an Ipad on IOS 9.3.5 :

https://medium.com/flutter-community/developing-and-debugging-flutter-apps-for-ios-without-a-mac-8d362a8ec667 and I'm stuck at rebuilding the Flutter Tool. (Last part of the tutorial)

I downloaded (from the link of the tutorial) and copied in C:\src\flutter\bin the libimobiledevice, ideviceinstaller and which binaries. Then I ran the git apply ios.diff which gives me multiple errors, sometimes it's just about mac.dart, and sometimes it's more like this :

error: patch failed: packages/flutter_tools/lib/src/ios/devices.dart:103
error: packages/flutter_tools/lib/src/ios/devices.dart: patch does not apply
error: patch failed: packages/flutter_tools/lib/src/ios/ios_workflow.dart:26
error: packages/flutter_tools/lib/src/ios/ios_workflow.dart: patch does not apply
error: patch failed: packages/flutter_tools/lib/src/ios/mac.dart:124
error: packages/flutter_tools/lib/src/ios/mac.dart: patch does not apply

Then I found this command in here : git: patch does not apply

git apply --reject --whitespace=fix mychanges.patch 

What I got was : (don't mind the content of the Future<String>, it's because I've already changed it to what it was supposed to be)

Checking patch packages/flutter_tools/lib/src/ios/mac.dart...
error: while searching for:
  Future<String> getAvailableDeviceIDs() async {
    try {
      final ProcessResult result = await processManager.run(<String>['idevice_id', '-l']);
      if (result.exitCode != 0)
        throw ToolExit('idevice_id returned an error:\n${result.stderr}');
      return result.stdout;
    } on ProcessException {
      throw ToolExit('Failed to invoke idevice_id. Run flutter doctor.');

error: patch failed: packages/flutter_tools/lib/src/ios/mac.dart:124
Applying patch packages/flutter_tools/lib/src/ios/devices.dart with 1 reject...
Rejected hunk #1.
Applying patch packages/flutter_tools/lib/src/ios/ios_workflow.dart with 1 reject...
Rejected hunk #1.
Applying patch packages/flutter_tools/lib/src/ios/mac.dart with 1 reject...
Rejected hunk #1.

At this point I manually pasted the right content in the mac.dart file (as you might have seen in the error above), but I am still not sure everything went well because of the :

error: patch failed: packages/flutter_tools/lib/src/ios/mac.dart:124

Anyway, I kept going and ran the command to rebuild the flutter tool:

bin\cache\dart-sdk\bin\dart --snapshot=.\bin\cache\flutter_tools.snapshot --packages=.\packages\flutter_tools\.packages .\packages\flutter_tools\bin\flutter_tools.dart

Finally, the output is this :

C:\src\flutter>bin\cache\dart-sdk\bin\dart --snapshot=.\bin\cache\flutter_tools.snapshot --packages=.\packages\flutter_tools\.packages .\
packages\flutter_tools\bin\flutter_tools.dart
packages/flutter_tools/lib/src/ios/ios_workflow.dart:20:30: Error: Getter not found: 'iMobileDevice'.
  bool get canListDevices => iMobileDevice.isInstalled || (xcode.isInstalledAndMeetsVersionCheck && xcode.isSimctlInstalled);
                             ^^^^^^^^^^^^^
packages/flutter_tools/lib/src/ios/ios_workflow.dart:20:30: Error: The getter 'iMobileDevice' isn't defined for the class 'IOSWorkflow'.
 - 'IOSWorkflow' is from 'package:flutter_tools/src/ios/ios_workflow.dart' ('packages/flutter_tools/lib/src/ios/ios_workflow.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'iMobileDevice'.
  bool get canListDevices => iMobileDevice.isInstalled || (xcode.isInstalledAndMeetsVersionCheck && xcode.isSimctlInstalled);
                             ^^^^^^^^^^^^^

Is this "iMobileDevice" related to this libimobiledevice ? I can run any of the ideviceinstaller.exe or idevice_id.exe, so I guess I installed it correctly.

I am missing something important to correct this error ?

Thanks a lot for your time :)


Solution

  • Thanks a lot ! Importing 'mac.dart' allowed me to apply everything correctly.

    I then ran flutter attach, and here is what I get : (I guess only the first lines are useful)

    D:\Beerproject>flutter attach
    
    Sending crash report to Google.
    Crash report sent (report ID: 5d71ca5958062efd)
    Oops; flutter has exited unexpectedly.
    
    Sending crash report to Google.
    Crash report sent (report ID: 5024a42feb468e2b)
    Oops; flutter has exited unexpectedly.
    Unhandled exception:
    Unsupported operation: Control of iOS devices or simulators only supported on Mac OS.
    #0      IOSDevice.getAttachedDevices (package:flutter_tools/src/ios/devices.dart:172:7)
    <asynchronous suspension>
    #1      IOSDevices.pollingGetDevices (package:flutter_tools/src/ios/devices.dart:117:57)
    #2      PollingDeviceDiscovery.devices (package:flutter_tools/src/device.dart:270:52)
    <asynchronous suspension>
    #3      DeviceManager.getAllConnectedDevices (package:flutter_tools/src/device.dart:136:46)
    <asynchronous suspension>
    #4      DeviceValidator.validate (package:flutter_tools/src/doctor.dart:760:54)
    <asynchronous suspension>
    #5      Doctor.startValidatorTasks (package:flutter_tools/src/doctor.dart:140:52)
    #6      Doctor.diagnose (package:flutter_tools/src/doctor.dart:211:41)
    #7      _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
    #8      Doctor.diagnose (package:flutter_tools/src/doctor.dart:201:24)
    #9      _doctorText.<anonymous closure> (package:flutter_tools/runner.dart:202:26)
    #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:29)
    #11     _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
    #12     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:7)
    #13     _rootRun (dart:async/zone.dart:1124:13)
    #14     _CustomZone.run (dart:async/zone.dart:1021:19)
    #15     _runZoned (dart:async/zone.dart:1516:10)
    #16     runZoned (dart:async/zone.dart:1463:12)
    #17     AppContext.run (package:flutter_tools/src/base/context.dart:153:18)
    #18     _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
    #19     AppContext.run (package:flutter_tools/src/base/context.dart:140:19)
    #20     _doctorText (package:flutter_tools/runner.dart:201:19)
    #21     _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
    #22     _doctorText (package:flutter_tools/runner.dart:197:27)
    #23     _createLocalCrashReport (package:flutter_tools/runner.dart:179:32)
    #24     _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
    #25     _createLocalCrashReport (package:flutter_tools/runner.dart:164:37)
    #26     _handleToolError (package:flutter_tools/runner.dart:134:33)
    #27     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
    #28     _rootRunUnary (dart:async/zone.dart:1132:38)
    #29     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
    #30     _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
    #31     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
    #32     Future._propagateToListeners (dart:async/future_impl.dart:707:32)
    #33     Future._completeWithValue (dart:async/future_impl.dart:522:5)
    #34     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
    #35     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
    #36     CrashReportSender.sendReport (package:flutter_tools/src/reporting/crash_reporting.dart)
    #37     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
    #38     _rootRunUnary (dart:async/zone.dart:1132:38)
    #39     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
    #40     _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
    #41     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
    #42     Future._propagateToListeners (dart:async/future_impl.dart:707:32)
    #43     Future._complete (dart:async/future_impl.dart:512:7)
    #44     Stream.fold.<anonymous closure> (dart:async/stream.dart:801:18)
    #45     _rootRun (dart:async/zone.dart:1120:38)
    #46     _CustomZone.run (dart:async/zone.dart:1021:19)
    #47     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
    #48     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:389:13)
    #49     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:399:15)
    #50     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:283:7)
    #51     _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:96:11)
    #52     _EventSinkWrapper.close (dart:async/stream_transformers.dart:23:11)
    #53     _StringAdapterSink.close (dart:convert/string_conversion.dart:249:11)
    #54     _Utf8ConversionSink.close (dart:convert/string_conversion.dart:300:20)
    #55     _ConverterStreamEventSink.close (dart:convert/chunked_conversion.dart:80:18)
    #56     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:141:24)
    #57     _rootRun (dart:async/zone.dart:1120:38)
    #58     _CustomZone.run (dart:async/zone.dart:1021:19)
    #59     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
    #60     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:389:13)
    #61     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:399:15)
    #62     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:283:7)
    #63     _ForwardingStream._handleDone (dart:async/stream_pipe.dart:106:10)
    #64     _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:172:13)
    #65     _rootRun (dart:async/zone.dart:1120:38)
    #66     _CustomZone.run (dart:async/zone.dart:1021:19)
    #67     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
    #68     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:389:13)
    #69     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:399:15)
    #70     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:283:7)
    #71     _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:96:11)
    #72     _EventSinkWrapper.close (dart:async/stream_transformers.dart:23:11)
    #73     _Uint8ListConversionSink.close (dart:_http/http_impl.dart:577:13)
    #74     _ConverterStreamEventSink.close (dart:convert/chunked_conversion.dart:80:18)
    #75     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:141:24)
    #76     _rootRun (dart:async/zone.dart:1120:38)
    #77     _CustomZone.run (dart:async/zone.dart:1021:19)
    #78     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
    #79     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:389:13)
    #80     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:399:15)
    #81     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:283:7)
    #82     _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:96:11)
    #83     _EventSinkWrapper.close (dart:async/stream_transformers.dart:23:11)
    #84     _ByteAdapterSink.close (dart:convert/byte_conversion.dart:62:11)
    #85     _FilterSink.close (dart:io/data_transformer.dart:637:11)
    #86     _ConverterStreamEventSink.close (dart:convert/chunked_conversion.dart:80:18)
    #87     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:141:24)
    #88     _rootRun (dart:async/zone.dart:1120:38)
    #89     _CustomZone.run (dart:async/zone.dart:1021:19)
    #90     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
    #91     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:389:13)
    #92     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:399:15)
    #93     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:283:7)
    #94     _ForwardingStream._handleDone (dart:async/stream_pipe.dart:106:10)
    #95     _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:172:13)
    #96     _rootRun (dart:async/zone.dart:1120:38)
    #97     _CustomZone.run (dart:async/zone.dart:1021:19)
    #98     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
    #99     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:389:13)
    #100    _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:399:15)
    #101    _BufferingStreamSubscription._close (dart:async/stream_impl.dart:283:7)
    #102    _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:772:19)
    #103    _StreamController._closeUnchecked (dart:async/stream_controller.dart:629:7)
    #104    _StreamController.close (dart:async/stream_controller.dart:622:5)
    #105    _HttpParser._closeIncoming (dart:_http/http_parser.dart:1037:23)
    #106    _HttpParser._doParse (dart:_http/http_parser.dart:752:11)
    #107    _HttpParser._parse (dart:_http/http_parser.dart:318:7)
    #108    _HttpParser._onData (dart:_http/http_parser.dart:810:5)
    #109    _rootRunUnary (dart:async/zone.dart:1132:38)
    #110    _CustomZone.runUnary (dart:async/zone.dart:1029:19)
    #111    _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
    #112    _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
    #113    _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
    #114    _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:764:19)
    #115    _StreamController._add (dart:async/stream_controller.dart:640:7)
    #116    _StreamController.add (dart:async/stream_controller.dart:586:5)
    #117    _Socket._onData (dart:io-patch/socket_patch.dart:1791:41)
    #118    _rootRunUnary (dart:async/zone.dart:1132:38)
    #119    _CustomZone.runUnary (dart:async/zone.dart:1029:19)
    #120    _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
    #121    _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
    #122    _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
    #123    _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:764:19)
    #124    _StreamController._add (dart:async/stream_controller.dart:640:7)
    #125    _StreamController.add (dart:async/stream_controller.dart:586:5)
    #126    _RawSecureSocket._sendReadEvent (dart:io/secure_socket.dart:1004:19)
    #127    _rootRun (dart:async/zone.dart:1120:38)
    #128    _CustomZone.run (dart:async/zone.dart:1021:19)
    #129    _CustomZone.runGuarded (dart:async/zone.dart:923:7)
    #130    _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
    #131    _rootRun (dart:async/zone.dart:1124:13)
    #132    _CustomZone.run (dart:async/zone.dart:1021:19)
    #133    _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
    #134    Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:21:15)
    #135    _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)
    #136    _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
    #137    _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
    

    Did anyone ever got this error ?

    EDIT : following this tutorial step by step didn't solve the problem ... (https://www.youtube.com/watch?v=jkWPQHLOAEw)

    SOLVED : I finally ended up using the Mac of a friend. Maybe could work using a virtual machine as well.