https://kotlinlang.org logo
r

rocketraman

10/20/2020, 6:49 AM
I use the cocoapods integration with a KMM project with a
Firebase/Auth
dependency. I keep getting the dreaded code 65 error:
Executing of 'xcodebuild -project Pods.xcodeproj -scheme Firebase -sdk iphonesimulator -configuration Release' failed with code 65 and message
. Anyone have this working?
e

Even André Fiskvik

10/20/2020, 6:52 AM
I haven't tried it myself, but I know a co-worker had similar issues and gave up (for now) on adding Cocoapod dependencies in our shared codebase.
a

Artyom Degtyarev [JB]

10/20/2020, 7:05 AM
Try specifying the pod name as
pod(FirebaseAuth)
, there was a big thread on it recently. Also, I found a similar error in this issue, but not sure if it’s related.
r

rocketraman

10/20/2020, 7:21 AM
I've tried that and other variations, and it does not solve the problem. It changes the error to:
Executing of 'xcodebuild -project Pods.xcodeproj -scheme FirebaseAuth -sdk iphonesimulator -configuration Release' failed with code 65 and message
a

Artyom Degtyarev [JB]

10/20/2020, 7:28 AM
Is it possible to specify, which Gradle task finishes with that?
r

rocketraman

10/20/2020, 7:35 AM
Yes, it was
podBuildDependenciesIosX64
Running that
xcodebuild
command directly in the
iosApp/Pods
directory works fine.
So its something to do with the way Gradle is calling it... perhaps it is executing in the wrong directory? The code 65 error is completely useless.
The weird thing is, this was working at some point before. I have no idea what broke it.
i

ilya.matveev

10/20/2020, 7:51 AM
@rocketraman Could you please run the build with
--scan --info
flags and send us the link to the buildscan?
r

rocketraman

10/20/2020, 7:55 AM
I'm just bisecting my source, and its possible Gradle 6.7 is the culprit. I'm building a version of the code with 6.5.1 and it worked. I'm now running the latest code with 6.5.1.
Nope, failed with 6.5.1 too
i

ilya.matveev

10/20/2020, 8:04 AM
This build has the default log level which is insufficient to determine how exactly the CocoaPods plugin started
xcodebuild
. Could you rerun the build with
--info
(or even
--debug
) flag to get more detailed logging?
r

rocketraman

10/20/2020, 8:05 AM
I ran it with
--info
... let me try again
I'm getting the debug output locally but the build scan does not contain it
i

ilya.matveev

10/20/2020, 8:08 AM
It looks strange. Could you post the log here then?
r

rocketraman

10/20/2020, 8:16 AM
Sent via DM.
The only thing that works is removing
FirebaseAuth
from the cocoapod dependencies in gradle. The strange thing is that if I do this, then sometimes the build works, but sometimes I get a linker error on an Objective-C symbol in
FirebaseAuth
. This is so confusing...
By "sometimes" I don't mean its random... but I can't figure out what makes it switch from working to non-working or vice-versa.
Maybe this was all simpler than it seems and probably so obvious no one bothered to mention it... it looks like the
shared.podspec
generated by the gradle
podspec
task adds a script phase which does
syncFramework
. Running that within xcode works (and I see that it sets a bunch of additional properties starting with
kotlin.native.cocoapods.*
). I was trying to run it from the CLI, which results in the code 65 error.
i

ilya.matveev

10/21/2020, 4:27 AM
This script phase is indeed needed for running from Xcode. But since 1.4, the CocoaPods plugin supports building from CLI as well.
r

rocketraman

10/21/2020, 2:44 PM
Ok, I've sent you a reproducer project on DM that, at least for me, shows the code 65 error
i

ilya.matveev

10/24/2020, 9:02 AM
Well, the original problem is that using CocoaPods 1.9.x together with Xcode 12.1 causes a compilation error of one of the Firebase dependencies (see a corresponding stackoverflow question). This issue is already fixed in CocoaPods 1.10 but unfortunately the
cocoapods-generate
plugin is incompatible with CocoaPods 1.10. The Kotlin Gradle plugin relies on
cocoapods-generate
to import pod dependencies, so we cannot fix the original issue just by updating CocoaPods. The incompatibility I mentioned is fixed in the master branch of
cocoapods-generate
so hopefully we will get a compatible release soon. Until that, we can use the following workaround. Add this snippet to a buildscript of a Gradle module with shared code:
Copy code
import org.jetbrains.kotlin.gradle.targets.native.tasks.PodGenTask
....
tasks.withType(PodGenTask::class.java) {
    doLast {
        val podspecName = project.name.replace("-", "_")
        val targetSupportFilesDir = buildDir.resolve(
                "cocoapods/synthetic/${kotlinNativeTarget.name}/$podspecName/Pods/Target Support Files"
        )
        val xcconfigs = fileTree(targetSupportFilesDir) {
            include("**/*.xcconfig")
        }
        xcconfigs.forEach {
            it.appendText("CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO")
        }
    }
}
It will disable the failing compiler diagnostic and fix the original issue.
l

louiscad

10/24/2020, 10:41 AM
Is there a YouTrack issue to watch for when this fix makes it into a release on Kotlin side?
r

rocketraman

10/24/2020, 8:07 PM
Just one clarification... the code 65 error can probably be caused by a lot of different build failures in xcodebuild -- the particular issue I was having was related to this error building a transitive dependency of Firebase called `nanopb`:
Copy code
Support Files/nanopb/nanopb-umbrella.h:13:9: error: double-quoted include "pb.h" in framework
The solution was well explained (and solved) by Ilya above. Thanks again!
@louiscad I think the only change required on the Kotlin side relating to this is improving the error reporting of failed xcodebuild calls. The other changes for this particular issue are in CocoaPods 1.10.
d

darkmoon_uk

10/25/2020, 7:28 AM
Another option is to build and install the latest 'master'
cocoapods-generate
gem, just until their next release, since the compatibility issue with Cocoapods 1.10.0 has been fixed, just not released 😒. I also noted this in #ios channel along with links to the relevant issues.
Created a new issue against
cocoapods-generate
for visibility: https://github.com/square/cocoapods-generate/issues/83
👌 3
i

ilya.matveev

10/26/2020, 9:36 AM
Is there a YouTrack issue to watch for when this fix makes it into a release on Kotlin side?
Indeed, the issue should be fixed at the
cocoapods-generate
side. Although I've opened a YT issue to aggregate all info about this problem: https://youtrack.jetbrains.com/issue/KT-42935. If the
cocoapods-generate
release lingers, I think, we will be able to include the workaround above to the CocoaPods Gradle plugin.
the only change required on the Kotlin side relating to this is improving the error reporting of failed xcodebuild calls
I've registered it as well: https://youtrack.jetbrains.com/issue/KT-42938
👍 2
r

rocketraman

11/17/2020, 10:38 PM
As a follow-up to this thread, cocoapods 1.10 and cocoapods-generate 2.0.1 have been released. I've updated my build and things are working well. The "double-quoted include" problem no longer needs workarounds in either the gradle build nor the ios Podfile.
👍 1
62 Views