Using Xcode 12 create a new Swift Package
Add a simple view with a preview to that swift package (See code below)
Attempt to run the preview.
See errors
Code:
Code Block #if os(iOS) import SwiftUI @available(iOS 14.0, *) public struct TestView: View { public init() { } public var body: some View { Text("Hello World") } } @available(iOS 14.0, *) struct NoDataView_Previews: PreviewProvider { static var previews: some View { TestView() } } #endif
Error:
Code Block Build input file cannot be found:...TestPackagePreview.o' (in targ SchemeBuildError: Failed to build the scheme "TestPackagePreview" Build input file cannot be found: ...TestPackagePreview.o' (in target 'TestPackagePreviewTests' from project 'TestPackagePreview' Link TestPackagePreviewTests (x86_64): error: Build input file cannot be found: ...TestPackagePreview.o' (in target 'TestPackagePreviewTests' from project 'TestPackagePreview')
Note I have added "..." in file paths for privacy reasons
Create a new swift package
Delete the auto generated struct that will be the name of your swift package
Remove the unit test associated with the auto generated struct
Edit the package.swift file to include the platform (example below: iOS)
Ensure you have the schema selected and the correct device selected for the preview you want. (Ex: iPhone selected for iOS)
Code Block platforms: [ .iOS(.v13) ],