Hi guys! I’m trying to open a KMM project to code ...
# orbit-mvi
g
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
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
const val kotlin = "1.5.30"
a
ah yeah i just noticed my sample project is still on 1.5.21!!!
g
didn’t try your sample though
ok, that could be where the problem lies
a
all those good intentions of writing up an article and publishing this stuff properly...
g
😂
like you said: “the cost of bleeding edge...”
but we’ll manage 😉
a
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
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
i mean they are "supposed" to be binary compatible
g
(do you think this could be a hotfix?)
a
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
top, will try that and keep you updated
thanks again for your time 🙂
a
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
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
hmm well it looks like i might need to tweak the sync task anyway too
g
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
less flaky than compose from what i remember! for the KMM project i never set any up though
g
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
you should see the files... something like this:
g
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
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
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
do you see the swift files in the projects build dir?
g
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
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
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
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
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
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
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
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