Firebase Xcode command line error using Firebase Unity SDK

Firebase Unity SDK 1.1.1. Unity 5.5.0p4 Xcode 8.2.1

When using authentication and a database from Firebase, I get the following error when creating a project in Xcode:

Undefined symbols for arm64 architecture:
"_OBJC_CLASS _ $ _ FIRGoogleAuthProvider" referenced: objc-class-ref in libAuth.a (credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
"_OBJC_CLASS _ $ _ FIRGitHubAuthProvider" referenced by: objc-class-ref in libAuth.a (credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
"_OBJC_CLASS _ $ _ FIREmailPasswordAuthProvider" referenced by: objc-class-ref in libAuth.a (credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
Msgstr "". objc-class-ref in libAuth.a (credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
"_OBJC_CLASS _ $ _ FIRApp" referenced by: objc-class-ref in libApp.a (app_ios_c76c7d869e568a9b561ea55e25a7dcc0.o)
"_OBJC_CLASS _ $ _ FIRAuth" referenced by: objc-class-ref in libAuth.a (auth_ios_3c64a79cf1eb3f06f9309f4d8e91ee94.o)
Msgstr "". objc-class-ref in libAuth.a (credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
"_OBJC_CLASS _ $ _ FIROptions" referenced: objc-class-ref in libApp.a (app_ios_c76c7d869e568a9b561ea55e25a7dcc0.o) ld: character (s) not found for arm64 architecture clang: error: linker command failed with exit code 1 (( use -v to call the call)

Am I missing something in Xcode? Or check something in Unity?

Thanks!

+6
source share
6 answers

I spent a couple of days trying to understand the errors associated with building Unity Cloud Build and building locally. Hope this helps someone else!

Create locally

It just worked while you had CocoaPods installed. The error error will appear in the Unity console after creation for iOS if CocoaPods is not installed. In addition, Firebase instructions worked great with Unity 5.6 and Xcode 8.3.

Create with Unity Cloud Build

CocoaPods is not available in UCB, but Firebase has an alternative other than CocoaPods: https://firebase.google.com/docs/ios/setup#frameworks

Add frames manually

The instructions assume an inbuilt build of iOS, but you can just drag and drop the required frameworks into Assets / Plugins / iOS / Firebase, and not into the Xcode project. Unity will add this framework to the Xcode project during assembly.

Add Linker Flag

You will need to manually add -ObjC to other link flags. For some reason, it appeared in my local Xcode project, but not when UCB created the assembly. Create a mail process script as mentioned in maros: https://forum.unity3d.com/threads/problem-building-ios-app-with-cloud-build-using-google-analytics.390803/#post-2549911

You need to add -ObjC as follows:

proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");

If you do not add this part, UCB can still create the assembly, but after the FirebaseAuth game crashes, it will start to crash, because it refers to an extension / category method that was not enabled due to the missing -ObjC flag.

Add other required structures and libraries

Depending on which Firebase features you use, you may need various additional frameworks or libraries. For example, I used FirebaseDatabase, and while the docs did not mention it, Xcode complained about a linker error that required me to add libicucore.tbd .

The best way to solve this problem is to uninstall CocoaPods locally and then create a Unity Xcode project so that I can get a more accurate idea of ​​what UCB will experience. This part may take some trial and error, as well as Google, to find out which structure or lib the link to the linker error refers to. Just try creating the Xcode project locally and you will get linker errors, if any.

I added:

 List<string> frameworks = new List<string>() { "AdSupport.framework", "CoreData.framework", "SystemConfiguration.framework", "libz.dylib", "libsqlite3.dylib", "libicucore.tbd" }; 

Manually move GoogleServices-Info.plist

Another oddity is that UCB has not moved GoogleServices-Info.plist to an Xcode project. There should be another script that does not work on UCB that runs locally. In the mail process script, where you add the linker flag and frameworks, you can also move GoogleServices-Info.plist to the Xcode project directory and then add it to the package.

First move the file:

 if (!File.Exists(path + "/GoogleService-Info.plist")) { FileUtil.CopyFileOrDirectory ("GoogleService-Info.plist", path + "/GoogleService-Info.plist"); } 

Then add it to the assembly:

 string guid = proj.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist"); proj.AddFileToBuild(target, guid); 

And that should be so. I will be updating if I encounter any other problems as I add more features to Firebase. I am currently using Auth, Database and Analytics.

+4
source

Firstly, thank you all for sharing your (hard) work!

Much has been said about this, but it took me a lot of time and a lot of trial and error to collect all the fragments on both SO and Unity, so I will simply publish the solution that I finally developed, and finally solved all the problems for me using a single cloud build / Unity 5.6.0f3 / Xcode 8.0, a project using only the firebase analytics package

SOLUTION FOR UNITY CLOUD BUILD

  • completely disconnect cocoapods from Unity> Assets> Resolver Services Services> Resolver iOS> Settings (uncheck "Generate subfile" and "Automatically install Cocoapod tools in the editor", select "No - do not integrate Cocoapods")
  • put GoogleServices-Info.plist in the Unity Assets folder
  • PostBuildProcessor Method:

 private static void ProcessPostBuild (BuildTarget buildTarget, string path) { // Only perform these steps for iOS builds #if UNITY_IOS Debug.Log ("[UNITY_IOS] ProcessPostBuild - Adding Google Analytics frameworks."); // Go get pbxproj file string projPath = path + "/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); // This is the Xcode target in the generated project string target = proj.TargetGuidByName("Unity-iPhone"); proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC"); proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-v"); proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO"); if (!File.Exists(path + "/GoogleService-Info.plist")) { FileUtil.CopyFileOrDirectory("Assets/GoogleService-Info.plist", path + "/GoogleService-Info.plist"); } string guid = proj.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist"); proj.AddFileToBuild(target, guid); // List of frameworks that will be added to project List<string> frameworks = new List<string>() { "AddressBook.framework", "AdSupport.framework", "CoreData.framework", "SystemConfiguration.framework", }; // Add each by name frameworks.ForEach((framework) => { proj.AddFrameworkToProject(target, framework, false); }); // List of frameworks that will be added to project List<string> usrLibFrameworks = new List<string>() { "libsqlite3.tbd", "libz.tbd", "libicucore.tbd", }; // Add each by name usrLibFrameworks.ForEach((framework) => { proj.AddFileToBuild(target, proj.AddFile("usr/lib/"+ framework, "Frameworks/" + framework, PBXSourceTree.Sdk)); }); // Write PBXProject object back to the file proj.WriteToFile (projPath); #endif } 

PS It is vague that unity in firebase sdk requires such hacks to work (UCB is an absolute requirement for us, and I think for most mobile platform developers), and I hope that all these workarounds will be useless soon, but judging by To all, all these problems have been here from the very beginning of the official support of Firebase Unity, I would not count too much on it

+4
source

I had the same problem, just fixed.

Locate the subfile file and open it in a text editor. remove

,: integrate_targets => false

in the second line, so he says: install! 'cocoapods'

Then add a new line after the platform: ios ...

use_frameworks!

Then open the terminal screen and go to the directory of this project. Type "pod install" and type. If everything goes well, a workspace file is created and a message appears stating that you should open the workspace in Xcode instead of the project. So close the project in xcode and open the projectname.xcworkspace file. Now Xcode will open the workspace and you can start the project. You may need to set your deployment target to 8.0. Hope this works for you.

+2
source

I just understand, just use the older version in your unity created pod file to be like that

target 'Unity-iPhone' do pod 'Firebase / Analytics',' 3.17.0 'pod' Firebase / Auth ',' 3.17.0 'pod' Firebase / Core ',' 3.17.0 'pod' Google-Mobile-Ads -SDK ',' 7.13 'end

/// Note: //

Remember to set the Allow Modules (c and Objective-c) parameter to yes in the build configuration for (Google-Mobile-Ads-SDK)

then open the folder from the terminal and run: -> pod install to update the modules

:)

+2
source

CocoaPods

CocoaPods is a dependency manager for iOS / macOS projects. It is used to install external frameworks / libraries in your project.


Creating a Unity application with a Firebase database locally with Xcode :

Cocoapods must be installed on your system: https://guides.cocoapods.org/using/getting-started.html#toc_3


Creating a Unity application with Firebase infrastructure in Cloudity Cloud:

For users who experience this issue on the Unity Build Cloud server.

Depending on the topic of this forum: https://forum.unity3d.com/threads/build-failed-cocoapods.421286/ cocoapods support is not supported. (and probably not even planned for development).

Cocoapods are responsible for ensuring that all library links for your iOS project are in your Xcode project. Since they are not supported on the Unity Build Cloud, you need to do this manually.

  • make sure you have installed cocoapods on your macOS system: https://guides.cocoapods.org/using/getting-started.html#toc_3

  • Build a Unity application locally (don't run builds in the cloud). The string exports the Xcode project (which should be started). This Xcode project contains the libraries that need to be added to the Unity project.

    • move all * .framework folders from EXPORTED_XCODE_PROJECT / Frameworks to YOUR_UNITY_PROJECT / Assets / Plugins / iOS For example: FirebaseAnalytics.framework, FirebaseCore.framework

    • Firebase requires the iOS sqlite framework to be included in the project as well. To do this, use this solution: https://forum.unity3d.com/threads/problem-building-ios-app-with-cloud-build-using-google-analytics.390803/#post-2549911 In the PostBuildProcessor class, change the ProcessPostBuild method ,

      // ObjC - needed for Firebase proj.AddBuildProperty (target, "OTHER_LDFLAGS", "-ObjC");

      List<string> frameworks = new List<string>() { "AdSupport.framework", "CoreData.framework", "SystemConfiguration.framework", "libz.dylib", "libsqlite3.dylib", "libApp.a", "libAnalytics.a" };

Save your Unity project, and now iOS Unity Build Cloud should work

0
source

Create a Unity application with a Firebase database locally using Xcode:

This is all about the iOS SDK version. This answer has part of the solution: fooobar.com/questions/1014495 / ...

Work in the environment of Mac.

When created in Unity iOS. Be sure to check: Assets β†’ iOS Resolver β†’ Settings

  • Cocoapods Integration
    • Xcode workspace - Add cocoa pods to your Xcode workspace
  • Automatically install Cocoapods tools in the editor

Create iOS and open the .workspace file.

Then go to Pods -> Podfile and add the previous version (3.7.0), because 4.0.0 triggers this error.

 target 'Unity-iPhone' do pod 'Firebase/Auth' pod 'Firebase/Core' end 

(eg...)

 target 'Unity-iPhone' do pod 'Firebase/Auth', '3.7.0' pod 'Firebase/Core', '3.7.0' end 

Close the xCode IDE to avoid conflicts, then install Cocoapods if you don't already have one ( https://guides.cocoapods.org/using/getting-started.html ):

Note:

 pod --version 

Install with:

 sudo gem install cocoapods 

Go to the project folder by launching the terminal and enter:

 pod install 

It will delete the current versiΓ³n and replace it with 3.7.0

Open xCode and click Product β†’ Clean and Product β†’ Build

0
source

Source: https://habr.com/ru/post/1014495/


All Articles