siteline / swiftui-introspect

Introspect underlying UIKit/AppKit components from SwiftUI
MIT License
5.71k stars 352 forks source link

Fix watchOS preview build issue #380

Closed sergeirr closed 1 year ago

sergeirr commented 1 year ago

For some reason Xcode watchOS SwiftUI preview attempts to build this package against watchOS SDK. Fixed by adding os type check. Tested with:

Fixes #111

sergeirr commented 1 year ago

Additional description: https://developer.apple.com/forums/thread/731732

davdroman commented 1 year ago

Thanks for your PR.

Is there any way we could add a CI check to make sure this doesn't break with future iterations?

sergeirr commented 1 year ago

I'm not sure about this. I don't know if it is possible to "Build to Preview" from the command line to reproduce the problem.

davdroman commented 1 year ago

Okay I'll look into this. I wouldn't want to merge without some assurance from CI. I'll try my best to get it sorted asap.

sergeirr commented 1 year ago

I see. Another workaround for developers is to temporary remove the iOS main app target from the watchOS scheme when you want to work with watchOS SwiftUI Previews. image

sergeirr commented 1 year ago

@davdroman You can mention me if you need some help with an example project to reproduce this.

davdroman commented 1 year ago

@sergeirr yes please, I'd certainly appreciate an example project.

sergeirr commented 1 year ago

@davdroman This is the project https://github.com/sergeirr/WatchOSIntrospect There are 2 branches (excluding main):

  1. With issue (added origin SwiftUIIntrospect package)
  2. Without issue (added forked by me SwiftUIIntrospect package)
davdroman commented 1 year ago

Thanks! This is very helpful to get going.