用于后台任务的 WatchOS 代码需要WKExtention.shared().delegate将 设置为self,但现在显示一条错误消息:
无法分配给属性:“delegate”是一个只能获取的属性
如果我删除该行,则在触发后台任务时我不会收到更新,因为我以前可以接收。
我上下查看了 StackOverflow 以及 Google 和 Apple 文档,但找不到答案。为什么该行在以前工作正常时现在显示错误。
创建一个新的 WatchKit 应用程序并InterfaceControllerVC.swift
添加WKExtensionDelegate到类中,然后:
override func awake(withContext context: Any?) {
super.awake(withContext: context)
WKExtension.shared().delegate = self
}
Run Code Online (Sandbox Code Playgroud)
线路:
WKExtension.shared().delegate = self
Run Code Online (Sandbox Code Playgroud)
被标记为红色并显示错误为:
无法分配给属性:“delegate”是一个只能获取的属性
I made a mistake by opening my project in a new beta version of xcode
Now I can not open it with a stable version because
The document “Main.storyboard” requires at least Xcode 11.0.
This version does not support iOS 13.0 system colors. Open this document with at least Xcode 11.0.
Run Code Online (Sandbox Code Playgroud)
On Saturday, I planned to publish the application. and it can not be published with the beta versions.
I need to run the application on the standard version of …
我正在尝试创建由 make dist 构建的 j2objc 的 xcframework。
推测那些 .a 文件被编译为胖库,但由于使用 xCode11 编译时出现编译错误而使用 xCode10 构建。
我的构建环境是 xCode11 beta 2 和 MacOS 10.5 beta。
$ xcodebuild -create-xcframework -library ./lib/libjre_emul.a -library ./lib/macosx/libjre_emul.a -headers ./include/ -output lib/universal/libjre_emul.xcframework
error: binaries with multiple platforms are not supported './j2objc/dist/lib/libjre_emul.a'
Run Code Online (Sandbox Code Playgroud) 考虑以下代码片段
class A {
var value: Int?
}
let a: A? = A()
let kp = \A.value
a?[keyPath: kp] = 10
print(a?.value)
Run Code Online (Sandbox Code Playgroud)
这完美地工作Optional(10)并按预期打印。在我的实际应用程序中,我试图以这种方式设置的字段被声明为Date?,它会导致一些奇怪的错误。我的实际应用程序的 MWE 是这样的:
class A {
var value: Date?
}
let a: A! = A()
let kp = \A.value
a?[keyPath: kp] = Date() // Line with error
print(a?.value)
Run Code Online (Sandbox Code Playgroud)
然而,编译器抱怨突出显示的行并说:
可选类型“日期?”的值 必须解包为“日期”类型的值
修复:使用“??”合并 当可选值包含“nil”时提供默认值
修复:使用 '!' 强制解包 如果可选值包含“nil”则中止执行
这是编译器的错误,我们可以期望在最终版本之前修复,还是我对关键路径不了解?
我正在使用 Xcode 11 beta 3,但我在 beta 2 中也遇到了同样的问题。如果它有用,实际代码在这里。
我的 iOS 项目出现以下错误,该项目在 Xcode 11.0 下运行良好,但在 Xcode 11.0 beta 中,出现以下错误。
[_UIRemoteKeyboards 代理]_block_invoke 无法访问远程服务:错误域=NSCocoaErrorDomain 代码=4097“连接到名为 com.apple.UIKit.KeyboardManagement.hosted 的 pid 0 上的服务” UserInfo={NSDebugDescription=连接到名为 com 的 pid 0 上的服务。 apple.UIKit.KeyboardManagement.hosted}
谁能帮我解决这个问题?
测试我的应用程序的Xcode 11(测试版)用于iOS的-13(测试版)的更新,我就当我试图从故事板实例的viewController越来越崩溃。
在以前的版本中,可以使用以下代码正常工作:
XYZController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"IDENTIFIER"];
Run Code Online (Sandbox Code Playgroud)
现在,对于iOS 13,Apple引入了新方法,即
XYZController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"IDENTIFIER" creator:^__Kindof UIViewController *__Nullable(NSCoder *_Nonnull coder){
return [XYZController alloc] initWithCoder:coder];
}];
Run Code Online (Sandbox Code Playgroud)
在iOS-13中执行这两种方法都会导致崩溃。当崩溃显示在其他地方时。
这是我的崩溃报告。
由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:''从-traitCollection返回nil,这是不允许的。
我只是迁移使用CoreDate而不是简单的集合。我正在使用iOS13 beta 8和Xcode11 beta 6。
struct BeaconList: View {
@Environment(\.managedObjectContext) var managedObjectContext
@FetchRequest(fetchRequest: fetchRequest(), animation: nil) var beacons: FetchedResults<Beacon>
static func fetchRequest() -> NSFetchRequest<Beacon> {
let request: NSFetchRequest<Beacon> = Beacon.fetchRequest()
request.sortDescriptors = [NSSortDescriptor(key: "id", ascending: true)]
return request
}
func buildView(name: String, beacons: [Beacon]) -> AnyView {
return AnyView (
Section(header: Text(name)) {
ForEach(beacons) { beacon in
BeaconListEntry(beacon: beacon)
}
}
)
}
var body: some View {
TabView {
NavigationView {
List {
buildView(name: "MY BEACONS", beacons: beacons.filter { …Run Code Online (Sandbox Code Playgroud) iOS13不支持后台更新通知。这是操作系统级别的错误吗?当应用进入后台时,Xcode警告显示:
无法结束BackgroundTask:不存在标识符为1(0x1)的后台任务,或者它可能已经结束。中断UIApplicationEndBackgroundTaskError()进行调试。
自从我升级到Xcode 11以来,我开始的每个新项目(包括框架)都无法在项目第二次构建后进行编译。
例如,使用此命令包括SDL2:
#include <SDL2/SDL.h>
Run Code Online (Sandbox Code Playgroud)
将导致此错误:
'SDL2/SDL.h' file not found
Run Code Online (Sandbox Code Playgroud)
在第二次编译项目之后。
在Xcode 10中创建的项目在Xcode 11中可以正常使用。我尝试更改框架的嵌入选项,但没有任何设置。在所有Xcode 11版本(0-2.1)中都会发生此错误。我正在使用macOS版本10.14.6。
为什么会发生这种情况或如何解决?