segmentio / analytics-swift

The hassle-free way to add Segment analytics to your Swift app (iOS/tvOS/watchOS/macOS/Linux).

Repository from Github https://github.comsegmentio/analytics-swiftRepository from Github https://github.comsegmentio/analytics-swift

Vendored Framework: "... is not a member type of ..." error

miquelalvarado opened this issue · comments

Describe the bug
Since the introduction of the JSONSafeEncoder framework we get an error each time we try to add both Segment and JSONSafeEncoder as vendored frameworks (through CocoaPods) to our application project.

When compiling our app we get several errors:
Screenshot 2024-04-03 at 11 12 07

If we jump to a file where it errors you can see as the module name seems to be duplicated (it probably wouldn't even have to be added at all):
Screenshot 2024-04-03 at 11 12 25

I've been searching for the root cause and a possible workaround but workarounds doesn't seem to work when cleaning the project and building again. In any case it seems to be related with the struct JSONSafeEncoder being named exactly the same as the file name as you can see here.

SPM integration works well

To Reproduce
Steps to reproduce the behavior:

  1. Create an example project using CocoaPods and adding Segment as well as Sovran and JSONSafeEncoder as vendored frameworks such as:
    s.vendored_frameworks = [
      "VendoredFrameworks/Segment.xcframework",
      "VendoredFrameworks/Sovran.xcframework",
      "VendoredFrameworks/JSONSafeEncoder.xcframework",
    ]
  1. Compile the project
  2. See error

Expected behavior
The project compiles as when integrated through SPM.

Platform (please complete the following information):

  • Library Version in use: Tried with several of the latest versions, it happens with all of them. Latest release as well (1.5.9)
  • Platform being tested: iOS

We don't/won't support Cocoapods. You can have a look at a couple of the forks where pod specs have been added and maybe find some guidance from there.

Hi @bsneed! Yes, I know you don't support Cocoapods so that's why we are using the downloadable xcframework file you provide from the releases section to integrate it (through a feature of CocoaPods called vendored frameworks) in our project.

That xcframework you are publishing is not working right now when integrated into a project. So that's what's making me think it should be supported.
The solution to it seems to be as easy as renaming the file containing the JSONSafeEncoder struct to something else (though I haven't been able to validate it).

I'm keeping the issue as closed and leaving to you the decision of reopening it if you consider my point valid. Thanks!

Hi @miquelalvarado, my apologies. I misunderstood. I'll go have a look at it shortly.

No problem, thanks! 😊

Hi @miquelalvarado, I just went in and looked at this. It looks like that's the swift generated header you're looking at. The actual code looks like this ...

image

The link you posted has a solution at the bottom that might be helpful, did you try this?

just Add "-no-verify-emitted-module-interface" to Other Swift Flags to your Build Settings if you are using SPM or Cocoapods.

If that doesn't work, I can change up the module/class names as necessary but would like to avoid it if I can.

oops, hit the wrong button. reopening.

Hi @bsneed,

Sorry I didn't add that information in my first message but yes, I tried that as well. I've prepared though, a simple project to test it out of my main project and remove other variables that might be involved; and the result is the same. I'm attaching a zip with the project as well as a screenshot where you can see the result:

VendoredFrameworksTest.zip

Screenshot 2024-04-19 at 10 54 48

Thanks @miquelalvarado, I'll open it now and have a look.

Should be resolved now, thanks for your patience @miquelalvarado !