Quantcast
Channel: Active questions tagged cocoapods - Stack Overflow
Viewing all articles
Browse latest Browse all 1029

"No candidates found to host preview" error when iOS Widget Extension file is not in the main project

$
0
0

I'm trying to export an iOS Widget Extension as a CocoaPods library. Since adding a widget extension requires a target, I should create the target manually in the host project, then transfer the widget files to the repository. Therefore, the library will just vend raw files and not act as an extension.

First question: Am I right? Is there a way to save the whole extension in the repository?

Now the Podfile is:

target 'Example' do  use_frameworks!  # I need to create a `MyWidget` widget first  target 'MyWidgetExtension' do    inherit! :search_paths    pod 'WidgetIOSSDK', :path => '../'  endend

In the widget entry point (MyWidgetBundle.swift), I use the widget from the library:

import WidgetIOSSDK@mainstruct MyWidgetBundle: WidgetBundle {    var body: some Widget {        MyWidget2()    }}

Build and run, the widget appears on the desktop. Then here is question 2:

  1. I can't preview the SwiftUI if the file is not in the host project. (picture 1 below)
  2. Even if in the host project I create a blank SwiftUI file and in the preview section I use the view from the pod library, it doesn't work either.(picture 2 below)

Is there a way to preview in other location?

error: No candidates found to host previewpicture 1

error: MyWidgetExtension may have crashedpicture 2


Viewing all articles
Browse latest Browse all 1029

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>