Widgets not working with TestFlight since Xcode 12 beta 3

I have noticed a strange problem today. I have uploaded a build of my app to TestFlight for internal testing using Xcode 12 beta 3. The app has widgets and if I run the app locally from Xcode widgets are working on device.

However, when I install a beta from TestFlight the widgets are not suggested by iOS and I can see in the logs that the widgets are actually crashing (something is going on with WidgetKit in the crash logs).

This has started only with beta 3, I have previously used TestFlight with widgets in beta 1 and beta 2.

Does anyone else have this problem? My feedback number is FB8122742.
Answered by Mr. Brightside in 625976022
Ok, here is the solution to this problem.
  1. Make sure that you use Xcode 12 beta 4 and iOS 14 beta 4 on your devices.

  2. Make sure that you have placeholder(in:) implemented. Make sure that you don't have placeholder(with:) because that's what the previous beta of Xcode was suggesting with autocompletion and without that you won't get your placeholder working. I think this whole problem is caused by the WidgetKit methods getting renamed but that's another story.

  3. As per the release notes, you need to set "Dead Code Stripping" to NO in your extension target's build settings. This is only necessary for the extension's target. When uploading your archive to the App Store Connect, uncheck "Include bitcode for iOS content".

  4. Delete your old build from a device when installing a new beta.

That should do the trick.

I tried removing Dead Code Stripping but I'm still not able to access my widgets after installing through TestFlight with Beta 3. They work fine when running from Xcode.
Has anyone tried Xcode beta 4 yet to see if it fixes the problem? The release code does not say anything about this problem. I'm downloading now.
Here in the release notes for beta 4 the issue is referenced...but I've tried these work around and they did not work via TestFlight.

https://developer.apple.com/documentation/xcode-release-notes/xcode-12-beta-release-notes/?id=swift


Swift
Known Issues
Widgets may crash when built for release. (65862827) Workaround: Set DEADCODESTRIPPING to NO in the extension target’s build settings. When you upload the application to App Store Connect, also unset “Include bitcode for iOS content” in the App Store Connect distribution options.






I just tried Xcode beta 4 and the issue is NOT resolved.
Right Xcode beta 4 still has the problem.

I discovered that to reproduce the problem you don't even need to submit through TestFlight. Just building in Xcode as release (vs debug) causes widgets to disappear.

I have also tried the "dead-code stripping" settings in "build settings" for the target and changing that does not fix the problem either. Given that HomeWidgets is an important feature of iOS 14, it's strange that Apple has not tested this once and even stranger that after filing bug reports against beta 3, they still have not fixed the problem in beta 4.
Yeah it's pretty annoying. I'm trying to get a new build of my app up on TestFlight but I'm currently stuck.
Has anyone been able to successfully to get a working widget through TestFlight when uploading with xcode beta 3 or 4?

I've tried Apple's suggested workaround by changing dead-code settings and unsetting “Include bitcode for iOS content” in the App Store Connect distribution options with no luck.
After updating to iOS Beta 4, it seems the widgets are now appearing again (at least with the build I have with dead-code stripping and unchecking including the iOS Bitcode)
@khuffie do you mean the HomeWidget appears when you distribute through TestFlight? Multiple people have reported that they don’t (including myself). Widgets don’t even appear when you create a release build.
@RawMean I can confirm that with Xcode 12, beta 4, the following worked for me:
  • Set DEAD_CODE_STRIPPING to NO

  • Disabled bitcode when uploading to AppStore Connect

  • Installed on iPhone 11 running Public Beta 3 (via TestFlight)

Widgets appeared and looked appropriate in the widget picker interface, but appeared black when installing to home screen. Restarting the device resolved the issue, and the widgets now work.


Accepted Answer
Ok, here is the solution to this problem.
  1. Make sure that you use Xcode 12 beta 4 and iOS 14 beta 4 on your devices.

  2. Make sure that you have placeholder(in:) implemented. Make sure that you don't have placeholder(with:) because that's what the previous beta of Xcode was suggesting with autocompletion and without that you won't get your placeholder working. I think this whole problem is caused by the WidgetKit methods getting renamed but that's another story.

  3. As per the release notes, you need to set "Dead Code Stripping" to NO in your extension target's build settings. This is only necessary for the extension's target. When uploading your archive to the App Store Connect, uncheck "Include bitcode for iOS content".

  4. Delete your old build from a device when installing a new beta.

That should do the trick.

I only see the answer after post this comment, so forget about this.



Using Xcode 12 beta 5, still having this issue: Widget works locally on a device from Xcode but not after I distribute it through TestFlight, it just disappeared. Any ideas?

Below is my codes:
Code Block swift
struct Provider: IntentTimelineProvider {
  typealias Entry = ScreenTimeEntry
  typealias Intent = ConfigurationIntent
  func placeholder(with: Context) -> ScreenTimeEntry {
    let entry = ScreenTimeEntry.sample
    return entry
  }
  public func snapshot(for configuration: ConfigurationIntent, with context: Context, completion: @escaping (ScreenTimeEntry) -> ()) {
    let entry = ScreenTimeEntry(date: Date(), configuration: configuration)
    completion(entry)
  }
  public func timeline(for configuration: ConfigurationIntent, with context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
    let currentDate = Date()
    let entries: [ScreenTimeEntry] = [
      ScreenTimeEntry(date: currentDate, configuration: configuration)
    ]
    let timeline = Timeline(entries: entries, policy: .atEnd)
    completion(timeline)
  }
}


Restart the device and you will see widget again. Just restart it and we don't need to do anything.
I'm having this issue with Xcode 12.2 again.
Widget in Testflight build can not work for some devices (14.2.x).

The two issues "Dead Code Stripping", and disable "Bitcode" were solved by Apple and mentioned in Xcode 12 release note.
But I'm not sure if Xcode 12.x has the issue again, or just an iOS version bug?

(Reboot the phone make Widget works again, but got down after awhile again)
Found this thread after having issues with my widgets in TestFlight as well. Is the solution in this thread also required for publishing to the App Store? Our only for test flight?
Widgets not working with TestFlight since Xcode 12 beta 3
 
 
Q