Firebase Unity iOS Problems

半世苍凉 提交于 2019-12-10 21:19:50

问题


I have setup Firebase successfully under my Android build in Unity, but am really battling getting it working in my iOS build.

Unity Firebase project was setup and looks fine:

I have followed all the steps on: https://firebase.google.com/docs/unity/setup

I have installed CocoaPods:

skywalker:sl leonard$ pod --version
1.2.0

Here is the top level generated iOS project:

skywalker:sl leonard$ ls
Classes                    Libraries
Data                    MapFileParser
Info.plist                MapFileParser.sh
LaunchScreen-iPad.png            Unity-iPhone
LaunchScreen-iPad.xib            Unity-iPhone Tests
LaunchScreen-iPhone.xib            Unity-iPhone.xcodeproj
LaunchScreen-iPhoneLandscape.png    UnityData.xcassets
LaunchScreen-iPhonePortrait.png        build

I don't see the GoogleService-Info.plist file being added and also expected a Podfile (but I'm just guessing that it would generate one).

The project generates errors and trying to manually resolve them just creates more errors.

Here is the project right after the first build:

Trying to resolve this modules disabled error:

Then after building this is what I see:

I then tried adding the GoogleMobileAds.framework iOS framework:

After running again I get these errors:

After reading online about these errors there's a lot of mention around CocoaPods, but running pod init just created a blank workspace and didn't resolve my issue.


回答1:


I had a similar problem and was able to get my app building in XCode by going to the App's Xcode directory and running "pod init". This created the podfile. I then edited that file with SublimeText (apparently some editors cause problems editing this file, I'm not fully clear on why) and adding the pods I needed. My podfile ended up looking like this:

platform :ios, '7.0'target 
'Unity-iPhone' do
pod 'Firebase/Analytics', '~> 3.10'
pod 'Firebase/Auth', '~> 3.10'
pod 'Firebase/Core', '~> 3.10'
pod 'Firebase/Messaging', '~> 3.10'
pod 'Firebase/RemoteConfig', '~> 3.10'
end

I then ran "pod install" in the same directory and that created the .xcworkspace file (this took some time, as it installed several prerequisites). Opening the .xcworkspace file, I was then able to successfully build and run my app. I've run into additional run time issues (which is why I was on StackOverflow today), but that at least got the project compiling.

You will need a copy of the GoogleServices-info.plist file into the app's xcode directory. Unity copied it automatically for me, but YMMV.

Hope this helps.




回答2:


Could you link the contents of you podfile? If you just added

pod 'Firebase/Core'

then that might not be enough: https://firebase.google.com/docs/ios/setup#available_pods

pod 'Firebase/Core' Prerequisite libraries and Analytics
pod 'Firebase/AdMob'    AdMob
pod 'Firebase/Messaging'    Cloud Messaging / Notifications
pod 'Firebase/Database' Realtime Database
pod 'Firebase/Invites'  Invites
pod 'Firebase/DynamicLinks' Dynamic Links
pod 'Firebase/Crash'    Crash Reporting
pod 'Firebase/RemoteConfig' Remote Config
pod 'Firebase/Auth' Authentication
pod 'Firebase/Storage'  Storage

You might have to add all pods for the features you are using.

Disclaimer: I'm currently trying to get my build to run on ios as well (works like a charm on android). Just realized this issue myself, I also only included pod 'Firebase/Core' before.



来源:https://stackoverflow.com/questions/42108793/firebase-unity-ios-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!