Hi all. I'm trying to install `FirebaseAuth` depen...
# ios
v
Hi all. I'm trying to install
FirebaseAuth
dependency using the kotlin cocoapods plugin when targeting macOS, but I'm unable to do it. I'm creating a KMM project targeting iOS and macOS with the cocoapods plugin. I have successfully added the
FirebaseAuth
dep when targeting iOS only, but after adding macOS target, I am not able to make it work. After gradle sync, the error stack trace is very long, but here is the end:
Copy code
> Task :shared:podBuildFirebaseAuthMacosx FAILED

[...]

2023-06-15 15:42:08.926 xcodebuild[29125:2268708] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:arm64, id:00006000-0012708E0A23801E }
{ platform:macOS, arch:x86_64, id:00006000-0012708E0A23801E }
{ platform:macOS, name:Any Mac }
** BUILD FAILED **


The following build commands failed:
	Ld /Users/vincent/AndroidStudioProjects/Testuning5/shared/build/cocoapods/synthetic/OSX/build/Pods.build/Release/PromisesObjC.build/Objects-normal/x86_64/Binary/FBLPromises normal x86_64 (in target 'PromisesObjC' from project 'Pods')
(1 failure)
Do you have any idea?
To reproduce the problem: • Create a new KMM project using the KMM Plugin in Android Studio. Enable cocoapods dependency manager. • Update the shared/build.gradle
Copy code
kotlin {
    targetHierarchy.default()

    android {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }

    iosX64()
    iosArm64()
    iosSimulatorArm64()
    macosX64()             // Add this line
    macosArm64()           // Add this line

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "14.1"
        osx.deploymentTarget = "13.0"           // Add this line
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "shared"
        }
        
        pod("FirebaseAuth")           // Add this line
    }

    [...]
j
Are you using an Apple Silicon or Intel Mac?
v
I'm using an Apple Silicon (M1 Pro)
j
The error looks to be that it is building for "any Mac" and choosing between arm64 (Apple Silicon) and x86_64 (Intel). Then it's failing to link to an x86_64 binary.
Are you targeting both
macosX64
and
macosArm64
in your project?
Oh, yes. Just read your build.gradle.kts file.
Does it work if you remove the
macosX64
target?
v
When removing the
macosX64
, I'm faced with the
MPP / Gradle: Consumable configurations must have unique attributes
bug. I fixed it thanks to this workaround. But at the end, I'm still having the exact same problem with the same stack trace
j
I've run into that before as well.
Not sure why it's failing to link the x86_64 binary for the macosX64 target.
I get the same error on my Intel Mac.
v
I experimented importing another library using the same method and targeting
macosX64
and
macosArm64
like
SwiftDate
and it works well. So, I'm not sure if it's a problem related to Firebase dependencies or anything else
j
It seems to be specific to building this pod dependency. I have both macOS targets in my projects with another pod that works.
The error output is much larger than what you shared. I'm sifting through it to see if there are any more relevant details.
I wonder if these warnings are related:
Copy code
../build/cocoapods/synthetic/OSX/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.12, but the range of supported deployment target versions is 10.13 to 13.3.99. (in target 'GoogleUtilities' from project 'Pods')
../build/cocoapods/synthetic/OSX/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.12, but the range of supported deployment target versions is 10.13 to 13.3.99. (in target 'GTMSessionFetcher' from project 'Pods')
../build/cocoapods/synthetic/OSX/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.10, but the range of supported deployment target versions is 10.13 to 13.3.99. (in target 'PromisesObjC' from project 'Pods')
It might be that the project needs to be updated to support the latest version of Xcode. I'm assuming you're running Xcode 14.3.1 or similar?
You could try downgrading Xcode and seeing if it builds then.
v
Yes exactly I'm running Xcode 14.3.1
If I understand well, the problem is not related to the version I put in the cocoapods config (
osx.deploymentTarget = "13.0
) but instead it's related to the version of Xcode I'm running because Xcode doesn't support any more targets like 10.10 and 10.12 that are needed to build the Firebase dependency
I'm not sure the version of Xcode I need to download, but I will try the version 13.4.1
j
The deployment target declares the minimum OS version supported. I don't think it necessarily means a project can't successfully build on a version of Xcode that no longer supports that OS version. But if the project does use any old APIs that are now removed and no longer supported, then it would fail to build.
There's some discussion on working around the warning in cocoapods here. But I don't think that would solve it if the project is using APIs that Xcode no longer supports.
I'd try the last 13.x version of Xcode, so yeah, 13.4.1. Hopefully you won't need to try 12.x as well. Oh, the hours I've spent installing past versions of Xcode! 😅
After you finish the Xcode install, make sure to open it and install the command line tools. Then change the command line tools version in the settings.
v
Ok, you're just my hero! Thank you so much for your time and your explanations 🙏 You literally saved me hours. I tried with Xcode 14.0 and it worked 🎉
j
Nice, glad to hear. Didn't need to go back a whole version at least. Apple somehow gets away with deprecating things much faster than most others dare.