I’ve been trying to use XCTestExpectation (<https:...
# kotlin-native
r
I’ve been trying to use XCTestExpectation (https://developer.apple.com/documentation/xctest/asynchronous_tests_and_expectations/testing_asynchronous_operations_with_expectations?language=objc) from Kotlin/Native but having symbol-not-found issues. I suspect a cinterop problem but could use some hints. Details in thread
Error looks like the following:
Copy code
> Task :linkTestDebugExecutableMacos FAILED
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_XCTWaiter", referenced from:
      objc-class-ref in combined.o
  "_OBJC_CLASS_$_XCTestExpectation", referenced from:
      objc-class-ref in combined.o
ld: symbol(s) not found for architecture x86_64
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
My repo is here: https://github.com/russhwolf/xctest-playground gradle cinterop setup: https://github.com/russhwolf/xctest-playground/blob/master/build.gradle#L21-L31 def file: https://github.com/russhwolf/xctest-playground/blob/master/src/nativeInterop/cinterop/xctest.def unit test: https://github.com/russhwolf/xctest-playground/blob/master/src/macosTest/kotlin/sample/SampleTests.kt I don’t think I really know my way around cinterop yet and was having trouble finding samples using objective-c frameworks, but was trying to follow this issue as a guide: https://github.com/JetBrains/kotlin-native/issues/1764
s
You're missing a
linkerOpts
line in your xctest.def file. I'm not sure what it should be though.
o
Same as for C/Objective-C, usually
r
I’m not sure what that is though. From the discussion I linked I might have guessed that I need
Copy code
compilerOpts = -framework XCTest
linkerOpts = -framework XCTest
but that just gets me to
Copy code
> Task :linkTestDebugExecutableMacos FAILED
ld: framework not found XCTest
d
Look up clang linker options.
o
seems /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework/Versions/A/XCTest got needed sysmbol, thus smth like
-F  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/ -framework XCTest
s
Although one can’t always assume that is the path Xcode is at. People often have multiple versions installed and may change it around.