
環境
- Unity
- Xcode
- Firebase SDK
- ExternalDependencyManager
Xcode上のビルドエラー
Undefined symbol: absl::lts_20220623::variant_internal::ThrowBadVariantAccess()
Undefined symbol: absl::lts_20220623::optional_internal::throw_bad_optional_access()
Linker command failed with exit code 1 (use -v to see invocation)

原因
既にgithubのissueに追加されていた。
github.com
2024/3/28時点でまだ中の人も調査中とコメントしている。
Firebaseの一連のSDKとFirebaseFirestoreInternalの特定のバージョンの組み合わせでエラーが起きてしまっているので、FirebaseFirestoreInternal側を固定してあげれば解決したとの書き込みがある。
対応
とりあえずの対応
pod 'FirebaseFirestoreInternal', '10.22.'
Podfileのどの行に追加するんだ、となると思うので追加した後の自分のPodfileも記載
source 'https://cdn.cocoapods.org/'
platform :ios, '12.0'
target 'UnityFramework' do
pod 'AppLovinSDK', '11.9.0'
pod 'Firebase/Analytics', '10.22.0'
pod 'Firebase/Auth', '10.22.0'
pod 'Firebase/Core', '10.22.0'
pod 'Firebase/Crashlytics', '10.22.0'
pod 'Firebase/Firestore', '10.22.0'
pod 'Firebase/Functions', '10.22.0'
pod 'Firebase/Messaging', '10.22.0'
pod 'Firebase/RemoteConfig', '10.22.0'
pod 'Firebase/Storage', '10.22.0'
pod 'PurchasesHybridCommon', '8.2.1'
pod 'FirebaseFirestoreInternal', '10.22.'
end
target 'Unity-iPhone' do
end
use_frameworks! :linkage => :static
post_install do |installer|
installer.generated_projects.each do |project|
project.targets.each do |target|
if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
end
end
end
end
end
この状態でPodsフォルダがある階層(Pods以下ではなく、Podsフォルダがある階層以上)に移動して、
pod install コマンドを実行。
もしエラーが出たら、Podfile.lockを削除して再度実行。
これでビルドすれば通るはず。
自動化対応
近日中にFirebase側で対応されると思うが、それまで毎回手動でPodfileを修正するのも手間なので、自動で修正されるようにしておく。
External Dependency Manager for Unity(EDM4U)が導入済みの前提。
github.com
EDM4Uではカスタムの設定ファイルを配置できる。
https://github.com/googlesamples/unity-jar-resolver?tab=readme-ov-file#config-file
- 任意の階層のEditorフォルダ以下
- **Dependencies.xml という命名のxmlファイル
があれば、EDM4U側が依存関係を記述したファイルと認識してくれる。
今回Podfileに追記した内容を自動で追加するようにするには、以下のようなファイルをEditorフォルダ以下に追加しておけばOK
CustomFirebaseDependencies.xml
xml version="1.0" encoding="utf-8"
<dependencies>
<iosPods>
<iosPod name="FirebaseFirestoreInternal" version="10.22.0"/>
</iosPods>
</dependencies>
これでビルドすれば自動でPodfileに追記されいる。
以上