Lockscreen widget not available in widgets list on iOS device - ios

I've developed a lock screen widget for the Flutter application using SwiftUI. The widget is working on the iOS simulator. However, when I'm uploading the app to Test Flight and after installing an app to the real device try to add a widget to the lock screen but the widget is missing from the widgets list.
From my research I found below solution and tried still issue is not resolved.
https://developer.apple.com/forums/thread/655393
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".
Am I missing something? Any help will be appreciated. Thanks in advance.

I had a some problem but fortunately I've realized that I'm using a WidgetBundle and after including the new widget in that bundle, it was available in the list.
Update: here's a source code for the bundle:
#main
struct MyWidgets: WidgetBundle {
var body: some Widget {
AWidget()
BWidget()
if #available(iOSApplicationExtension 16.0, *) {
LockScreenWidget()
}
}
}
Essentially if you have multiple widgets, they need to be included in a bundle.

Related

My widget doesn't seem to install onto my Xcode 12 simulator

I have a SwiftUI iOS app that builds and runs perfectly on the Xcode Simulator. I'm trying to create a widget for my app. I create a new Widget Extension target successfully, and without modifying any of the stock template code, I try to run my extension target.
The widget extension builds successfully, and Xcode tells me the extension is running, but no widget appears in my simulator. I checked the "add widget" list and it isn't there either.
I've tried making a widget without having the "Include Configuration Intent" checked, I've made sure that I'm running my app and widget extension on the same device (and I've tried different devices, iPhone 11, iPhone 12, etc.), I've tried uninstalling the app and rebuilding the project... I'm not sure what I'm missing here!
Any help would be greatly appreciated.
I'm on a late 2013 MacBook Pro, running MacOS Big Sur 11.5.2, and using XCode 12.5.1. I am not a paying Apple Developer member (if that makes a difference). I'm sorry if I'm leaving some important information out, I didn't know what to include so please let me know if you have any questions.
Thanks so much for your help in advance!
Go to your mainTarget > Build Phases.
Under Embed App Extensions, uncheck "Copy only when installing"
The thing is, you want to see your widget getting copied over in all sessions, not just for the Production Profile.
Build again and you should see your widget now.
Fixed! I did some poking and tried to run the preview canvas for my widget file, it gave me an error saying the preview couldn't be rendered.
Googled it up, found this answer and rebuilt and ran the widget extension again. It still gave this error, so I rebooted the iPhone simulator and voila! It works!
Thanks for the help, hope this helps someone down the road...

“Unable to Load” message in Today's Widget in iOS 11

On all my test devices and simulators running iOS 11 my widgets failing to load. Just a message in the center "Unable to load". Not visible "Show more"/"Show less" also. Cannot open the app when tap on the widget.
On all iOS 10.x.x devices/simulators everything is fine.
Tried restart devices, delete app and install again from the App Store. Tried remove widget and add again. Tried with new build of the app using last Xcode (9.0), without success.
Any assumptions?
Finally I found the reason..
Here Apple Developer Guide I found this for the widget's plist.file:
"If you don’t want to use the storyboard file provided by the template, remove the NSExtensionMainStoryboard key and add the NSExtensionPrincipalClass key, using the name of your view controller for the value."
So, when I remove NSExtensionMainStoryboard key, works in iOS 11, no "Unable to load" message, the widget looks good, when tap on the widget, my app starts.

iOS widget extension works from xcode but not when archived

If i run the extension or app from xcode, they both work fine, but if i archive, create an IPA file and install it via itunes, then the widget is always "Unable to load" (but the app itself still works fine).
I noticed that if i turn "always embed swift standard libraries" on for the widget target, then the widget installed with the IPA does work fine. BUT doing this means you can't submit it to the app store ("The bundle at … contains disallowed file 'Frameworks'")
Any ideas on how to find the problem? I can't see how the widget is crashing because it doesn't crash in xcode
I think i solved this thanks to step 3 on this answer: https://stackoverflow.com/a/29821624/160149
I had to add "#executable_path/../../Frameworks" to Runpath searchpaths in the extension target

Apple watch simulator issue

I am trying to debug and run the app on apple watch simulator. I have tried by using different target for notification, Glance and Watch app but apple simulator don't shows any thing.. It stuck in waiting for attach process of extension. I just see a black screen for the Apple Watch Simulator.
What did I do wrong?
How to overcome this issue ?
This post from the dev forums solved my issue. More specifically, this excerpt:
In order for Watch apps to function properly, certain properties
must match across the Watch app and its App Extension (18857540):
The WKAppBundleIdentifier property of NSExtensionAttributes in the WatchKit App Extension’s Info.plist must match the
CFBundleIdentifier of WatchKit App's Info.plist.
The WKCompanionAppBundleIdentifier property of the WatchKit App's Info.plist must match the CFBundleIdentifier of the Containing iOS App's Info.plist.
I have exactly same problem. I created a new project and added WatchKit extension in Xcode 6.2 beta 4 with WatchKit. I tried all ways mentioned in other answers but still failed to let watch app run in the simulator. Finally, I made it work.
My steps:
Delete the containing app in the iPhone simulator.
Clean your project in Xcode.
Do not run the containing app, run the WatchKit app from Xcode.
I had the same issue. The only thing that helped was to delete and recreate the target scheme.
Before spending a lot of time on changing things, restart Xcode. Sometimes, this solves the problem.
Even if everything is configured correctly, it may take 20 seconds to attach the process to the debugger.
You need to run the Watch App target and then from iPhone/iPad simulator check (Hardware -> External displays), any one of the Apple Watch options.
I was experiencing the same issue. Mainly when creating an app extension in an existing app.
I was able to consistenly solve it by doing the following steps:
Make sure that the app extension gets the .appex extension. XCode tends to set it to .app. You can do this under 'build settings' -> 'wrapper'.
Under the 'Build Phases' tab in your target, your app extension should be listed under 'Embed App Extensions'. If you don't see this section, you can enforce it by adding a normal app extension to your app (fe. action extension). The section will now be visible. Replace the dummy extension you just created with the Watch app extension.
Start the host app and then start the Watch app, it should be working now.
I had some trouble on iPhone 6 simulator, but each time I switch on iPhone5S it works.
In my case the trouble was caused by a scheme with missing target although not the one I was trying to run.
Hope that helps somebody.
I was running into this problem as well and tried a few of the suggestions above. I found that deleting and recreating the target scheme resolved it. Everything is working fine now.

iOS 8 Today Extension not working on device

When I run my Today Extension on the simulator everything works fine and it displays the following as expected:
However when I run it on my devices (iPod touch and iPhone 5s) the body won't show (don't mind the title and icon, that was changed)
I attached the debugger to my extension and I got this:
I have no idea what all of this means...
I removed all code for the Today Extension to check if there was a problem with my code and nothing changed so I doubt theres a problem with my code. Any suggestions on how to fix this would be greatly appreciated.
(I do have app groups enabled if thats of any significance)
Make sure extension target version
Please make sure your extension target version is correct. Xcode'd give you the highest version by default such as 8.3, and if your iOS version is lower than it, Xcode'd give your a crash.
I found out that I was accessing my app group with the wrong suitename. Just make sure you access the app group with "group.something.something" not just "something.something"
I found the solution for my case. I just had to specify arm64 as valid architecture for the widget target.
On the Widget Target
Build Settings > Valid Architectures
I was having just armv7 and armv7s. I added arm64 and it worked like charm in my 5s device
Few points to remember while using app extensions
Bundle Identifier for the target extension should be com.companyName.AppName.ExtensionName
You need to have separate AppID for the target extension, with identifier specified as com.companyName.AppName.ExtensionName and create provisioning profile with this AppID.
Also, the appGroupID created should be embedded in both the AppIDs(for application as well as extension).
Since you didn't share any piece of code, I cannot help you with a specific answer. Please try to debug your widget by using following steps Debug->Attach to Process->(select your widget from the menu) and debug your viewdidload viewwillappear and - (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler methods. Hope it helps.
The sources of my problems:
on simulator viewDidLoad was called each time, on the device the view is loaded once and only viewWillAppear is called.
the widget does not receive core data changes notifications
do not call NCWidgetController.widgetController().setHasContent from widgetPerformUpdateWithCompletionHandler. The best place to use it (mostly) is your containing app, not the widget itself.
hope this helps someone
In my case I set preferred content size and it is starting working on device
self.preferredContentSize = CGSizeMake(UIScreen.mainScreen().nativeBounds.width, 100.0)
I had an issue using custom ViewController in my Share Extension. It turns out that the resources are limited in Extension mini-apps, so when my Extension was generating thumbnails, it crashed the extension because too many background threads were being used. Reducing thumbnail generation to a single one at a time fixed the issue.
The confusing part was that this limitation was not seen in Simulator, only on a real device.

Resources