MobileNativeFoundation / rules_xcodeproj

Bazel rules for generating Xcode projects.
MIT License
502 stars 76 forks source link

Feature Request: A section in `usage.md` on how to enable Xcode Previews #1450

Open brentleyjones opened 1 year ago

brentleyjones commented 1 year ago

This is the top search in our repo, and it's not always clear how to enable previews for swift_library targets.

joprice commented 6 months ago

I've gone through some of the issues referencing this and checked out the "integration" example but can't seem to figure out how to get this to work. In lieu of a longer doc, could you write a few sentences here on the recommended approach? I've tried wrapping swift_library's in ios_framework, but I get linker errors and can't seem to find a setup that pleases xcode.

thiagohmcruz commented 6 months ago

Checked examples/integration in the latest main (28931c024335ac5d90b9fb4ddebf0fbce42eed9c) and it's indeed broken during linking (LibFramework.iOS not found via rpath). I was trying to run the preview from this source: https://github.com/MobileNativeFoundation/rules_xcodeproj/blob/28931c024335ac5d90b9fb4ddebf0fbce42eed9c/examples/integration/UI/ContentView.swift.

Noticed that if I stop un-focusing that target the preview works as expected though.

The above is for examples/integration, so non-rules_ios. Specifically for rules_ios users one option is to flip link_dynamic like I described here: https://github.com/MobileNativeFoundation/rules_xcodeproj/issues/2612#issuecomment-1832730815

If you could verify if the above for examples/integration also works for you @joprice that would be great. Happy to add a blurb in usage.md (for both use cases) once we're able to root cause the issue above.

joprice commented 5 months ago

@thiagohmcruz I haven't had time to test this, but just found that the new incremental generation might fix my issue https://github.com/MobileNativeFoundation/rules_xcodeproj/issues/1384. I'm testing that now, so this workaround might not apply for my case after that.