kotlin-hands-on / get-started-with-kmp

Source code for the "Get started with Kotlin Multiplatform for mobile" project: https://kotlinlang.org/docs/multiplatform-mobile-getting-started.html
Apache License 2.0
4 stars 4 forks source link

Error on Swift code on step3 #7

Open hrqmonteiro opened 2 months ago

hrqmonteiro commented 2 months ago
import SwiftUI
import Shared

struct ContentView: View {
    let phrases = Greeting().greet()

    var body: some View {
        List(phrases, id: \.self) {
            Text($0)
        }
    }
}

This code returns these errors:

Cannot convert value of type 'String' to expected argument type 'Binding<Data>' Initializer 'init(_:)' requires that 'Binding<Data.Element>' conform to 'StringProtocol'

Screenshot 2024-05-02 at 11 22 05 AM

pahill commented 2 months ago

Hi there, thanks for taking the time to file this issue.

I think, it's possible that your shared framework is out of date. You can run embedAndSign to refresh this by either running the app from Android Studio or even Xcode.

Will you check and let me know please?

hrqmonteiro commented 2 months ago

embedAndSign

I don't have the slightest idea of how to do that embedAndSign and i couldn't find anything about it, i am very new to Kotlin. I am just following the tutorial word by word.

Can you provide me more info about it?

The screenshot i provided you was precisely when i tried to run it on Xcode. If i run it on Android Studio this is what i get:

Screenshot 2024-05-06 at 8 42 25 PM

Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project /Users/hrq/Code/Learning/GreetingKMP/iosApp/iosApp.xcodeproj -scheme iosApp -configuration Debug OBJROOT=/Users/hrq/Code/Learning/GreetingKMP/build/ios SYMROOT=/Users/hrq/Code/Learning/GreetingKMP/build/ios -destination id=D9E05D56-CBCB-4F27-A291-9509F5BD345E -allowProvisioningDeviceRegistration -allowProvisioningUpdates

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

Build settings from command line:
    OBJROOT = /Users/hrq/Code/Learning/GreetingKMP/build/ios
    SYMROOT = /Users/hrq/Code/Learning/GreetingKMP/build/ios

Prepare packages

ComputeTargetDependencyGraph
note: Building targets in dependency order
note: Target dependency graph (1 target)
    Target 'iosApp' in project 'iosApp' (no dependencies)

GatherProvisioningInputs

CreateBuildDescription
Build description signature: fc300dfc2957b0d1adba3793526ee8cf
Build description path: /Users/hrq/Code/Learning/GreetingKMP/build/ios/XCBuildData/fc300dfc2957b0d1adba3793526ee8cf.xcbuilddata

/Users/hrq/Downloads/GreetingKMP/iosApp/Configuration/Config.xcconfig:1:1: error: unable to open configuration settings file
error: Multiple commands produce '/Users/hrq/Code/Learning/GreetingKMP/build/ios/Debug-iphonesimulator/.app'
    note: Target 'iosApp' (project 'iosApp') has create directory command with output '/Users/hrq/Code/Learning/GreetingKMP/build/ios/Debug-iphonesimulator/.app'
    note: Target 'iosApp' (project 'iosApp') has link command with output '/Users/hrq/Code/Learning/GreetingKMP/build/ios/Debug-iphonesimulator/.app'
warning: Run script build phase 'Compile Kotlin Framework' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'iosApp' from project 'iosApp')
error: failed to read asset tags: Error Domain=NSCocoaErrorDomain Code=4 "The file “iosApp” doesn’t exist." UserInfo={NSFilePath=/Users/hrq/Downloads/GreetingKMP/iosApp} (in target 'iosApp' from project 'iosApp')
warning: duplicate output file '/Users/hrq/Code/Learning/GreetingKMP/build/ios/Debug-iphonesimulator/.app' on task: Ld /Users/hrq/Code/Learning/GreetingKMP/build/ios/Debug-iphonesimulator/.app normal (in target 'iosApp' from project 'iosApp')
** BUILD FAILED **