https://kotlinlang.org logo
#ios
Title
# ios
s

Shubham Singh

01/26/2023, 12:54 PM
Hey everyone So I'm working on a KMP project where the
ios
module is set up to use cocoapods But this is causing SwiftUI's preview to fail (i.e. the app runs fine, but I'm not able to see previews in XCode) It gives the following error:
Copy code
linker command failed with exit code 1 (use -v to see invocation)

----------------------------------------

LinkDylibError: Failed to build ContentView.swift

Linking failed: linker command failed with exit code 1 (use -v to see invocation)

|  BuildInvocationError
|  
|  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -F /Applications/Xcode.app/Contents/SharedFrameworks-iphonesimulator -target arm64-apple-ios15.0-simulator -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.1.sdk -L/Users/shubhamsingh/Library/Developer/Xcode/DerivedData/ios-ahzpwspogoxmxtfairhvwgbqqgwj/Build/Intermediates.noindex/Previews/ios/Intermediates.noindex/EagerLinkingTBDs -L/Users/shubhamsingh/Library/Developer/Xcode/DerivedData/ios-ahzpwspogoxmxtfairhvwgbqqgwj/Build/Intermediates.noindex/Previews/ios/Products/Debug-iphonesimulator -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.1.sdk/usr/lib/swift -F/Users/shubhamsingh/Library/Developer/Xcode/DerivedData/ios-ahzpwspogoxmxtfairhvwgbqqgwj/Build/Intermediates.noindex/Previews/ios/Intermediates.noindex/EagerLinkingTBDs -F/Users/shubhamsingh/Library/Developer/Xcode/DerivedData/ios-ahzpwspogoxmxtfairhvwgbqqgwj/Build/Intermediates.noindex/Previews/ios/Products/Debug-iphonesimulator -F/Users/shubhamsingh/Library/Developer/Xcode/DerivedData/ios-ahzpwspogoxmxtfairhvwgbqqgwj/Build/Intermediates.noindex/Previews/ios/Products/Debug-iphonesimulator/KMPNativeCoroutinesCore -F/Users/shubhamsingh/Library/Developer/Xcode/DerivedData/ios-ahzpwspogoxmxtfairhvwgbqqgwj/Build/Intermediates.noindex/Previews/ios/Products/Debug-iphonesimulator/KMPNativeCoroutinesRxSwift -F/Users/shubhamsingh/Library/Developer/Xcode/DerivedData/ios-ahzpwspogoxmxtfairhvwgbqqgwj/Build/Intermediates.noindex/Previews/ios/Products/Debug-iphonesimulator/RxSwift -F/Users/shubhamsingh/IdeaProjects/PlayTogetherKMP/ios/Pods/../../shared/build/cocoapods/framework -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/Frameworks -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 -lsqlite3 -ObjC -lc++ -framework KMPNativeCoroutinesCore -framework KMPNativeCoroutinesRxSwift -framework RxSwift -framework shared -framework Pods_ios -bundle -bundle_loader /Users/shubhamsingh/Library/Developer/Xcode/DerivedData/ios-ahzpwspogoxmxtfairhvwgbqqgwj/Build/Intermediates.noindex/Previews/ios/Products/Debug-iphonesimulator/ios.app/ios /Users/shubhamsingh/Library/Developer/Xcode/DerivedData/ios-ahzpwspogoxmxtfairhvwgbqqgwj/Build/Intermediates.noindex/Previews/ios/Intermediates.noindex/ios.build/Debug-iphonesimulator/ios.build/Objects-normal/arm64/ContentView.1.preview-thunk.o -o /Users/shubhamsingh/Library/Developer/Xcode/DerivedData/ios-ahzpwspogoxmxtfairhvwgbqqgwj/Build/Intermediates.noindex/Previews/ios/Intermediates.noindex/ios.build/Debug-iphonesimulator/ios.build/Objects-normal/arm64/ContentView.1.preview-thunk.dylib -framework SwiftUI
I found a GitHub issue that matches what I'm trying to say: https://github.com/JetBrains/kotlin-native/issues/3059 In this issue, they talk about making
isStatic = false
in the shared
build.gradle.kts
But if I do that, neither the app works nor the previews When trying to see the preview, XCode shows this error:
Copy code
ios crashed because shared.framework is missing

dyld_sim [
        Library not loaded: @rpath/shared.framework/shared
And when trying to run the app, it crashes while giving the following error:
47 Views