grpc-swift icon indicating copy to clipboard operation
grpc-swift copied to clipboard

Unable to use into generated ***ClientProtocol into Test Target

Open adriantabirta opened this issue 2 years ago • 3 comments

Describe the bug

Got: Missing required module 'CNIOAtomics'

Hard: MacBook M1 Soft: latest Xcode version on Ventura, swift version 5.7.1, grpc-swift(1.10.0) in SPM package,

SPM package here

To reproduce

Steps to reproduce the bug you've found:

  1. Create simple Xcode project and add package as dependency
  2. Try to use GeneratedServiceClientProtocol to create RideServiceClientProtocolMock into test target
  3. Got error/s

Expected behaviour

I want to use generated client protocol to create mock classes for testing.

Additional information

  • Have tried to use @_exported import ... in SPM package - same error,
  • Have tried to add grpc-swift as dependency into Xcode project alongside with created SPM package - error, duplicated code
  • Added created package to Link binary with Libraries in Test Target - give me errors like:
Undefined symbols for architecture arm64:
  "_$s19TaxifyClientSwiftUI20RideRemoteDataSourceMp", referenced from:
      _symbolic ______pSg 19TaxifyClientSwiftUI20RideRemoteDataSourceP in RealRideRemoteDataSourceTests.o

Is there a way to forward correctly dependencies like grpc-swift -> my SPM package -> Xcode (especially test target)? Notice: Mocking is working on application target, am I doing something wrong?

adriantabirta avatar Dec 05 '22 19:12 adriantabirta

This seems like an Xcode issue: does this build correctly otherwise?

Lukasa avatar Dec 06 '22 09:12 Lukasa

This seems like an Xcode issue: does this build correctly otherwise?

otherwise how?

Only solution I found it is to add grpc-swift as package dep to Xcode project test target. So basically I import 2 times and got this in terminal when I run tests:

objc[49542]: Class _TtC6NIOTLS37ApplicationProtocolNegotiationHandler is implemented in both 
/Users/at/Library/Developer/XCTestDevices/65FB8BD5-AA7E-4B86-B3E4-CCE03D12DD29/data/Containers/Bundle/Application/7FD92C43-7416-4761-8FBC-ED400AD7407E/OpenTaxi.app/OpenTaxi (0x10129aca8)
and /Users/at/Library/Developer/XCTestDevices/65FB8BD5-AA7E-4B86-B3E4-CCE03D12DD29/data/Containers/Bundle/Application/7FD92C43-7416-4761-8FBC-ED400AD7407E/OpenTaxi.app/PlugIns/OpenTaxiTests.xctest/OpenTaxiTests (0x10e05ed30).
 One of the two will be used. Which one is undefined.

adriantabirta avatar Dec 08 '22 20:12 adriantabirta

Yeah, I think this will require filing a report using Feedback Assistant or asking for help on the Apple Developer Forums. This issue appears to be with Xcode, not with grpc-swift.

Lukasa avatar Dec 12 '22 12:12 Lukasa