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.