LeoNatan / LNPopupUI

A SwiftUI library for presenting views as popups, much like the Apple Music and Podcasts apps.
MIT License
320 stars 29 forks source link

Can't build test target while using LNPopupUI #23

Closed tadelv closed 1 year ago

tadelv commented 1 year ago

Describe the Bug I'm using LNPopupUI as a SPM dependency in my project, added through Xcode. I have my target set up so that it adds LNPopupUI-Static (not sure if this is the intended way). When I try to build tests for my target, I get a failure <unknown>:0: error: missing required module 'LNPopupController_ObjC'

To Reproduce Steps to reproduce the behavior:

  1. add LNPopupUI to your target
  2. import LNPopupUI and attach popup to ContentView content
  3. build and run tests
  4. See error

Expected Behavior Test bundle should build and run tests

Additional Context I've uploaded an example that reproduces the issue here

tadelv commented 1 year ago

Also, it does not matter whether LNPopupUI or LNPopupUI-Static is the dependency. Eitherway, module emitting fails because of LNPopupController_ObjC

LeoNatan commented 1 year ago

Using your project, to get the tests to run I linked the test target with LNPopupUI:

Screenshot 2023-05-14 at 1 57 35

I’m not sure why this is required. It could be an Xcode bug with how @testable import is implemented. I’m not really familiar with how that works in Swift. I don’t think there is any misconfiguration on this project’s part, so I am closing the issue.

Thanks

tadelv commented 1 year ago

Just to confirm, this fixes the build. Thanks again!

LeoNatan commented 1 year ago

Just an aside, I don’t think you should be unit-testing UI. I know with SwiftUI, this is a tall order, because of model-view intertwining (terrible), but normal XCTest is really not suited for any UI testing, nor should it be. This is a small issue. But throughout your testing, you will hit many, many issues related to expecting stuff from the system UI frameworks or their state. Just an unsolicited word of caution. 🙂

tadelv commented 1 year ago

Thanks for the after thought, I appreciate it. I'm not testing the UI in the actual app where I first observed the issue.