Hello,
I am currently encountering an issue where SwiftUI View Previews cannot be displayed when the View is defined in a Static Framework target. This issue only occurs under specific conditions.
Environment
-
Xcode: 16.2
-
Scheme Structure:
-
MainApp
-
Test Target: TestHogeFeature
-
Test Setting:
- Gather coverage (Code coverage collection) enabled(all)
-
-
-
Target Structure:
-
MainApp (Application target)
- Dependencies: [HogeFeature, Core]
-
HogeFeature (Static Framework target)
- Dependencies: [Core]
-
Core (Framework target)
- Dependencies: None
-
TestHogeFeature (Unit test target)
- Dependencies: [HogeFeature]
-
Summary
I am currently working on a SwiftUI-based project and have encountered an issue where Previews fail to display under specific conditions. Below are the details:
Issue
In the MainApp scheme, when the code coverage collection setting (Gather coverage for) is enabled, Previews for SwiftUI Views within the HogeFeature (Static Framework) target fail to display correctly. However, the issue is resolved by taking one of the following actions:
- Change HogeFeature from a Static Framework to a Dynamic Framework.
- Remove the build setting
MACH_O_TYPE: staticlib
- Remove the build setting
- Disable the Gather coverage setting in the MainApp scheme.
I have attached the actual error log from the failed Preview.
Questions
- Why does this issue occur only when using a Static Framework with code coverage enabled?
- Is there any way to resolve this issue while maintaining the current configuration (Static Framework with code coverage enabled)?
I would appreciate any advice or insights regarding the cause and potential solutions.