https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

Aleksandr Ivanov

10/05/2020, 12:44 PM
Hi there, Not found an answer - now I’m building a library for android/ios and plan to distribute it for iOS via cocoapods. I managed to made that locally as wrote in documentations. But what if I want to distribute it via remote repository. How to do that? And is it possible to do taht without have a link to target application podfile inside library. It looks weird to have it here, especially in case I have no knowledge about who will use ny project.
👀 1
s

Siggi Gunnarss

10/05/2020, 1:04 PM
This is a good question. I think the example you mention assumes that the library either build for simulator or iPhone. When distributing a library, even within your company, you need to support both. You would need to make a "fat framework" and then edit the podfile to support the right platforms. I would be very interested in seeing a working example that uses fat frameworks that include linked libraries like sqlite3, distributed via cocoapods.
With the framework and podspec successfully build, you would publish via the
pod
commands, at least if you're distributing to a private pod repo: https://guides.cocoapods.org/making/private-cocoapods.html
pod repo push ...
a

Aleksandr Ivanov

10/05/2020, 1:29 PM
I experimented with fat framework to, but in that case, as I understand I must create pod file and deploy it manually, don’t wont to do that. Thanks you for the link, will check it.
y

yousefa2

10/05/2020, 4:44 PM
Keep in mind the difference between
PodFile
and
.podspec
.
PodFile
is for your application to know which pods to use while
.podspec
describes the framework you are building. Siggi’s suggestion is the official way of publishing pods to the cocoapods central repository but you can also reference git repositories in a
PodFile
to pull in a cocoapod.
k

KamilH

11/03/2020, 6:51 AM
Hey @Aleksandr Ivanov, did you find any good solution to your problem? I’m trying to publish my iOS target of Multiplatform library in remote
cocoapods
which seems like a similar problem to yours
a

Aleksandr Ivanov

11/03/2020, 8:09 AM
Not yet. At this moment we decided to stay with fat framework and manually created .podspec file.
k

KamilH

11/03/2020, 9:06 PM
Would you mind share how are you building fat framework?
But a little bit different:
Copy code
// Create a task to build a debug fat framework.
    tasks.create("generateDebugFatFramework", FatFrameworkTask::class) {
        // The fat framework must have the same base name as the initial frameworks.
        baseName = "authSDK"
        // The default destination directory is '<build directory>/fat-framework'.
        destinationDir = buildDir.resolve("fat-framework/debug")
        // Specify the frameworks to be merged.
        from(
                iosArm64().binaries.getFramework("DEBUG"),
                iosX64().binaries.getFramework("DEBUG")
        )
    }

    // Create a task to build a release fat framework.
    tasks.create("generateReleaseFatFramework", FatFrameworkTask::class) {
        // The fat framework must have the same base name as the initial frameworks.
        baseName = "authSDK"
        // The default destination directory is '<build directory>/fat-framework'.
        destinationDir = buildDir.resolve("fat-framework/release")
        // Specify the frameworks to be merged.
        from(
            iosArm64().binaries.getFramework("RELEASE"),
            iosX64().binaries.getFramework("RELEASE")
        )
    }
k

KamilH

11/05/2020, 1:43 PM
Great, thank you! This is what I was looking for 🙂