0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Flutter XCode12+flutter_soundのエラーを解消

0
Last updated at Posted at 2021-09-19

こんにちは。Flutter赤ん坊です。

flutter_soundというパッケージがあるのですが、私の環境では動かせませんでした。周りを実装しながら時々flutter_soundを有効化するために奮闘していたのですが、先程ついに出来ましたので、その方法をご紹介します。

環境

XCode12.5.1

Flutter 2.5.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 4cc385b4b8 (11 days ago) • 2021-09-07 23:01:49 -0700
Engine • revision f0826da7ef
Tools • Dart 2.14.0

再現

サンプルプログラムを実行

まずはコマンドラインから新規プロジェクトを作成します。

flutter create test

これでtestディレクトリが作られました。該当ディレクトリに移動します。

cd test

ここはもうプロジェクト内です。例の数字が増えていくサンプルプログラムが入っています。まずiOSシミュレータ(iPhone)を起動しておいてから、次のようにサンプルプログラムを起動します。

flutter run --device-id iphone

プログラムが正常に起動したことと思います。プロンプト内で半角の「q」を押すことで終了できます。なお環境によっては起動しないかも知れませんが、そこまでは私にも分かりませんので、ご了承ください。

スクリーンショット 2021-09-19 10.49.37.png

問題のflutter_soundをインストール

ここでflutter_soundパッケージをインストールします。

flutter pub add flutter_sound

もう一度プログラムを起動します。

flutter run --device-id iphone

すると、以下のようなエラーが出ました。

Error output from CocoaPods:


    [!] Automatically assigning platform `iOS` with version `9.0` on target
    `Runner` because no platform was specified. Please specify a platform for
    this target in your Podfile. See
    `https://guides.cocoapods.org/syntax/podfile.html#platform`.

iOSを特定しろと言うことのようです。

対処

iOSのバージョンを指定

まずは指示通り、iOSのバージョンを指定します。test/ios/podfileを開くと、次のようになっています。

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

二行目をコメントアウトし、バージョンを9から10に上げます。ちなみに9だと別のエラーが出てしまいます。

# Uncomment this line to define a global platform for your project
platform :ios, '10.0'

もう一度コンパイルしてみます。

flutter run --device-id iphone

すると、以下のエラーが出ました。

building for iOS Simulator, but linking in object file built for iOS,
file '/Users/user/test/ios/Pods/mobile-ffmpeg-audio/lame.framework/lame'
for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)

arm64です。

arm64を除外する

arm64は実機のCPUですが、シミュレータでは使われていません。ですので、これを使用しないように設定します。XCode11以前はこのエラーは無く、12から対応が必要になったようです。

まずXCodeで、test/ios/Runner.xcworkspaceを開きます。そこで以下のように、Excluded Architecturesにarm64を追加していきます。

スクリーンショット 2021-09-19 11.25.56.png

赤矢印を入れ忘れたのですが、画面左端、RunnerとPodsに分かれているうち、Runnerの方です。上記はPROJECTに対する設定ですが、そのほかにTARGETSにも同様にarm64を追記します。すでに値が入っている場合は、 スペース区切りでOKと思われます。なおTARGETSの方はDebug, Profile, Releaseと分かれていますので、お好みで入れてください。

PROJECTとTARGETSの両方にarm64を追記できたら、完了です。改めてサンプルプログラムを起動すれば、きちんと動作するかと思います。

終わりに

いかがでしたでしょうか。この問題で他のこともしながら色々試しつつダラダラ3日間くらいかかりました。慣れてないもので致し方ないかも知れませんが、同じ苦労をしないよう、共有させていただきます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?