Arkadii Ivanov

    Arkadii Ivanov

    1 year ago
    I'm using the "packForXcode" Gradle task to build my shared library as a Framework. This works fine from Xcode when the Framework is not built yet or I don't change the build target in Xcode. But once I already have the Framework build for e.g. "iOS" and I switch to "iOS Simulator", build fails. It fails before even executing the script from Build Phases (it is put on the second position from top). Is there any solution for this? Currently I can only manually delete the Framework folder before building.
    d

    dazza5000

    1 year ago
    I think we need to understand / have a solution to generate xcframeworks
    Arkadii Ivanov

    Arkadii Ivanov

    1 year ago
    Fat frameworks are possible but they are slow, since every time it builds all targets.
    d

    dazza5000

    1 year ago
    do you have any reference on how to build them in an MP project? That would solve this issue.
    Thomas

    Thomas

    1 year ago
    I have this as well. A gradle clean works, too. I also noticed that Xcode always uses the previously built framework, so I need to tap run again. So if you change some Kotlin code, and run in Xcode, it uses the previously built Kotlin code. Clicking run again in Xcode uses the new code. Not sure what is wrong with my project configuration.
    Arkadii Ivanov

    Arkadii Ivanov

    1 year ago
    @dazza5000 We have fat framework setup for our sample project for Reaktive (e.g. there is a special task to build the Fat framework)
    But currently I'm adding another Xcode project and would like to avoid fat frameworks, since they are slow in build.
    @Thomas I think my problem is a bit different. I'm not changing the Kotlin code, just switching to another build target (iOS -> iOS Simulator). And the build script is not event executed before build fails.
    Thomas

    Thomas

    1 year ago
    @Arkadii Ivanov that is exactly the issue I am having too. I get the same error when switching between targets (device and simulator). It seems that Xcode checks and uses the framework that was built previously. That is why it shows an error when switching targets. And in my case it also uses the previously built framework when building again for the same target when changing Kotlin code.
    Arkadii Ivanov

    Arkadii Ivanov

    1 year ago
    Will use Fat framework approach as a fallback if there is no solution.
    d

    dazza5000

    1 year ago
    awesome - i will need to do this on my projects now that xcode 12 is out - thank you for sharing
    Arkadii Ivanov

    Arkadii Ivanov

    1 year ago
    Yeah, seems working
    ntherning

    ntherning

    1 year ago
    This is how we do it. Only builds the needed slice (arm64, x86_64, debug, release). It also produces an Xcode dependency file to let Xocde detect dirty files on the kotlin side and only invoke Gradle when needed. It's a bit complicated to set up but works flawlessly so far for us. https://gist.github.com/ntherning/dafd5979bdfb660bbf516066ca056931
    Arkadii Ivanov

    Arkadii Ivanov

    1 year ago
    @ntherning looks like this is a great solution, will give it a try. Thanks for sharing! PS: sounds like a good topic for an article/blog post.