ionspin / kotlin-multiplatform-libsodium

A kotlin multiplatform wrapper for libsodium, using directly built libsodium for jvm and native, and libsodium.js for js targets.
Apache License 2.0
99 stars 9 forks source link

Linker error running on iPhone Simulator x86_64 using 0.8.8 #32

Closed azlekov closed 2 years ago

azlekov commented 2 years ago

After updating to 0.8.8 when I develop a multiplatform project and I try to run some SwiftUI previews I got:

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

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

LinkDylibError: Failed to build SingleSelectionList.swift

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

ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/SharedFrameworks-iphonesimulator'
Undefined symbols for architecture x86_64:
  "_crypto_core_salsa2012", referenced from:
      _libsodium_crypto_core_salsa2012_wrapper169 in DodiKit(result.o)
     (maybe you meant: knifunptr_libsodium168_crypto_core_salsa2012_constbytes, _libsodium_crypto_core_salsa2012_outputbytes_wrapper165 , knifunptr_libsodium165_crypto_core_salsa2012_outputbytes , _libsodium_crypto_core_salsa2012_constbytes_wrapper168 , knifunptr_libsodium167_crypto_core_salsa2012_keybytes , _libsodium_crypto_core_salsa2012_keybytes_wrapper167 , knifunptr_libsodium166_crypto_core_salsa2012_inputbytes , _libsodium_crypto_core_salsa2012_inputbytes_wrapper166 , _libsodium_crypto_core_salsa2012_wrapper169 , knifunptr_libsodium169_crypto_core_salsa2012 )
  "_crypto_core_salsa2012_constbytes", referenced from:
      _libsodium_crypto_core_salsa2012_constbytes_wrapper168 in DodiKit(result.o)
     (maybe you meant: knifunptr_libsodium168_crypto_core_salsa2012_constbytes, _libsodium_crypto_core_salsa2012_constbytes_wrapper168 )
  "_crypto_core_salsa2012_inputbytes", referenced from:
      _libsodium_crypto_core_salsa2012_inputbytes_wrapper166 in DodiKit(result.o)
     (maybe you meant: knifunptr_libsodium166_crypto_core_salsa2012_inputbytes, _libsodium_crypto_core_salsa2012_inputbytes_wrapper166 )
  "_crypto_core_salsa2012_keybytes", referenced from:
      _libsodium_crypto_core_salsa2012_keybytes_wrapper167 in DodiKit(result.o)
     (maybe you meant: knifunptr_libsodium167_crypto_core_salsa2012_keybytes, _libsodium_crypto_core_salsa2012_keybytes_wrapper167 )
  "_crypto_core_salsa2012_outputbytes", referenced from:
      _libsodium_crypto_core_salsa2012_outputbytes_wrapper165 in DodiKit(result.o)
     (maybe you meant: _libsodium_crypto_core_salsa2012_outputbytes_wrapper165, knifunptr_libsodium165_crypto_core_salsa2012_outputbytes )
  "_crypto_core_salsa208", referenced from:
      _libsodium_crypto_core_salsa208_wrapper174 in DodiKit(result.o)
     (maybe you meant: knifunptr_libsodium174_crypto_core_salsa208, _libsodium_crypto_core_salsa208_inputbytes_wrapper171 , _libsodium_crypto_core_salsa208_constbytes_wrapper173 , knifunptr_libsodium170_crypto_core_salsa208_outputbytes , knifunptr_libsodium171_crypto_core_salsa208_inputbytes , knifunptr_libsodium172_crypto_core_salsa208_keybytes , _libsodium_crypto_core_salsa208_keybytes_wrapper172 , knifunptr_libsodium173_crypto_core_salsa208_constbytes , _libsodium_crypto_core_salsa208_wrapper174 , _libsodium_crypto_core_salsa208_outputbytes_wrapper170 )
  "_crypto_core_salsa208_constbytes", referenced from:
      _libsodium_crypto_core_salsa208_constbytes_wrapper173 in DodiKit(result.o)
     (maybe you meant: _libsodium_crypto_core_salsa208_constbytes_wrapper173, knifunptr_libsodium173_crypto_core_salsa208_constbytes )
  "_crypto_core_salsa208_inputbytes", referenced from:
      _libsodium_crypto_core_salsa208_inputbytes_wrapper171 in DodiKit(result.o)
     (maybe you meant: _libsodium_crypto_core_salsa208_inputbytes_wrapper171, knifunptr_libsodium171_crypto_core_salsa208_inputbytes )
  "_crypto_core_salsa208_keybytes", referenced from:
      _libsodium_crypto_core_salsa208_keybytes_wrapper172 in DodiKit(result.o)
     (maybe you meant: knifunptr_libsodium172_crypto_core_salsa208_keybytes, _libsodium_crypto_core_salsa208_keybytes_wrapper172 )
  "_crypto_core_salsa208_outputbytes", referenced from:
      _libsodium_crypto_core_salsa208_outputbytes_wrapper170 in DodiKit(result.o)
     (maybe you meant: knifunptr_libsodium170_crypto_core_salsa208_outputbytes, _libsodium_crypto_core_salsa208_outputbytes_wrapper170 )
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It was working before.

ionspin commented 2 years ago

Hi @L3K0V , This happens only with previews? Presumably you are using x86 and not arm mac?

ionspin commented 2 years ago

There shouldn't have been any significant change on ios/mac side between 0.8.7 and 0.8.8 since the update was only for inclusion of windows mingw target into modules. I've checked the released files and module.xml and it seems to be ok for mac/ios targets.

I've previously had problems with xcode caching my libraries in an unexpected way. Could you try cleaning the project, or removing and re-adding the library to your project?

azlekov commented 2 years ago

Hi @L3K0V , This happens only with previews? Presumably you are using x86 and not arm mac?

Only with previews on x86 MacBook. Everything works fine on iOS, but maybe is affecting macOS targets...

There shouldn't have been any significant change on ios/mac side between 0.8.7 and 0.8.8 since the update was only for inclusion of windows mingw target into modules. I've checked the released files and module.xml and it seems to be ok for mac/ios targets.

I've previously had problems with xcode caching my libraries in an unexpected way. Could you try cleaning the project, or removing and re-adding the library to your project?

I tried cleaning derived data, rebuilding the multiplatform project without any success. Last time I used SwiftUI previews I believe was with 0.8.6 or 0.8.7. I also checked the release notes and nothing special I found.

By re-adding the library what do you mean, do you remember how you fix it? Any other proposals or ideas?

ionspin commented 2 years ago

By re-adding the library what do you mean, do you remember how you fix it? Any other proposals or ideas?

I haven't touched iOS/macos in several months, but the last time I had trouble with it I would remove the framework (the one that you kotlin project builds in the end using "packForXcode" task or something similar) from the xcode project, let xcode fail a build and report the framework is missing and then add it once again.

ionspin commented 2 years ago

Or if you are using multiplatformSwiftPackage plugin then the task is createXCFramework that produces the framework.

azlekov commented 2 years ago

I will try and report back, hopefully with a successful result 🙏

azlekov commented 2 years ago

Deleting the framework and generating a fresh one did the job 🎉

Many thanks, @ionspin! I'm closing this 📦