podFile to use_frameworks! Can't use the option?
Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)? Yes
What's the issue repro rate? 100%
What happened? How can we make the problem occur?
This could be a description, log/console output, etc.
If you have a downloadable sample project that reproduces the bug you're reporting, you will
likely receive a faster response on your issue.
If you use podFile like this
As soon as the app launches, it quits.
source'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target'UnityFramework' do
pod'Firebase/Analytics', '6.32.2'
pod'Firebase/Core', '6.32.2'
pod'Firebase/Crashlytics', '6.32.2'
end
If you use podFile like this
The app runs, but
Firebase.FirebaseApp.DefaultInstance;
Exception occurs when calling.
source'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target'Unity-iPhone' do
pod'Firebase/Analytics', '6.32.2'
pod'Firebase/Core', '6.32.2'
pod'Firebase/Crashlytics', '6.32.2'
end
target'UnityFramework' do
pod'Firebase/Analytics', '6.32.2'
pod'Firebase/Core', '6.32.2'
pod'Firebase/Crashlytics', '6.32.2'
end
Firebase_UseFrameworks_UnityIPhone.txt
Attach log files for the above two situations.
Hi @kairi81, I noticed in the second log file, there is this line:
idevtest 6.32.0 - [Firebase/Core][I-COR000012] Could not locate configuration file: 'GoogleService-Info.plist'.
idevtest ERROR: Unable to configure Firebase app (The default FirebaseApp instance must be configured before the defaultFirebaseApp instance can be initialized. One way to ensure that is to call [FIRApp configure]; (FirebaseApp.configure() in Swift) in the App Delegate's application:didFinishLaunchingWithOptions: (application(_:didFinishLaunchingWithOptions:) in Swift).)
Can you confirm if that file is configured correctly in your project first?
It is located in the XCode folder as shown in this picture.
And when you open the project in xcode, click on the file, it has the correct target project checked like this?

The target of the GoogleService-Info.plist file is UnityFramework.
However, even when built without using "use_frameworks!", the target is UnityFramework.

Hi @kairi81, sorry it takes a while to get back to you. I tried to repro with both Analytics testapp and Crashlytics testapp, and setup the podfile like below
`source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target 'UnityFramework' do
pod 'Firebase/Analytics', '6.32.2'
pod 'Firebase/Core', '6.32.2'
end`
Everything works fine with the testapps. Can you share the exact repro steps to help us dig deeper? Thanks!
I will attach the source code of the sample app I tested.
Only some files are attached due to upload capacity limitation.
Some unique information required at build time has been removed.
I imported Firebase_unity_sdk_6.16.1 because Unity Pakage Manger is not available due to company security policy.
I copied the podFile into the PostProcessBuild(45) sequence because the use_frameworks setting is not available in IOSResolver.
Is there any solution to this issue?
@kairi81
Sorry for the delay! We are aware of issues around use_frameworks! in general (in my own brief testing, I even had issues linking a solution) and are looking into it. I can't comment on when exactly the issue will be resolved.
If your issue is just reading GoogleService-Info.plist, you can try one thing. It looks like you have a very centralized place where you call FirebaseApp.DefaultInstance. It turns out that if you call FirebaseApp.Create with no name specified _and_ Firebase has not yet been initialized (basically don't call anything other than CheckAndFixDependenciesAsync), the firebase app that will be created will be the default app.
I'll mark this as a bug for now, but certainly feel free to let me know if that works as a temporary workaround!
--Patrick
Also see issue #902 which seems to be related. The inclusion of the Facebook SDK produces a podfile that includes the !use_frameworks directive.
@kairi81
Sorry for the delay! We are aware of issues around
use_frameworks!in general (in my own brief testing, I even had issues linking a solution) and are looking into it. I can't comment on when exactly the issue will be resolved.If your issue is just reading
GoogleService-Info.plist, you can try one thing. It looks like you have a very centralized place where you callFirebaseApp.DefaultInstance. It turns out that if you callFirebaseApp.Createwith no name specified _and_ Firebase has not yet been initialized (basically don't call anything other thanCheckAndFixDependenciesAsync), the firebase app that will be created will be the default app.I'll mark this as a bug for now, but certainly feel free to let me know if that works as a temporary workaround!
--Patrick
I didn't get a word describing how actually is possible to fix it?! Better you prepare well tested versions before releases instead of providing some workaround each time on new version. For entire time working with Firebase SDK I never saw stable release without any issue. Hate Firebase, but have to use it only because of project selected technological stack.
@DellaBitta Thanks a lot.
@cynthiajoan
Hi everyone, Does anyone know how I can initialize Firebase? I am following the steps described in the following link (https://goo.gl/ctyzm8).
But when I get to step 5, I don't know how to initialize Firebase.
How can I add the lines of code that are mentioned? I don't know which file they go into and which libraries to import.
I'm using:
Unit 2019.4.16f1
Firebase 6.16.1
Cocoapods
Note:
I am opening the
.xcworkspace from my project in Xcode 12.3
Thanks a lot.
@patm1987
When an Exception occurs in FirebaseApp.DefaultInstance
FirebaseApp.Create() was called and Instance returned normally.
However, when a Test Exception is made, the event is not caught on the dashboard.
I am testing it to build without using use_frameworks!.
This can be solved by adding GoogleService-Info.plist a resource of the main target.
I added a post build script to do it for now, until Firebase comes up with a better way of handling this...
[PostProcessBuild]
public static void OnPostProcessBuildAddFirebaseFile(BuildTarget buildTarget, string pathToBuiltProject)
{
if (buildTarget == BuildTarget.iOS)
{
// Go get pbxproj file
string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
// PBXProject class represents a project build settings file,
// here is how to read that in.
PBXProject proj = new PBXProject ();
proj.ReadFromFile (projPath);
// Copy plist from the project folder to the build folder
proj.AddFileToBuild (proj.GetUnityMainTargetGuid(), proj.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist"));
// Write PBXProject object back to the file
proj.WriteToFile (projPath);
}
}
@eladleb Thank you for providing a workaround here.
I had investigated this issue in the past few days and here are my findings.
When use_frameworks! is used in Podfile, either added manually or by Facebook SDK, there are two options to make Firebase function properly.
Unity-iPhone target in Podfile, which is usually added by Facebook SDK.target 'Unity-iPhone' do
# Empty Target. Required or the app crash due to missing library.
end
use_frameworks!
```
use_frameworks! to use_frameworks! :linkage => :static in Podfile. No additional Unity code or empty Unity-iPhone target needed. It required Cocoapods 1.9 and above.use_frameworks! :linkage => :static
```
Use option 1 if you really like to link libraries dynamically, you re-generate Xcode frequently, or you are using older version of Cocoapods.
Use option 2 for stability and performance. This will be the default solution I'm going forward to add to EDM4U as a new option in iOSResolver.
Here is what we know so far
UnityFramework target on top of Unity-iPhone target in Xcode project. More detail here. Unity-iPhone is changed to be a thin launcher to load UnityFramework.UnityFramework include all classes and libraries from Unity, including all of Firebase Unity and native C++ SDK, such as libFirebaseCppApp.a. They will be a member of UnityFramework target by default when Xcode project is generated.pod install to generate Unity-iPhone.xcworkspace.Google-Services.plist to Xcode project and add it to be a member of UnityFramework target from Unity 2019.3. (Unity-iPhone for Unity 2019.2 and below)use_framework! is required for Swift libraries. Firebase SDK currently does not require it yet.use_framework! and empty Unity-iPhone target to Podfile. I guess they do so because they switch to Swift library.use_framework! is used, libraries are linked dynamically by default unless :linkage => :static is specified.Google-Services.plist needs to be added to Unity-iPhone target to create FirebaseApp. Also, an empty Unity-iPhone target is required in Podfile or the app can crash due to missing libraries. This is really odd. Though we do not know the reason why these are required yet but this _might_ be related to UnityFramework.framework being embedded to Unity-iPhoneuse_frameworks! :linkage => :static to link libraries statically.There are still some mysteries about this issue. If you have any insight about this, feel free to share here!
I'll leave this issue open until we have a proper support for it.
Using facebook v9 also face the same crash
@Thaina
Thanks for reporting this.
I just ran some test with Facebook SDK 9.0.0, seems like https://github.com/firebase/quickstart-unity/issues/862#issuecomment-752945417 is the only working solution now. use_frameworks! :linkage => :static does not seem to work with the latest Facebook SDK.
I'll add some fixes from both EDM4U and Firebase side.
Can someone please clarify? Adding _use_frameworks! :linkage => :static_ is supposed to make Firebase 7.0.2 and Facebook 9.0.0 build?
It doesn't work for me. I continue to get this error:
Undefined symbol: _OBJC_CLASS_$_GKLocalPlayer
@andymads
It doesn't work for me. I continue to get this error:
Undefined symbol: OBJC_CLASS$_GKLocalPlayer
I think this is a different issue caused from missing framework.
Try adding GameKit.framework to your xcode prject from
Targets -> UnityFramework -> General -> Frameworks and Libraries
-> click + button and find GameKit.framework -> rebuild.
Hope this solves your problem.
@andymads
It doesn't work for me. I continue to get this error:
Undefined symbol: OBJC_CLASS$_GKLocalPlayerI think this is a different issue caused from missing framework.
Try adding GameKit.framework to your xcode prject from
Targets->UnityFramework->General->Frameworks and Libraries
-> click+button and findGameKit.framework-> rebuild.Hope this solves your problem.
Yes, thanks very much. Didn't work until I did a clean first, then build.
This can be solved by adding GoogleService-Info.plist a resource of the main target.
I added a post build script to do it for now, until Firebase comes up with a better way of handling this...[PostProcessBuild] public static void OnPostProcessBuildAddFirebaseFile(BuildTarget buildTarget, string pathToBuiltProject) { if (buildTarget == BuildTarget.iOS) { // Go get pbxproj file string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj"; // PBXProject class represents a project build settings file, // here is how to read that in. PBXProject proj = new PBXProject (); proj.ReadFromFile (projPath); // Copy plist from the project folder to the build folder proj.AddFileToBuild (proj.GetUnityMainTargetGuid(), proj.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist")); // Write PBXProject object back to the file proj.WriteToFile (projPath); } }
string googleInfoPlistGuid = proj.FindFileGuidByProjectPath("GoogleService-Info.plist");
proj.AddFileToBuild(targetGuid, googleInfoPlistGuid);
Any updates on this issue for iOS?
I'm also facing the issue with GoogleService-Info.plist added in UnityFramework instead of Unity-iPhone target like @kairi81 said in https://github.com/firebase/quickstart-unity/issues/862#issuecomment-725928638
Unity 2019.4.17f1
Firebase 7.0.2 (via UPM): Core, Analytics, RemoteConfig
Facebook SDK 9.0.0
AdMob 5.4.0
My game doesn't crash but RemoteConfig failed due to Failed to read Firebase options from the app's resources. Either make sure GoogleService-Info.plist is included in your build or specify options explicitly.
Will try the workarounds with PostProcessBuild above but it would be great to get this sorted out by Firebase.
I'm also facing the issue with
GoogleService-Info.plistadded inUnityFrameworkinstead ofUnity-iPhonetarget like @kairi81 said in #862 (comment)Unity 2019.4.17f1
Firebase 7.0.2 (via UPM): Core, Analytics, RemoteConfig
Facebook SDK 9.0.0
AdMob 5.4.0My game doesn't crash but RemoteConfig failed due to
Failed to read Firebase options from the app's resources. Either make sure GoogleService-Info.plist is included in your build or specify options explicitly.Will try the workarounds with PostProcessBuild above but it would be great to get this sorted out by Firebase.
I reported this problem and got this reply so I'm not sure that Firebase are interested in sorting it out.
_It looks like you're having issues integrating third party libraries with Firebase SDKs. Integrations like this are not covered by Firebase Support at the moment. This is currently beyond our scope of free support as it makes use of a third-party library, and I have limited expertise. I recommend to raise your question to other public communities such as GitHub or Stack Overflow where fellow developers will be able to directly provide suggestions or ideas pertaining to this topic._
@andymads
I have a patch in review to fix the issue with GoogleService-Info.plist.
Also, there are a couple of upcoming patches for EDM4U to support wider spectrum of Pod configurations.
Most helpful comment
This can be solved by adding GoogleService-Info.plist a resource of the main target.
I added a post build script to do it for now, until Firebase comes up with a better way of handling this...