LoginSignup
8
5

More than 5 years have passed since last update.

UnityのiOSアプリにFirebaseを導入したら「iOS framework addition failed」でビルドできない問題

Posted at

概要

UnityからFirebase Realtime Databaseを使おうとした際に、iOSビルドが通らない問題が生じたためその備忘録です。

環境

・Unity2018.2.10f1
・Xcode10
・firebase_unity_sdk(5.3.0)
pod --version -> 1.5.3

再現方法

下記の手順でFirebaseを導入した際にiOSビルドが通らない問題が生じました。
UnityへFirebaseを導入する方法については、公式の説明を参照して下さい。

  1. Unityプロジェクトを作成し、ビルドプラットフォームをiOSに変更する

  2. 公式に従ってFirebaseを導入する
    今回はFirebaseDatabase.unitypackageのみインポート

  3. ビルドすると以下のようなエラーが生じる

    iOS framework addition failed due to a CocoaPods installation failure. This will will likely result in an non-functional Xcode project.
    
    After the failure, "pod repo update" was executed and succeeded. "pod install" was then attempted again, and still failed. This may be due to a broken CocoaPods installation. See: https://guides.cocoapods.org/using/troubleshooting.html for potential solutions.
    
    pod install output:
    
    Analyzing dependencies
    [!] CocoaPods could not find compatible versions for pod "GoogleUtilities/MethodSwizzler":
    In Podfile:
    Firebase/Core (= 5.6.0) was resolved to 5.6.0, which depends on
      FirebaseAnalytics (= 5.1.1) was resolved to 5.1.1, which depends on
        GoogleUtilities/MethodSwizzler (~> 5.2.0)
    
    Specs satisfying the `GoogleUtilities/MethodSwizzler (~> 5.2.0)` dependency were found, but they required a higher minimum deployment target.
    
    [33mWARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
    Consider adding the following to ~/.profile:
    
    export LANG=en_US.UTF-8
    [0m
    
    pod repo update output:
    
    ~ 以下略 ~
    

    ログにはBuild completed with a result of 'Succeeded'とあり、Xcodeプロジェクトも生成されていますが、そちらを開いて実行してもビルドは通りません。

解決方法

どうやら原因はCocoaPodのバグらしく、こちらの通りPodfileを編集して再インストールする事で無事ビルドできました。

  1. 生成されたプロジェクトフォルダに移動してPodfileを開く
  2. 下記のようにpod 'GoogleUtilities', '5.2.3'を追記する

    Podfile
    source 'https://github.com/CocoaPods/Specs.git'
    platform :ios, '12.0'
    
    target 'Unity-iPhone' do
    pod 'Firebase/Auth', '5.6.0'
    pod 'Firebase/Core', '5.6.0'
    pod 'Firebase/Database', '5.6.0'
    pod 'GoogleUtilities', '5.2.3'
    end
    ~                 
    
  3. pod install

  4. 生成されたUnity-iPhone.xcworkspaceを開いてビルド

上記手順で一度インストールしてしまえば、以降はUnityの[Build And Run]からも実行できるようになります。

ちなみに「iOS framework addition failed」で調べると、~/.profile~/.bash_profileexport LANG=en_US.UTF-8を追記する解決法が散見されますが、今回の問題はこの方法では解決しませんでした。

8
5
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
8
5