Hello! I have this error after compiling KMP libra...
# multiplatform
n
Hello! I have this error after compiling KMP library with cocoapods
Copy code
There is a library attached to the project that was compiled with an older Kotlin/Native compiler and can't be read in IDE:
			"analytics-cinterop-Analytics.klib" at $project/analytics/build/classes/kotlin/iosX64/main/analytics-cinterop-Analytics.klib
			Please edit Gradle buildfile(s) to use Kotlin Gradle plugin version 1.3.61. Then rebuild the project and re-import it in IDE.
The only place that I apply multiplatform plugin has
kotlin("multiplatform") version "1.3.61"
How can I fix it?
a
You’re getting this in the IDEA right? Please check its Kotlin plugin version. Is it also 1.3.61-<something>?
n
@Artyom Degtyarev [JB] 1.3.61-release-IJ2019.3-1
a
Maybe one can avoid it by invalidating caches ofc, but if it won’t help, maybe it would make sense to check klib manually. To do it, use 'klib' tool from the ~/.konan/kotlin-native-macos-1.3.61/bin/ directory If klibs contents will show correct symbols, then the problem is just IDE plugin. Is it working correctly btw? I mean compilation etc.
n
The compilation works just fine, the output framework is successfully used in 33% cases (one machine out of three, the rest give the attached error)
Restart resolved my problem until the next build
klib contents
showed me the content of my library that I exported via Cocoapods
a
Ok. At least it means klib itself should be valid. Can you clarify a bit, when you face the error, and when you’re getting this SwiftLint things?
n
This error pops up in Intellij Idea after I build a project from Xcode (far from every time though)
The error about incorrect K/N version, i mean
The error with crosses all over stacktrace pops up when an iOS project is built on the other machine using the compiled library as dependency via cocoapods
Exactly same project on the same machine that was used to compile the framework works fine
The framework is wrapped into cocoapods and is retrieved from private repo via
Copy code
use_modular_headers!


source <mailto:'git@bitbucket.org|'git@bitbucket.org>:%COMPANY%/%COMPANY%cocoapods.git'
source '<https://github.com/CocoaPods/Specs.git>'

target 'Demo' do
    pod 'ProjectAnalytics', '~> 0.1.0'
end
import analytics
is where the framework is being imported into the iOS project
And is where the error happens
Exactly same iOS project with exactly same Podfile runs flawlessly on the first machine
And my theory was that the error about
Kotlin Gradle plugin version
can be the cause of it
a
Ah, I think I understand what’s the problem here. In it’s current state, CocoaPods plugin generates dummy framework on the
./gradlew podspec
task execution, to avoid some problems with static/dynamic frameworks.
vendored_framework=
parameter in the Xcode build process. For the actual build, on some stage the plugin compiles the real framework instead of dummy one, and everything goes fine. In your case, it seems like some part of this fragile pipeline was broke.
There was a discussion on CocoaPods plugin use for the remote repositories, see here https://kotlinlang.slack.com/archives/C9JM6Q2UX/p1580468907017200
n
Thanks! So, if I understood correctly, the first option can solve my problem here?
a
Yes, sorry for a long delay. Distributing final framework as a file seems to be an optimal solution here.
n
Thank you! I have found a solution that works on my limited set of tests: I'm building Xcode project for three archs (arm64, arm32, X64); three frameworks are generated; I'm merging %module_name% files from them with
lipo
and put it back into one of frameworks. Finally, I edit Info.plist to mark supported platforms (IPhoneOS, IPhoneSimulator), and add this framework to an empty Cocoapod as dependency. Now, when I include this empty Cocoapod into Xcode project, I am able to build with my framework. It's a lot of manual processes, but as long as it works...
🆒 1
a
Just a small addition - we got some FatFrameworkTask in the Gradle plugin, maybe it could cut you some time on this
lipo
manipulations.
n
Thanks, even better that I thought!