Reputation: 141
Firebase Unity SDK 1.1.1. Unity 5.5.0p4 XCode 8.2.1
When using Authentication and Database from Firebase I get the following error when building the project in XCode :
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_FIRGoogleAuthProvider", referenced from: objc-class-ref in libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
"_OBJC_CLASS_$_FIRGitHubAuthProvider", referenced from: objc-class-ref in libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
"_OBJC_CLASS_$_FIREmailPasswordAuthProvider", referenced from: objc-class-ref in libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
"_OBJC_CLASS_$_FIRFacebookAuthProvider", referenced from: objc-class-ref in libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
"_OBJC_CLASS_$_FIRApp", referenced from: objc-class-ref in libApp.a(app_ios_c76c7d869e568a9b561ea55e25a7dcc0.o)
"_OBJC_CLASS_$_FIRAuth", referenced from: objc-class-ref in libAuth.a(auth_ios_3c64a79cf1eb3f06f9309f4d8e91ee94.o)
"_OBJC_CLASS_$_FIRTwitterAuthProvider", referenced from: objc-class-ref in libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
"_OBJC_CLASS_$_FIROptions", referenced from: objc-class-ref in libApp.a(app_ios_c76c7d869e568a9b561ea55e25a7dcc0.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Do I miss something in XCode? Or have something to check in Unity?
Thanks!
Upvotes: 14
Views: 20726
Reputation: 88
i had this issue and was fixed by updating the pods installation one way was clearing the locally cached copy and reinstall it again and another way was to force the installation to be from an online source
it worth mention that the building to IOS was succeeded
Build completed with a result of 'Succeeded'
but had an error installing the pods
on the mac terminal change directory to the builded folder that should contain a Podfile
executed the following
$ pod repo remove master
$ pod install --repo-update
Rebuild the project from unity should install the pods
automatically
see Firebase pods for more information
For releases starting with 5.0.0, the source for each release is also deployed to CocoaPods master and available via standard CocoaPods Podfile syntax.
These instructions can be used to access the Firebase repo at other branches, tags, or commits.
See the Podfile Syntax Reference for instructions and options about overriding pod source locations.
Step-by-step Source Pod Installation Instructions
For iOS, copy a subset of the following lines to your Podfile
:
pod 'Firebase' # To enable Firebase module, with `@import Firebase` support
pod 'FirebaseCore', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0'
pod 'FirebaseAuth', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0'
pod 'FirebaseDatabase', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0'
pod 'FirebaseFirestore', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0'
pod 'FirebaseFunctions', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0'
pod 'FirebaseMessaging', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0'
pod 'FirebaseStorage', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0'
For macOS and tvOS, copy a subset of the following:
pod 'FirebaseCore', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0'
pod 'FirebaseAuth', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0'
pod 'FirebaseDatabase', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0'
pod 'FirebaseStorage', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0'
1- Make sure you have at least CocoaPods version 1.4.0 - pod --version.
2- Delete pods for any components you don't need, except FirebaseCore must always be included.
3- Update the tags to the latest Firebase release. See the release notes
4- Run pod update.
Upvotes: 0
Reputation: 406
I had the same problem, after spend couple of hours i got the main problem.
It was the podfile library's defined specific version.
target 'Unity-iPhone' do
pod 'Firebase/Auth', '4.10.0'
pod 'Firebase/Core', '4.10.0'
end
When unity build iOS project's podfile they define their latest library version. But when from xcode/terminal try to update pod library from GIT and the specific version is not available then its failed to update and showing this error.
Solution is simple just don't need to define the specific version. pod will update the GIT's latest version.
target 'Unity-iPhone' do
pod 'Firebase/Auth'
pod 'Firebase/Core'
end
Upvotes: 1
Reputation: 31
Building Unity app with Firebase framework locally with Xcode:
It is all about the iOS SDK version. This answer have part of the solution: https://stackoverflow.com/a/41908040/8063631
Working on Mac environment.
When build in Unity to iOS. Be sure checked before: Assets -> iOS Resolver -> Setting
Build to iOS and open .workspace file.
Then go to Pods -> Podfile and add the past release version (3.7.0), because the 4.0.0 launch that error.
target 'Unity-iPhone' do
pod 'Firebase/Auth'
pod 'Firebase/Core'
end
by (for example...)
target 'Unity-iPhone' do
pod 'Firebase/Auth', '3.7.0'
pod 'Firebase/Core', '3.7.0'
end
Close xCode IDE to avoid conflicts, then install Cocoapods if you don't have it yet (https://guides.cocoapods.org/using/getting-started.html):
Check with:
pod --version
Install with:
sudo gem install cocoapods
Go to your project folder by running Terminal and type:
pod install
It will remove the current versión and it replace it by the 3.7.0
Open xCode and press Product -> Clean and Product -> Build
Upvotes: 1
Reputation: 888
First, thanks to all for sharing your (hard) work !
A lot has been said on the subject, but it took me a lot of time and a lot of trial and error to gather all the pieces on both SO & Unity forums, so I will just post the solution that I finally worked out, which finally solved all issues for me, using unity cloud build/Unity 5.6.0f3/Xcode 8.0, the project using only firebase analytics package
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's crazy that firebase unity sdk is requiring such hacks to work (UCB is an absolute requirement for us and I guess for most multiplatform mobile developers) and I hope all those workarounds will soon be useless, but judging that all those issues are here from the beginning of official firebase Unity support, I wouldn't count too much on it
Upvotes: 5
Reputation: 41
I just figure it out , just use older version in your pod file created by unity to be like this
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: //
Don't forgot to set the Enable Modules (c and Objective-c) to yes in building setting for (Google-Mobile-Ads-SDK)
then open folder from terminal and run: ->pod install to update pods
:)
Upvotes: 2
Reputation: 71
I spent a couple of days trying to figure out the errors from building with Unity Cloud Build vs building locally. Hopefully this can help someone else!
This just worked as long as you have CocoaPods installed. An error will appear in the Unity console after building for iOS if CocoaPods is not installed. Other than that, the instructions provided by Firebase worked fine with Unity 5.6 and Xcode 8.3.
CocoaPods is not available on UCB but Firebase has a non-CocoaPods alternative: https://firebase.google.com/docs/ios/setup#frameworks
Add Frameworks Manually
The instructions are assuming a native iOS build but you can simply drag the frameworks you need into Assets/Plugins/iOS/Firebase instead of into an Xcode project. Unity will add those frameworks to the Xcode project on build.
Add Linker Flag
You will need to manually add -ObjC
into Other Link Flags. For some reason it showed up in my local Xcode project but not when UCB made the build. Create a post process script much like maros mentioned: https://forum.unity3d.com/threads/problem-building-ios-app-with-cloud-build-using-google-analytics.390803/#post-2549911
You will need to add -ObjC
like this:
proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
If you do not add this part, UCB may still create a build but the game will crash immediately after trying to create FirebaseAuth as it will reference an extension/category method that was not included due to the missing -ObjC
flag.
Add Other Required Frameworks and Libraries
Depending on which Firebase features you are using, you may need different additional frameworks or libs. For example I had used FirebaseDatabase and while the docs did not mention this, Xcode complained about a linker error that required me to add libicucore.tbd
.
The best way I could think to solve this was uninstall CocoaPods locally and then have Unity create the Xcode project so that I could get a more accurate representation of what UCB would experience. This part may take some trial and error as well as Googling to figure out which framework or lib the linker error is referring to. Just try to build the Xcode project locally and you will get the 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 did not move the GoogleServices-Info.plist into the Xcode project. There must be some other script that is not running on UCB that does run locally. In the post process script where you add the linker flag and frameworks, you can also move the GoogleServices-Info.plist into the Xcode project directory and then add it to the bundle.
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 build:
string guid = proj.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist");
proj.AddFileToBuild(target, guid);
And that should be it. I will update if I run into any other issues as I add more Firebase features. Currently I am using Auth, Database, and Analytics.
Upvotes: 6
Reputation: 432
CocoaPods
CocoaPods is a dependency manager for iOS/macOS projects. It is used for installing external frameworks/libraries to your project.
Building Unity app with Firebase framework locally with Xcode:
You need to have cocoapods installed on your system: https://guides.cocoapods.org/using/getting-started.html#toc_3
Building Unity app with Firebase framework on Unity Build Cloud:
For the users who experience this issue on Unity Build Cloud server.
According to this forum thread: https://forum.unity3d.com/threads/build-failed-cocoapods.421286/ supporting cocoapods is not supported. (and probably not even scheduled for development).
Cocoapods are responsible for having all referenced libraries for your iOS project setup in your Xcode project. As they are not supported on Unity Build Cloud, you need to do it manually.
make sure you have installed cocoapods on your macOS system: https://guides.cocoapods.org/using/getting-started.html#toc_3
build your Unity app locally (don't trigger the build on the cloud). The build exports an Xcode project (which should be runnable). This Xcode project contains libraries (Frameworks) you need to add to the Unity project.
move all the *.framework folders from EXPORTED_XCODE_PROJECT/Frameworks to YOUR_UNITY_PROJECT/Assets/Plugins/iOS e.g.: FirebaseAnalytics.framework, FirebaseCore.framework
Firebase requires iOS sqlite framework to be also included in the project. For that use this solution: https://forum.unity3d.com/threads/problem-building-ios-app-with-cloud-build-using-google-analytics.390803/#post-2549911 In the class PostBuildProcessor modify the method ProcessPostBuild,
// 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 the Unity project and by now the iOS Unity Build Cloud should work
Upvotes: 0
Reputation: 201
I had the same problem, just fixed it.
Find the Podfile file and open it in a text editor. remove
, :integrate_targets => false
in the second line so it says: install! 'cocoapods'
Then add a new line after platform: ios...
use_frameworks!
Then open a terminal screen and go to the directory of this project. Type 'pod install' and enter. If everything goes well a workspace file is created and a message appears that you should open the workspace in Xcode in stead of the project. So close the project in xcode and open the projectname.xcworkspace file. Now Xcode will open the workspace and you will be able to run the project. You may have to adjust your Deployment Target to 8.0. Hope this works for you
Upvotes: 4