我一直在尝试很多方法来解决这个问题。我正在尝试使用谓词获取 SwiftData 记录。但我尝试的一切都会导致两个错误:
初始化程序“init(_:)”要求“Item”符合“Encodable”
初始化程序“init(_:)”要求“Item”符合“Decodable”
该错误来自扩展#Predicate宏内部。
这是一个简单的类来演示这个问题:
@Model
final class Item {
@Attribute(.unique) var id: String
var timestamp: Date
init(timestamp: Date) {
self.id = UUID().uuidString
self.timestamp = timestamp
}
}
Run Code Online (Sandbox Code Playgroud)
这是导致编译器问题的基本代码:
extension Item {
static func foo() {
let item = Item(timestamp: .now)
let pred = #Predicate<Item> { $0.id == item.id }
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试了很多方法来解决这个错误。我见过的 Apple SwiftData 示例项目都没有出现此错误。
我尝试过遵守Identifiable. 我已经重新命名了该id属性。我已将id类型更改为UUID直接而不是String.
当然,我添加了代码以符合Codable. 虽然这修复了编译器错误,但我最终遇到了运行时错误。请注意,Apple SwiftData 项目的模型均不符合Codable. …
有人经历过这个问题吗?每次我尝试在 App Store Connect 中向内部测试器添加新版本时,它都会显示一条错误消息:
“发生错误。请稍后重试。”

我尝试通过重新登录帐户、清除历史记录、创建新存档,然后尝试将其添加到内部测试程序来解决该问题。然而,问题仍然存在。
本月,苹果决定对 App Store Connect 中的游戏中心授权更加挑剔。在那之前,我们的应用程序在 Game Center 上运行得很好。但是,因此我们现在无法提交任何新的应用程序版本。
在 App Store Connect 中,我们在游戏中心部分收到警告:
要为您的应用程序启用 Game Center,您必须在 Xcode 中添加 com.apple.developer.game-center 权利
无论如何,如果我单击“添加到评论”按钮,我会收到以下错误消息:
无法添加以供审核
启动审核过程需要以下项目:
您必须在 Xcode 中添加 com.apple.developer.game-center 密钥。
错误很明显,唯一的问题是项目中的所有内容都已设置。
权利已包含com.apple.developer.game-center并设置为true

应用程序标识符已包含游戏中心功能
在签名和功能中,一切似乎都设置得很好:

我尝试在 Xcode 中以及通过更新的配置文件从 Apple Developer Portal 中禁用并重新启用该功能。问题依然存在。
该构建是通过 Xcode Cloud 使用 Xcode 14.3.1 进行的。
如果有人知道我可能缺少什么,请告诉我。
我尝试使用按钮将 ScrollView 设置为最顶部的元素。因此,新的.scrollPosition()修饰符应该会派上用场。我无法让它工作。在以下示例中,当单击堆栈底部的项目或按钮时,滚动将起作用。但滚动时该值不会更新。您可以通过滚动到底部、单击“滚动到顶部”按钮并向下滚动来重现该行为。第二次,什么也没有发生,因为值仍然是 1。我做错了什么,还是我对修饰符的期望错误?文档是这样说的: https://developer.apple.com/documentation/swiftui/view/scrollposition(id:anchor:)
//\n// ContentView.swift\n// Test\n//\n// Created by Sebastian G\xc3\xb6tte on 23.09.23.\n//\n\nimport SwiftUI\n\nstruct ContentView: View {\n \n @State private var scrollViewPosition: Int?\n \n var body: some View {\n ScrollView(.vertical) {\n VStack(spacing: 32) {\n ForEach(1..<21) { item in\n Text("I am item no. \\(item)")\n .id(item)\n \n .frame(maxWidth: .infinity)\n .padding()\n .background(.purple)\n .cornerRadius(4)\n \n .onTapGesture {\n withAnimation {\n scrollViewPosition = item\n }\n }\n }\n \n Button("Scroll to top", action: {\n withAnimation {\n scrollViewPosition = 1\n }\n })\n }\n .scrollTargetLayout()\n …Run Code Online (Sandbox Code Playgroud) 当我使用 Xcode 14 时,我没有遇到任何警告。然而,更新到 Xcode 15 后,我突然开始收到来自第三方库的 200 多个警告。有谁知道这样做的原因或如何解决这些警告而不必等待库更新?这些警告似乎与库中 Objective-C 的使用有关。
类似这样的警告:
Mixed ObjC ABI, /Users/wanghong/Developer/alpaca/Pods/AppsFlyerFramework/iOS/AppsFlyerLib.framework/Versions/A/AppsFlyerLib[x86_64][26](AppsFlyerAES128Crypto.o) compiled with category class properties
请原谅看到此内容的人——我是一名新开发人员,无法理解我在这里缺少的内容。当我为 iPhone 构建包含 AdMob 广告的 Xcode 工作区时,出现以下错误:
沙箱:rsync(1900)拒绝(1)文件读取数据/Users/philiplattanzio/Library/Developer/Xcode/DerivedData/TigerRun-gexhklhksmplmfagqcwbsfjmflme/Build/Products/Debug-iphoneos/XCFrameworkIntermediates/GoogleUserMessagingPlatform/UserMessagingPlatform.framework/Headers
我相信我已经安装了适当的框架。我不知道如何解决这个问题。
我重新安装了 pods 和 google swift 包管理器。我更新了 AdMob 上的隐私政策(不确定这是否有影响)
为了从工作线程打印到 UIPrinter(我已保存其 URL),我正在执行此操作并能够打印:
func PrintPdfDocument (pDocument:Data)
{
// Create a print interaction controller
let printController = UIPrintInteractionController.shared
// Set the printing options
let printInfo = UIPrintInfo(dictionary:nil)
printInfo.jobName = "Print Job "
printController.printInfo = printInfo
printController.showsPageRange = true
// Set the PDF document to be printed
printController.printingItems = pDocument
printController.print(to: defaulttprinter, completionHandler: { (controller, completed, error) in
if completed {
print("Printing successful!")
} else {
if let error = error {
print("Printing failed with error: \(error.localizedDescription)")
} else {
print("Printing was …Run Code Online (Sandbox Code Playgroud) 我只是在寻找 swift 中高阶函数的内部实现,例如 map、filter、reduce。
根据苹果文档。
@inlinable public func map(_transform: (Element) throws -> T) re throws -> [T]
返回一个数组,其中包含将给定闭包映射到序列元素的结果。
例如;
var arr = [1,2,3,4,5]
print(arr.map({$0*5}))
Run Code Online (Sandbox Code Playgroud)
输出将是
[5,10,15,20,25];
或者
print(arr.map({String($0)}))
Run Code Online (Sandbox Code Playgroud)
我只是想知道这里的计算基本上是如何工作的或者更高阶的内部工作原理。您能否在这里帮助我,了解映射在这里如何工作,例如如何处理值(相乘或转换为字符串)。
我正在使用 Mac Catalyst 开发一个应用程序。
当用户关闭 Mac 版本上的窗口时,应用程序将终止。
可以通过使用以下方法来改变 Cocoa 中的这种行为:
applicationShouldTerminateAfterLastWindowClosed
Run Code Online (Sandbox Code Playgroud)
方法或通过在 plist 文件中将 NSSupportsAutomaticTermination 设置为 NO 。
如何在 Mac Catalyst 应用程序中获得相同的效果?
我从 Mac 中删除了一个旧项目,现在在我当前的项目中,该项目与旧项目没有任何联系,我收到一条消息:
error: the replacement path doesn't exist: "/path/to/old/project"
Run Code Online (Sandbox Code Playgroud)
当我在我的ios设备上运行时。
ios ×4
swift ×4
xcode ×4
airprint ×1
build-error ×1
dictionary ×1
game-center ×1
mac-catalyst ×1
predicate ×1
swift-data ×1
swiftui ×1
testflight ×1
uikit ×1
xcode15 ×1