Facebook iOS SDK 18.0.0 버전을 추가하면서 소스코드가 많이 늘어났는지 Xcode에서 위와 같은 빌드 에러가 뜬다. 결국 소스코드 양을 줄여야 된다는 말인데.. 전부터 느끼는 거지만 Facebook SDK는 쓸데없이 다 때려박아놔서 소스양이 많아서 이런저런 문제를 계속 만들어 내는 것 같다.
그런데 Unity 2021.3.41f1에서도 여전히 빌드에러가 나서 에러 메시지를 확인해보니 아래와 같은 부분이 있다.
stderr[
FAILURE: Build completed with3 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':launcher:checkReleaseDuplicateClasses'.
> Could not resolve all files for configuration ':launcher:releaseRuntimeClasspath'.
> Could not find com.google.firebase:firebase-analytics-unity:12.1.0.
Searched in the following locations:
- https://maven.google.com/com/google/firebase/firebase-analytics-unity/12.1.0/firebase-analytics-unity-12.1.0.pom
- file:////Assets/GeneratedLocalRepo/Firebase/m2repository/com/google/firebase/firebase-analytics-unity/12.1.0/firebase-analytics-unity-12.1.0.pom
file:////Assets/GeneratedLocalRepo/Firebase/m2repository/... 부분의 앞에 프로젝트의 Path가 있어야 되는데 제대로 들어가지 않고 있는 것 같다.
해당 부분은 settingsTemplate.gradle에서 절대경로를 넣으면 임시로 해결이 된다고 하는데,
Unity 2021에서는 Custom SettingsTemplate Gradle 파일 활성화 옵션이 없지만 파일 자체를 Plugins/Android 폴더에 넣으면 제대로 작동한다.
settingsTemplate.gradle 파일 안에 **DIR_UNITYPROJECT**를 넣으면 제대로 작동해야되는데 작동을 하지 않아서 IPostGenerateGradleAndroidProject를 사용해서 Path를 절대경로로 교체하는 방식 제안이 있어서 적용해 봤지만 제대로 여전히 빌드가 제대로 되지 않는다.
1) Unity 2021.3.41f1에서 많이 바껴서 baseProjectTemplate.gradle / gradleTemplate.properties / mainTemplate.gradle 등 gradle 관련 파일들을 삭제 후 새로 생성하자.
(특히 gradle 버전이 많이 올라가서 baseProjectTemplate.gradle은 새로 생성해줄 필요가 있다.)
2) Android Min API24 / Target API34로 변경
(Min API 23에서는 아래와 같은 에러 발생함)
stderr[
Note: Some input files use oroverride a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
ERROR:D8: com.android.tools.r8.kotlin.H
ERROR:D8: com.android.tools.r8.kotlin.H
ERROR:D8: com.android.tools.r8.kotlin.H
3) 아래 settingsTemplate.gradle 파일을 ../Assets/Plugins/Android 폴더에 추가
I used thepostin the 'EDIT 2' to come up with a decent solution. I don't know if it will work 100% of the time and I would love for someone to correct me if I have chosen a poor solution. This should allow me to run code before the build starts, and if the build fails or succeeds without changing the unity build pipeline.
classCustomBuildPipeline : MonoBehaviour, IPreprocessBuildWithReport, IPostprocessBuildWithReport
{
publicint callbackOrder => 0;
// CALLED BEFORE THE BUILDpublicvoidOnPreprocessBuild(BuildReport report)
{
// Start listening for errors when build starts
Application.logMessageReceived += OnBuildError;
}
// CALLED DURING BUILD TO CHECK FOR ERRORSprivatevoidOnBuildError(string condition, string stacktrace, LogType type)
{
if (type == LogType.Error)
{
// FAILED TO BUILD, STOP LISTENING FOR ERRORS
Application.logMessageReceived -= OnBuildError;
}
}
// CALLED AFTER THE BUILDpublicvoidOnPostprocessBuild(BuildReport report)
{
// IF BUILD FINISHED AND SUCCEEDED, STOP LOOKING FOR ERRORS
Application.logMessageReceived -= OnBuildError;
}
}
pod install output:
Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "GTMSessionFetcher/Core":
In Podfile:
Firebase/Auth (= 10.6.0) was resolved to 10.6.0, which depends onFirebaseAuth (~> 10.6.0) was resolved to 10.6.0, which depends on
GTMSessionFetcher/Core (< 4.0, >= 2.1)
GoogleSignIn (= 6.0.2) was resolved to 6.0.2, which depends onGTMAppAuth (~> 1.0) was resolved to 1.3.1, which depends on
GTMSessionFetcher/Core (< 3.0, >= 1.5)
GoogleSignIn (= 6.0.2) was resolved to 6.0.2, which depends on
GTMSessionFetcher/Core (~> 1.1)
Firebase 10.6.0이 업데이트 돼서 다시 한 번 iOS 빌드를 시도해 봤는데 여전히 에러가 난다.
UnayOzan commented on Feb 5
Fixed this error with changing the version in"GoogleSignIn.podspec.json" file.
Firebase/Auth (= 10.4.0) was resolved to 10.4.0, which depends onFirebaseAuth (~> 10.4.0) was resolved to 10.4.0, which depends on
GTMSessionFetcher/Core (< 4.0, >= 2.1)
GoogleSignIn (~> **5.0.2**) was resolved to **5.0.2**, which depends on
GTMSessionFetcher/Core (~> **1.1**)
I found the file in {user}.cocoapods/repos/cocoapods/Specs and then just search for"GoogleSignIn.podspec.json".
Find the folder with the same version with the error, in my case5.0.2.
And then change its dependencies with the version 7.0.0or something that works with the other packages.
In my project the solution was this;
"dependencies": {
"AppAuth": [
"~> 1.5"
],
"GTMAppAuth": [
">= 1.3",
"< 3.0"
],
"GTMSessionFetcher/Core": [
">= 1.1",
"< 4.0"
]
After that I exited Xcode, deintagrated pods, cleaned cache and installed it again.
Everything works fine now.