Hi I am new to kmm. I started with AppCode and cre...
# multiplatform
r
Hi I am new to kmm. I started with AppCode and created a new kmm project. When I want to build the app for iOS I ran into the following error:
Copy code
ld: building for iOS Simulator, but linking in dylib built for iOS, file '../../../../../shared/build/bin/iosArm64/debugFramework/shared.framework/shared' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Copy code
> Task :iosApp:buildIosAppMain FAILED

The following build commands failed:
	Ld /Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/bin/iosApp/Debug-iphonesimulator/HelloWorld.app/HelloWorld normal (in target 'iosApp' from project 'iosApp')
(1 failure)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':iosApp:buildIosAppMain'.
> Process 'command 'xcrun'' finished with non-zero exit value 65
I work on a MacBook Pro M1 with macOS 12.1 and xCode 13.2.1. How can I fix this linking error?
a
Hello, @Roger Kreienbühl! Please check if your shared module has the
iosSimulatorArm64
target uncommented in the
build.gradle.kts
file.
r
@Artyom Degtyarev [JB] Thanks for your response.
iosSimulatorArm64
was missing. I added
Copy code
iosSimulatorArm64()
to
kotlin {}
and added
Copy code
val iosSimulatorArm64Main by getting
val iosSimulatorArm64Test by getting

iosSimulatorArm64Main.dependsOn(iosMain)
iosSimulatorArm64Test.dependsOn(iosTest)
to
kotlin { sourceSets {} }
as mentioned in the docs, but I have the same error. My
build.gradle.kts
for the shared module looks like this:
Copy code
plugins {
    kotlin("multiplatform")
    id("com.android.library")
    id("kotlin-android-extensions")
}

repositories {
    google()
    jcenter()
}

kotlin {
    android()
    ios {
        binaries {
            framework {
                baseName = "shared"
            }
        }
    }
    iosSimulatorArm64()
    sourceSets {
        val commonMain by getting
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val androidMain by getting {
            dependencies {
                implementation("com.google.android.material:material:1.2.1")
            }
        }
        val androidTest by getting {
            dependencies {
                implementation("junit:junit:4.13")
            }
        }
        val iosMain by getting
        val iosTest by getting
        val iosSimulatorArm64Main by getting
        val iosSimulatorArm64Test by getting

        iosSimulatorArm64Main.dependsOn(iosMain)
        iosSimulatorArm64Test.dependsOn(iosTest)
    }
}

android {
    compileSdkVersion(29)
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdkVersion(24)
        targetSdkVersion(29)
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}
and the one for iOS like this:
Copy code
plugins {
    id("org.jetbrains.gradle.apple.applePlugin") version "212.4638.14-0.15"
}

apple {
    iosApp {
        productName = "HelloWorld"

        sceneDelegateClass = "SceneDelegate"
        launchStoryboard = "LaunchScreen"

        //productInfo["NSAppTransportSecurity"] = mapOf("NSAllowsArbitraryLoads" to true)
        //buildSettings.OTHER_LDFLAGS("")

        dependencies {
            implementation(project(":shared"))
        }
    }
}
The whole error log with stacktrace is:
Copy code
> Task :iosApp:buildIosAppMain FAILED
RUNNING XCODEBUILD:
objc[25765]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1f2616b90) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x107a402c8). One of the two will be used. Which one is undefined.
objc[25765]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1f2616be0) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x107a40318). One of the two will be used. Which one is undefined.
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project iosApp.xcodeproj -scheme iosApp -configuration Debug OBJROOT=../../../classes/apple/iosApp/build SYMROOT=../../../bin/iosApp -arch arm64 -derivedDataPath ../../../classes/apple/iosApp/DerivedData -sdk iphonesimulator build

User defaults from command line:
    IDEDerivedDataPathOverride = /Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/classes/apple/iosApp/DerivedData
    IDEPackageSupportUseBuiltinSCM = YES

Build settings from command line:
    ARCHS = arm64
    OBJROOT = ../../../classes/apple/iosApp/build
    SDKROOT = iphonesimulator15.2
    SYMROOT = ../../../bin/iosApp

--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
{ platform:iOS Simulator, id:FD0F2302-9B3D-42C3-A429-9B9016EB7F83, OS:15.2, name:iPhone 8 }
{ platform:iOS Simulator, id:28ACB7EC-E937-41C8-B499-CF8A44E1F8D5, OS:15.2, name:iPhone 8 Plus }
{ platform:iOS Simulator, id:C19209A0-387F-436F-9967-E8F0B512F9DA, OS:15.2, name:iPhone 11 }
{ platform:iOS Simulator, id:A034500C-9AC8-4040-B191-6AAF1E90B6B2, OS:15.2, name:iPhone 11 Pro }
{ platform:iOS Simulator, id:5325AABE-2864-49B9-AD83-25EA389CC3B5, OS:15.2, name:iPhone 11 Pro Max }
{ platform:iOS Simulator, id:2C752D57-4EA6-4250-8A16-1B7D1EE1EDAB, OS:15.2, name:iPhone 12 }
{ platform:iOS Simulator, id:FC3B2B7A-0FE7-4B2A-B126-F9D995508F8C, OS:15.2, name:iPhone 12 Pro }
{ platform:iOS Simulator, id:58FFD604-CA26-4451-8CF7-FCE7754C8BE5, OS:15.2, name:iPhone 12 Pro Max }
{ platform:iOS Simulator, id:3C0CCCBA-62C5-4128-B922-888673902C09, OS:15.2, name:iPhone 12 mini }
{ platform:iOS Simulator, id:F338FE49-B120-4FDB-8707-9F2CE5E860AA, OS:15.2, name:iPhone 13 }
{ platform:iOS Simulator, id:EBD2B58E-0914-4F23-951C-2C2EC7FE126B, OS:15.2, name:iPhone 13 Pro }
{ platform:iOS Simulator, id:EDCD5868-6863-47EF-9ADB-CAE9FD121734, OS:15.2, name:iPhone 13 Pro Max }
{ platform:iOS Simulator, id:0A5708CA-F68A-4F78-9E6C-4E7EDA9A2A6D, OS:15.2, name:iPhone 13 mini }
{ platform:iOS Simulator, id:866FE91A-0B5F-4EDD-B451-7889AD000BFC, OS:15.2, name:iPhone SE (2nd generation) }
{ platform:iOS Simulator, id:1BCA0AF7-AB7D-4EDB-BA65-5A60A3C038BA, OS:15.2, name:iPod touch (7th generation) }
{ platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:00006000-000A44212238801E }
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
{ platform:iOS Simulator, id:74FA5EAA-8333-42A1-A467-61C210DEDE63, OS:15.2, name:iPad (9th generation) }
{ platform:iOS Simulator, id:CA6E27ED-4A34-421B-B1B3-2677EA657D85, OS:15.2, name:iPad Air (4th generation) }
{ platform:iOS Simulator, id:26E1DD85-CB51-42C9-B33C-A69DD6EDDCF2, OS:15.2, name:iPad Pro (9.7-inch) }
{ platform:iOS Simulator, id:A76C0A97-D114-45CA-9D06-E24EFFC5F22F, OS:15.2, name:iPad Pro (11-inch) (3rd generation) }
{ platform:iOS Simulator, id:FB269545-7742-480F-8172-FC109E94503B, OS:15.2, name:iPad Pro (12.9-inch) (5th generation) }
{ platform:iOS Simulator, id:57C341FB-FC28-4B40-91F6-1329474F1326, OS:15.2, name:iPad mini (6th generation) }
note: Using new build system
note: Planning
Analyze workspace

Create build description
Build description signature: b0e4f9753ff18eeb064a6f7398a96bc2
Build description path: /Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/tmp/apple/iosApp/../../../classes/apple/iosApp/build/XCBuildData/b0e4f9753ff18eeb064a6f7398a96bc2-desc.xcbuild

note: Build preparation complete
note: Building targets in dependency order
Ld /Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/bin/iosApp/Debug-iphonesimulator/HelloWorld.app/HelloWorld normal (in target 'iosApp' from project 'iosApp')
    cd /Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/tmp/apple/iosApp
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-ios15.2-simulator -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk -L/Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/bin/iosApp/Debug-iphonesimulator -F/Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/bin/iosApp/Debug-iphonesimulator -F../../../../../shared/build/bin/iosArm64/debugFramework -filelist /Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/classes/apple/iosApp/build/iosApp.build/Debug-iphonesimulator/iosApp.build/Objects-normal/arm64/HelloWorld.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/classes/apple/iosApp/build/iosApp.build/Debug-iphonesimulator/iosApp.build/Objects-normal/arm64/HelloWorld_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/classes/apple/iosApp/build/iosApp.build/Debug-iphonesimulator/iosApp.build/Objects-normal/arm64/iosApp.swiftmodule -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/classes/apple/iosApp/build/iosApp.build/Debug-iphonesimulator/iosApp.build/HelloWorld.app-Simulated.xcent -framework shared -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/classes/apple/iosApp/build/iosApp.build/Debug-iphonesimulator/iosApp.build/Objects-normal/arm64/HelloWorld_dependency_info.dat -o /Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/bin/iosApp/Debug-iphonesimulator/HelloWorld.app/HelloWorld
ld: building for iOS Simulator, but linking in dylib built for iOS, file '../../../../../shared/build/bin/iosArm64/debugFramework/shared.framework/shared' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **


The following build commands failed:
	Ld /Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/bin/iosApp/Debug-iphonesimulator/HelloWorld.app/HelloWorld normal (in target 'iosApp' from project 'iosApp')
(1 failure)

Execution failed for task ':iosApp:buildIosAppMain'.
> Process 'command 'xcrun'' finished with non-zero exit value 65
a
This script does not specify actual framework for the required target. See, the
binaries
block here applies only to the
ios
target shortcut, which is just a wrapper for
iosX64
&
iosArm64
targets. Please copy the
binaries
block into your
iosSimulatorArm64
and check if this would make any difference. I'm not too familiar with AppCode's approach on importing frameworks, but I hope that it won't require any additional steps.
r
I have also tryed this, but also get the same error
a
Please try deleting the
shared/build/
folder to force the AppCode search for the framework. If this also won't help, let's try specifying the framework location explicitly as described here:https://plugins.jetbrains.com/plugin/17098-kotlin-multiplatform-mobile-for-appcode/docs/kmm-project-structure.html. @Vyacheslav Karpukhin [JB], could you please have a look? Maybe we're missing something obvious here.
r
Deleting the
shared/build/
folder dind’t work. Will try specifying the framework location explicitly in the afternoon.
I have tried to specify the framework via path:
Copy code
implementation(files("../shared/build/bin/iosArm64/debugFramework/shared.framework"))
With this I get the exact same error as before.
v
Hi, I'll try to reproduce and will get back to you soon
r
Thanks. The project was created with the multiplatform plugin for AppCode. If it helps, here I have the packed project (including the build folders for shared and iosApp)
v
Indeed, looks like it's broken at the moment. Thanks for reporting, please follow https://youtrack.jetbrains.com/issue/KMA-374
r
Ok, thanks for the info.
273 Views