iOS应用移除systemMedium组件家族后仍报错的问题求助
问题背景
之前调试Widget组件时添加了.systemMedium尺寸类型,后续因效果不佳从三处移除相关配置:
- PreviewProvider结构体仅保留
.systemSmall - Widget结构体设置
supportedFamilies([.systemSmall]) - WidgetEntryView不再引用
.systemMedium类型
但构建部署应用时Xcode仍报错,删除应用重装后问题依旧,错误信息如下:
"Request widget family (systemMedium) is not supported by this widget kind" SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show Widget 'com.test.Weather-Widget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open \"com.apple.springboard\" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x48c01a880 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=3 "**Request widget family (systemMedium) is not supported by this widget kind** (Weather_Widget)" UserInfo={NSLocalizedDescription=Request widget family (systemMedium) is not supported by this widget kind (Weather_Widget)}},
排查方向
检查Widget Extension的Info.plist
Xcode有时会自动在Info.plist中生成Widget尺寸配置。打开WidgetExtension目标的Info.plist,找到NSExtension -> NSExtensionAttributes -> ISNWidgetFamily键,确认是否仍包含systemMedium,如果有则删除,仅保留systemSmall。清理Xcode缓存与构建目录
仅删除App无法清理Xcode的缓存残留。按Cmd+Shift+K清理当前项目的构建目录,再手动删除~/Library/Developer/Xcode/DerivedData下对应项目的缓存文件夹,重启Xcode后重新构建部署。检查Widget调试启动参数
如果之前通过Xcode直接运行Widget目标调试,可能启动参数中仍指定了systemMedium。进入Edit Scheme -> Run -> Arguments,查看是否存在-widgetFamily systemMedium的参数,如有则删除或修改为systemSmall。确认是否存在多Widget Target
若项目内有多个Widget Extension目标,检查其他目标的配置是否残留systemMedium,同时确认部署时是否选择了正确的Widget目标。
内容的提问来源于stack exchange,提问作者Craig

