brew install --HEAD libimobiledevice が通らんかったのでなんとかした


Flutterをしよう

諸事情あってFlutterを触る必要が出てきたので、まずは環境構築。
flutter doctorまでは公式サイトのGet Startedを参照していただきたい。
んで、PATHを通してこれっぽいのが出てくればOK。

% flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.3 18D109, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
    ✗ libimobiledevice and ideviceinstaller are not installed. To install with
      Brew, run:
        brew update
        brew install --HEAD usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
[!] Android Studio (version 3.3)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code (version 1.31.1)
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
    ! No devices available

! Doctor found issues in 4 categories.

中間のあたりでlibimobiledeviceなるパッケージを突っ込めと言われるので指示に従う。

どうしてこうなった

% brew install --HEAD libimobiledevice
==> Cloning https://git.libimobiledevice.org/libimobiledevice.git
Cloning into '/Users/reno.89m/Library/Caches/Homebrew/libimobiledevice--git'...
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
Error: An exception occurred within a child process:
  DownloadError: Failed to download resource "libimobiledevice"
Failure while executing; `git clone --branch master https://git.libimobiledevice.org/libimobiledevice.git /Users/reno.89m/Library/Caches/Homebrew/libimobiledevice--git` exited with 128. Here's the output:
Cloning into '/Users/reno.89m/Library/Caches/Homebrew/libimobiledevice--git'...
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

????????

(;´Д`)

解決方法

githubのリポジトリがあったので、Cloneしてセルフビルドする。

% git clone https://github.com/libimobiledevice/libimobiledevice.git
Cloning into 'libimobiledevice'...
remote: Enumerating objects: 27, done.
remote: Counting objects: 100% (27/27), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 8261 (delta 14), reused 18 (delta 11), pack-reused 8234
Receiving objects: 100% (8261/8261), 2.56 MiB | 2.01 MiB/s, done.
Resolving deltas: 100% (5794/5794), done.

そしたらREADME.md通りにシェルスクリプトを叩く

% cd libimobiledevice
% ./autogen.sh
~~~~~~省略
checking for openssl >= 0.9.8... no
checking for gnutls >= 2.2.0... no
configure: error: Package requirements (gnutls >= 2.2.0) were not met:

No package 'gnutls' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables libgnutls_CFLAGS
and libgnutls_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

なんで💢
と思ったけどこれに関してはすでに解決方法がネットに出てた(https://cloud.tencent.com/developer/article/1394906)

解決方法その②

さっきのリンクの通りにgnutlsとlibgcryptを突っ込んだ後、--disable-opensslオプションを追加してスクリプトを叩く。

% brew install gnutls
% brew install libgcrypt

% ./autogen.sh --disable-openssl
% make
% make install

インストールできたのでもう一度flutter doctorを確認してみる。(libimobiledevice以外は導入に成功している場合)

% flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.3 18D109, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[!] Android Studio (version 3.3)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code (version 1.31.1)
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
    ! No devices available

! Doctor found issues in 3 categories.

iOStoolchain解決🎉
あとは普通にAndroid StudioとVSCodeの設定を済ませればOK
みんなもLet's Flutter😉