https://kotlinlang.org logo
#orbit-mvi
Title
# orbit-mvi
g

Guilherme Delgado

11/04/2021, 1:46 PM
Hi guys! I’m trying to open a KMM project to code iOS module and it fails to build with:
Copy code
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':shared'.
> kotlin.native.cocoapods.target property was dropped in favor of kotlin.native.cocoapods.platform and kotlin.native.cocoapods.archs. 
 Podspec file might be outdated. Sync project with Gradle files or run the 'podspec' task manually to regenerate it.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at <https://help.gradle.org>

BUILD FAILED in 3s
6 actionable tasks: 6 up-to-date
Command PhaseScriptExecution failed with a nonzero exit code

Showing Recent Messages
                REPO_ROOT="$PODS_TARGET_SRCROOT"

                "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" :shared:syncOrbitSwift                     -Pkotlin.native.cocoapods.target=$KOTLIN_TARGET                     -Pkotlin.native.cocoapods.configuration=$CONFIGURATION                     -Pkotlin.native.cocoapods.cflags="$OTHER_CFLAGS"                     -Pkotlin.native.cocoapods.paths.headers="$HEADER_SEARCH_PATHS"                     -Pkotlin.native.cocoapods.paths.frameworks="$FRAMEWORK_SEARCH_PATHS"

> Task :buildSrc:compileKotlin UP-TO-DATE

> Task :buildSrc:compileJava NO-SOURCE

> Task :buildSrc:compileGroovy NO-SOURCE

> Task :buildSrc:pluginDescriptors UP-TO-DATE

> Task :buildSrc:processResources NO-SOURCE

> Task :buildSrc:classes UP-TO-DATE

> Task :buildSrc:inspectClassesForKotlinIC UP-TO-DATE

> Task :buildSrc:jar UP-TO-DATE

> Task :buildSrc:assemble UP-TO-DATE

> Task :buildSrc:compileTestKotlin NO-SOURCE

> Task :buildSrc:pluginUnderTestMetadata UP-TO-DATE

> Task :buildSrc:compileTestJava NO-SOURCE

> Task :buildSrc:compileTestGroovy NO-SOURCE

> Task :buildSrc:processTestResources NO-SOURCE

> Task :buildSrc:testClasses UP-TO-DATE

> Task :buildSrc:test NO-SOURCE

> Task :buildSrc:validatePlugins UP-TO-DATE

> Task :buildSrc:check UP-TO-DATE

> Task :buildSrc:build UP-TO-DATE
I’ve run:
Copy code
$ ./gradlew orbitPodSpec

> Configure project :shared
Kotlin Multiplatform Projects are an Alpha feature. See: <https://kotlinlang.org/docs/reference/evolution/components-stability.html>. To hide this message, add 'kotlin.mpp.stability.nowarn=true' to the Gradle properties.

To take advantage of the new functionality for Cocoapods Integration like synchronizing with the Xcode project 
and supporting dependencies on pods, please install the `cocoapods-generate` plugin for CocoaPods 
by calling `gem install cocoapods-generate` in terminal. 

More details are available by <https://github.com/square/cocoapods-generate>

The following Kotlin source sets were configured but not added to any Kotlin compilation:
 * androidAndroidTestRelease
 * androidTestFixtures
 * androidTestFixturesDebug
 * androidTestFixturesRelease
You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
See <https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets>

> Task :shared:orbitPodspec
Generated a podspec file at: /Users/.../shared/sharedOrbitSwift.podspec.
To include it in your Xcode project, check that the following dependency snippet exists in your Podfile:

pod 'sharedOrbitSwift', :path => '/Users/.../shared'


Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See <https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings>

BUILD SUCCESSFUL in 2s
my podfile:
Copy code
target 'iosApp' do
 use_frameworks!
 platform :ios, '14.1'
 pod 'shared', :path => '../shared'
 pod 'sharedOrbitSwift', :path => '../shared'
end
🤔
a

appmattus

11/04/2021, 3:30 PM
the cost of bleeding edge... will try and take a look and come up with something over the weekend... hoping its just a simple fix.
😅 1
🙏 1
What version of Kotlin are you using?
g

Guilherme Delgado

11/04/2021, 3:34 PM
const val kotlin = "1.5.30"
a

appmattus

11/04/2021, 3:34 PM
ah yeah i just noticed my sample project is still on 1.5.21!!!
g

Guilherme Delgado

11/04/2021, 3:34 PM
didn’t try your sample though
ok, that could be where the problem lies
a

appmattus

11/04/2021, 3:36 PM
all those good intentions of writing up an article and publishing this stuff properly...
g

Guilherme Delgado

11/04/2021, 3:36 PM
😂
like you said: “the cost of bleeding edge...”
but we’ll manage 😉
a

appmattus

11/04/2021, 3:38 PM
i seem to remember now fighting a lot with compose when i was setting it up so reduced the kotlin version to please it; now its properly out i should be able to bump things correctly
👍 2
g

Guilherme Delgado

11/04/2021, 3:38 PM
I saw an article from john o’reilly where he uses different kotlin version for Android and iOS
i could give it a spin
a

appmattus

11/04/2021, 3:39 PM
i mean they are "supposed" to be binary compatible
g

Guilherme Delgado

11/04/2021, 3:40 PM
(do you think this could be a hotfix?)
a

appmattus

11/04/2021, 3:43 PM
yeah certainly looking at johns article, looks like it should help, you're just downgrading kotlin to 1.5.21 for the ios build and keeping android on 1.5.31
hopefully will have a proper fix down quickly too though
g

Guilherme Delgado

11/04/2021, 3:46 PM
top, will try that and keep you updated
thanks again for your time 🙂
a

appmattus

11/04/2021, 5:03 PM
as a very quick fix you may be able to replace part of the podspec with the below before re-running
pod install
although i'm hitting a different issue to do with a modulemap that i've not seen before!
Copy code
spec.pod_target_xcconfig = {
        'KOTLIN_PROJECT_PATH' => ':shared',
        'PRODUCT_MODULE_NAME' => 'shared',
    }

    spec.script_phases = [
        {
            :name => 'Build sharedOrbitSwift',
            :execution_position => :before_compile,
            :shell_path => '/bin/sh',
            :script => <<-SCRIPT
                if [ "YES" = "$COCOAPODS_SKIP_KOTLIN_BUILD" ]; then
                  echo "Skipping Gradle build task invocation due to COCOAPODS_SKIP_KOTLIN_BUILD environment variable set to \"YES\""
                  exit 0
                fi
                set -ev
                REPO_ROOT="$PODS_TARGET_SRCROOT"
                "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncOrbitSwift \
                    -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \
                    -Pkotlin.native.cocoapods.archs="$ARCHS" \
                    -Pkotlin.native.cocoapods.configuration=$CONFIGURATION \
                    -Pkotlin.native.cocoapods.cflags="$OTHER_CFLAGS" \
                    -Pkotlin.native.cocoapods.paths.headers="$HEADER_SEARCH_PATHS" \
                    -Pkotlin.native.cocoapods.paths.frameworks="$FRAMEWORK_SEARCH_PATHS"
            SCRIPT
        }
    ]
g

Guilherme Delgado

11/04/2021, 5:06 PM
I’ve tried john’s approach and it was failing too (dunno if you want to try it too, to exclude a possible false negative)
I’ve replaced and run pod install and (i guess) it worked. Now I’ve a different error but it could be my fault
let me double check
at least the “exit with zero” error didn’t happen
a

appmattus

11/04/2021, 5:14 PM
hmm well it looks like i might need to tweak the sync task anyway too
g

Guilherme Delgado

11/04/2021, 5:31 PM
ok it worked, it builds
off topic: did you have any problem with SwiftUI previews? I’m just trying to use Xcode for the previews, other wise I’ll use AppCode.
a

appmattus

11/04/2021, 6:13 PM
less flaky than compose from what i remember! for the KMM project i never set any up though
g

Guilherme Delgado

11/04/2021, 6:17 PM
I can’t generate a preview, I’ve tried with a 100% iOS and it worked
maybe it’s because of the KMM thing… oh well AppCode.
also, with Android I find it faster to run to the device instead of waiting for the preview 😅
@appmattus hello!
Views created now it’s time to integrate 🦜 😬
first problem:
import sharedOrbitSwift
Xcode says it can’t find this module, but i do have this:
message has been deleted
and the
shared
doesn’t give me this warning 🤔
Copy code
@StateObject private var viewModel = ViewModels().myViewModel().asStateObject()
it can find
ViewModels().myViewModel
but not the
asStateObject()
which I believe it’s an extension from the
sharedOrbitSwift
module (am I right?)
any hint?
I’ve noticed that there’s no Framework folder inside the sharedOrbitSwift group, maybe this is the problem
a

appmattus

11/10/2021, 10:35 AM
you should see the files... something like this:
g

Guilherme Delgado

11/10/2021, 10:36 AM
gonna run again the ./gradlew orbitPodSpec
(I have to change the file to what we have discussed last week (’cause of Kotlin version) every time i run the command)
a

appmattus

11/10/2021, 10:37 AM
you need to run the build in xcode for them to appear i believe
of course i've broken my sample app locally trying to get it running with 1.5.31 so cannot provide better details!
😅 1
g

Guilherme Delgado

11/10/2021, 10:40 AM
my steps: 1 - ./gradlew orbitPodSpec 2 - changed sharedOrbitSwift.podspec file 3 - pod install 4 - xcode build same output 🤔
I do have the pod folder but not the MyViewModelAsStateObject.swift file
Copy code
Analyzing dependencies
Downloading dependencies
Installing sharedOrbitSwift 1.0
Generating Pods project
Integrating client project
Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.
a

appmattus

11/10/2021, 11:02 AM
do you see the swift files in the projects build dir?
g

Guilherme Delgado

11/10/2021, 11:33 AM
you mean the build folder from shared module right?
i’ve a lot less folders 😕 but i do see the StateObject file
message has been deleted
message has been deleted
in the cocopods i don’t have the sharedOrbitSwift 🤔
a

appmattus

11/10/2021, 11:40 AM
the files get built into build/bin first and are then copied into the cocoapods/framework so i guess something in the build step is failing
you might be able to see the exception in xcode logs (hopefully)
g

Guilherme Delgado

11/10/2021, 11:53 AM
fresh clean builds
but now:
Copy code
* What went wrong:
Task 'syncOrbitSwift' not found in project ':shared'.

* Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at <https://help.gradle.org>

BUILD FAILED in 4s
6 actionable tasks: 6 up-to-date
Command PhaseScriptExecution failed with a nonzero exit code
😒
could it be the path:
spec.source_files       = “build/cocoapods/orbit/sharedOrbitSwift/**/*.{h,m,swift}”
🤔
I don’t have the “orbit” folder
(tried it, same output)
a

appmattus

11/10/2021, 2:54 PM
hmm i might have screwed the paths up to be honest... locally i still have the orbit directory from a previous build which would explain why it still works for me
g

Guilherme Delgado

11/10/2021, 2:57 PM
either way, i believe the problem now it’s related with the syncOrbitSwift
this is a task from your compiler plugin right?
for some reason when the xcode build runs this command:
Copy code
"$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncOrbitSwift \
it will throw saying that task doesn’t exists 🤔
a

appmattus

11/10/2021, 4:34 PM
usually thats because the parameters are wrong for the task
when i (finally) get around to koltin 1.5.31 support i should be able to fix this
g

Guilherme Delgado

11/12/2021, 6:04 PM
Hello @appmattus!
new minor progress: i’ve added this line to my podfile:
Copy code
install! 'cocoapods', :disable_input_output_paths => true
and commented this one:
Copy code
#  use_frameworks!
still fails with the same output 😒:
Copy code
Task 'syncOrbitSwift' not found in project ':shared'.
But now I can see the swift files generated in the sharedOrbitSwift folder
dunno if it helps, but yeah.
a

appmattus

11/25/2021, 4:14 PM
ha yeah fortunately @Mikolaj Leszczynski already messaged me about this too... fortunately we haven't published a new version of orbit targetting 1.6.0
3 Views