I’m getting an error when building for the iOS sim...
# multiplatform
r
I’m getting an error when building for the iOS simulator on Mac M1 (detailed logs attached in the thread). Originally the iOS build of my shared library is complained target ios_simulator_arm64 is missing. When I added
iosSimulatorArm64()
as a target to my build.gradle.kts, then the build complains that my “expect” classes are missing for that target with:
Expected class 'SettingsStorage' has no actual declaration in module <shared> for Native.
What is the proper way to get around this error and build for the simulator?
Copy code
> Configure project :mshared
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.

Dependency on pods requires cocoapods-generate plugin to be installed.
If you plan to add dependencies on third party pods, don't forget to install it by executing 'gem install cocoapods-generate' in terminal.

Please wait while Kotlin/Native compiler 1.6.10 is being installed.
Download <https://download.jetbrains.com/kotlin/native/builds/releases/1.6.10/macos-aarch64/kotlin-native-prebuilt-macos-aarch64-1.6.10.tar.gz>
Download <https://download.jetbrains.com/kotlin/native/builds/releases/1.6.10/macos-aarch64/kotlin-native-prebuilt-macos-aarch64-1.6.10.tar.gz> finished, took 16 s 654 ms
Unpack Kotlin/Native compiler to /Users/m/.konan/kotlin-native-prebuilt-macos-aarch64-1.6.10
Unpack Kotlin/Native compiler to /Users/m/.konan/kotlin-native-prebuilt-macos-aarch64-1.6.10 finished, took 17 s 303 ms

The following Kotlin source sets were configured but not added to any Kotlin compilation:
 * androidAndroidTestBeta
 * androidAndroidTestRelease
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 :mshared:compileKotlinIosSimulatorArm64
Downloading native dependencies (LLVM, sysroot etc). This is a one-time action performed only on the first run of the compiler.

(KonanProperies) Downloading dependency: <https://download.jetbrains.com/kotlin/native/apple-llvm-20200714-macos-aarch64-essentials.tar.gz> (0/86257507). 
(KonanProperies) Downloading dependency: <https://download.jetbrains.com/kotlin/native/apple-llvm-20200714-macos-aarch64-essentials.tar.gz> (5569830/86257507). 
(KonanProperies) Downloading dependency: <https://download.jetbrains.com/kotlin/native/apple-llvm-20200714-macos-aarch64-essentials.tar.gz> (17335528/86257507). 
(KonanProperies) Downloading dependency: <https://download.jetbrains.com/kotlin/native/apple-llvm-20200714-macos-aarch64-essentials.tar.gz> (28822361/86257507). 
(KonanProperies) Downloading dependency: <https://download.jetbrains.com/kotlin/native/apple-llvm-20200714-macos-aarch64-essentials.tar.gz> (48371614/86257507). 
(KonanProperies) Downloading dependency: <https://download.jetbrains.com/kotlin/native/apple-llvm-20200714-macos-aarch64-essentials.tar.gz> (81671202/86257507). 
(KonanProperies) Downloading dependency: <https://download.jetbrains.com/kotlin/native/apple-llvm-20200714-macos-aarch64-essentials.tar.gz> (86257507/86257507). Done.
Extracting dependency: /Users/m/.konan/cache/apple-llvm-20200714-macos-aarch64-essentials.tar.gz into /Users/m/.konan/dependencies

(KonanProperies) Downloading dependency: <https://download.jetbrains.com/kotlin/native/libffi-3.3-1-macos-arm64.tar.gz> (0/17037). 
(KonanProperies) Downloading dependency: <https://download.jetbrains.com/kotlin/native/libffi-3.3-1-macos-arm64.tar.gz> (17037/17037). Done.
Extracting dependency: /Users/m/.konan/cache/libffi-3.3-1-macos-arm64.tar.gz into /Users/m/.konan/dependencies
e: /Users/m/Development/hazels/mshared/src/commonMain/kotlin/com/mlabs/mshared/Platform.kt: (3, 14): Expected class 'Platform' has no actual declaration in module <hazels:mshared> for Native
e: /Users/m/Development/hazels/mshared/src/commonMain/kotlin/com/mlabs/mshared/util/Base64Util.kt: (4, 15): Expected object 'Base64Util' has no actual declaration in module <hazels:mshared> for Native
e: /Users/m/Development/hazels/mshared/src/commonMain/kotlin/com/mlabs/mshared/util/BaseViewModel.kt: (5, 19): Expected class 'BaseViewModel' has no actual declaration in module <hazels:mshared> for Native
e: /Users/m/Development/hazels/mshared/src/commonMain/kotlin/com/mlabs/mshared/util/CommonFlow.kt: (6, 14): Expected class 'CommonFlow' has no actual declaration in module <hazels:mshared> for Native
e: /Users/m/Development/hazels/mshared/src/commonMain/kotlin/com/mlabs/mshared/util/CommonFlow.kt: (10, 14): Expected class 'CommonSharedFlow' has no actual declaration in module <hazels:mshared> for Native
e: /Users/m/Development/hazels/mshared/src/commonMain/kotlin/com/mlabs/mshared/util/CommonFlow.kt: (14, 14): Expected class 'CommonStateFlow' has no actual declaration in module <hazels:mshared> for Native
e: /Users/m/Development/hazels/mshared/src/commonMain/kotlin/com/mlabs/mshared/util/CommonFlow.kt: (18, 14): Expected class 'CommonListFlow' has no actual declaration in module <hazels:mshared> for Native
e: /Users/m/Development/hazels/mshared/src/commonMain/kotlin/com/mlabs/mshared/util/Scopes.kt: (6, 15): Expected object 'Scopes' has no actual declaration in module <hazels:mshared> for Native
e: /Users/m/Development/hazels/mshared/src/commonMain/kotlin/com/mlabs/mshared/util/SettingsStorage.kt: (4, 14): Expected class 'SettingsStorage' has no actual declaration in module <hazels:mshared> for Native

> Task :mshared:compileKotlinIosSimulatorArm64 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mshared:compileKotlinIosSimulatorArm64'.
> Compilation finished with errors

* 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>

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See <https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings>

BUILD FAILED in 1m 24s
1 actionable task: 1 executed
Command PhaseScriptExecution failed with a nonzero exit code
Original (first) error with missing ios_simulator_arm64 target complaint:
Copy code
xport TARGETNAME\=mshared
    export TARGET_BUILD_DIR\=/Users/m/Library/Developer/Xcode/DerivedData/m-cdmvboyvdtcfhvdjvmtxmhooltwj/Build/Products/Debug-iphonesimulator/mshared
    export TARGET_DEVICE_IDENTIFIER\=C6ECA80B-781F-4D8D-9893-BFE08AF6D8F5
    export TARGET_DEVICE_MODEL\=iPhone14,5
    export TARGET_DEVICE_OS_VERSION\=15.2
    export TARGET_DEVICE_PLATFORM_NAME\=iphonesimulator
    export TARGET_NAME\=mshared
    export TARGET_TEMP_DIR\=/Users/m/Library/Developer/Xcode/DerivedData/m-cdmvboyvdtcfhvdjvmtxmhooltwj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/mshared.build
    export TEMP_DIR\=/Users/m/Library/Developer/Xcode/DerivedData/m-cdmvboyvdtcfhvdjvmtxmhooltwj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/mshared.build
    export TEMP_FILES_DIR\=/Users/m/Library/Developer/Xcode/DerivedData/m-cdmvboyvdtcfhvdjvmtxmhooltwj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/mshared.build
    export TEMP_FILE_DIR\=/Users/m/Library/Developer/Xcode/DerivedData/m-cdmvboyvdtcfhvdjvmtxmhooltwj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/mshared.build
    export TEMP_ROOT\=/Users/m/Library/Developer/Xcode/DerivedData/m-cdmvboyvdtcfhvdjvmtxmhooltwj/Build/Intermediates.noindex
    export TEST_FRAMEWORK_SEARCH_PATHS\=\ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks\ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/Developer/Library/Frameworks
    export TEST_LIBRARY_SEARCH_PATHS\=\ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib
    export TOOLCHAINS\=com.apple.dt.toolchain.XcodeDefault
    export TOOLCHAIN_DIR\=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
    export TREAT_MISSING_BASELINES_AS_TEST_FAILURES\=NO
    export UID\=501
    export UNSTRIPPED_PRODUCT\=NO
    export USER\=m
    export USER_APPS_DIR\=/Users/m/Applications
    export USER_LIBRARY_DIR\=/Users/m/Library
    export USE_DYNAMIC_NO_PIC\=YES
    export USE_HEADERMAP\=YES
    export USE_HEADER_SYMLINKS\=NO
    export USE_LLVM_TARGET_TRIPLES\=YES
    export USE_LLVM_TARGET_TRIPLES_FOR_CLANG\=YES
    export USE_LLVM_TARGET_TRIPLES_FOR_LD\=YES
    export USE_LLVM_TARGET_TRIPLES_FOR_TAPI\=YES
    export USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES\=YES
    export VALIDATE_DEVELOPMENT_ASSET_PATHS\=YES_ERROR
    export VALIDATE_PRODUCT\=NO
    export VALIDATE_WORKSPACE\=YES_ERROR
    export VALID_ARCHS\=arm64\ arm64e\ i386\ x86_64
    export VERBOSE_PBXCP\=NO
    export VERSION_INFO_BUILDER\=m
    export VERSION_INFO_FILE\=mshared_vers.c
    export VERSION_INFO_STRING\=\"@\(\#\)PROGRAM:mshared\ \ PROJECT:Pods-\"
    export WRAP_ASSET_PACKS_IN_SEPARATE_DIRECTORIES\=NO
    export XCODE_APP_SUPPORT_DIR\=/Applications/Xcode.app/Contents/Developer/Library/Xcode
    export XCODE_PRODUCT_BUILD_VERSION\=13C100
    export XCODE_VERSION_ACTUAL\=1321
    export XCODE_VERSION_MAJOR\=1300
    export XCODE_VERSION_MINOR\=1320
    export XPCSERVICES_FOLDER_PATH\=/XPCServices
    export YACC\=yacc
    export arch\=undefined_arch
    export variant\=normal
    /bin/sh -c /Users/m/Library/Developer/Xcode/DerivedData/m-cdmvboyvdtcfhvdjvmtxmhooltwj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/mshared.build/Script-BA84D0F87526D5B114AA1DE645383CF4.sh

                REPO_ROOT="$PODS_TARGET_SRCROOT"
                "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework                     -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME                     -Pkotlin.native.cocoapods.archs="$ARCHS"                     -Pkotlin.native.cocoapods.configuration=$CONFIGURATION

> Configure project :app
App version: 3.12.0
strippedNativeLibsDir is deprecated and no longer used. Please remove it from your build configuration.
strippedNativeLibsDir is deprecated and no longer used. Please remove it from your build configuration.

> Configure project :mshared
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.

Dependency on pods requires cocoapods-generate plugin to be installed.
If you plan to add dependencies on third party pods, don't forget to install it by executing 'gem install cocoapods-generate' in terminal.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':mshared'.
> The project must have a target for at least one of the following platforms: ios_simulator_arm64.

* 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>

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See <https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings>

BUILD FAILED in 2s
Command PhaseScriptExecution failed with a nonzero exit code
l
Hello. You have to make iosSimulatorArm64 depends on iOS target such as (in sourceSet block):
val iosSimulatorArm64Main by getting { dependsOn(iosMain) }
Same goes for iosTest target
r
Thanks, now I’m getting a new error!
l
Oh ? which one ?
437 Views