Overview
On macOS when a user clicks on the date in a date picker field a pop up opens with options to select the date if the user taps on Esc key, then there is no option to select that field or any other field.
Feedback: FB11812450
Questions:
Am I missing something?
Is this a bug? (Feedback: FB11812450)
Steps to reproduce
Run the code (see below) on macOS
Click on the date portion of the date picker field
A pop up opens
Press the Esc key
Actual Behaviour
You can't select the date picker again to change the date.
Expected Behaviour
When the the escape key is pressed the popup should close and the date picker and other text fields should be selectable again.
Code
struct ContentView: View {
@State private var date = Date()
@State private var note = "hello world"
var body: some View {
VStack {
DatePicker("Birthday", selection: $date)
TextField("Note", text: $note)
}
}
}
Post
Replies
Boosts
Views
Activity
Hi,
When using NSPersistentCloudKitContainer lots of error / debug messages are shown in Xcode Debug area.
Feedback FB11794798:
Overview
When I use NSPersistentCloudKitContainer I get the following error / debug messages printed on the Xcode Debug Area.
Syncing seems to happen fine.
Tested on device and simulator.
I am still using Development (not deployed to Production yet)
I even tried with a new project using the default code generated for by enabling CloudKit coredata sync and I still get the same messages.
I have filed a feedback FB11794798
Steps to Reproduce
Create a new project check Use CoreData and Host in CloudKit check boxes
Run the project
Notice the error messages shown below.
Questions
How to resolve these errors?
Or is this a bug from the Apple Frameworks? (Feedback FB11794798)
Error / debug message printed on Xcode debug area
CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](36): Validating options: <NSCloudKitMirroringDelegateOptions: 0x600000760510> containerIdentifier:<MyContainerID> databaseScope:Private ckAssetThresholdBytes:<null> operationMemoryThresholdBytes:<null> useEncryptedStorage:NO useDeviceToDeviceEncryption:NO automaticallyDownloadFileBackedFutures:NO automaticallyScheduleImportAndExportOperations:YES skipCloudKitSetup:NO preserveLegacyRecordMetadataBehavior:NO useDaemon:YES apsConnectionMachServiceName:<null> containerProvider:<PFCloudKitContainerProvider: 0x600003764210> storeMonitorProvider:<PFCloudKitStoreMonitorProvider: 0x600003764220> metricsClient:<PFCloudKitMetricsClient: 0x600003764230> metadataPurger:<PFCloudKitMetadataPurger: 0x600003764240> scheduler:<null> notificationListener:<null> containerOptions:<null> defaultOperationConfiguration:<null> progressProvider:<NSPersistentCloudKitContainer: 0x60000205d200> test_useLegacySavePolicy:YES archivingUtilities:<PFCloudKitArchivingUtilities: 0x600003764250> bypassSchedulerActivityForInitialImport:NO
storeOptions: {
NSInferMappingModelAutomaticallyOption = 1;
NSMigratePersistentStoresAutomaticallyOption = 1;
NSPersistentCloudKitContainerOptionsKey = "<NSPersistentCloudKitContainerOptions: 0x600003b3a190>";
NSPersistentHistoryTrackingKey = 1;
NSPersistentStoreMirroringOptionsKey = {
NSPersistentStoreMirroringDelegateOptionKey = "<NSCloudKitMirroringDelegate: 0x600000c642a0>";
};
NSPersistentStoreRemoteChangeNotificationOptionKey = 1;
}
CoreData: debug: CoreData+CloudKit: -[NSCloudKitMirroringDelegate observeChangesForStore:inPersistentStoreCoordinator:](416): <NSCloudKitMirroringDelegate: 0x600000c642a0>: Observing store: <NSSQLCore: 0x14080aec0> (URL: file:///Users/<my home folder>/Library/Group%20Containers/group.<app name>/<filename>.sqlite)
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _setUpCloudKitIntegration](562): <NSCloudKitMirroringDelegate: 0x600000c642a0>: Successfully enqueued setup request.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest](3209): <NSCloudKitMirroringDelegate: 0x600000c642a0>: Checking for pending requests.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]_block_invoke(3222): <NSCloudKitMirroringDelegate: 0x600000c642a0>: Executing: <NSCloudKitMirroringDelegateSetupRequest: 0x600001643f20> D3975DD0-1198-40F2-9D6A-B9994B9710B6
CoreData: debug: CoreData+CloudKit: -[PFCloudKitMetadataModelMigrator calculateMigrationStepsWithConnection:error:](446): Skipping migration for 'ANSCKDATABASEMETADATA' because it already has a column named 'ZLASTFETCHDATE'
Overview
I have a swift package that I have added to the app target.
On the app extension (widget) target I have added the same package under Frameworks and Libraries.
I am able to archive successfully when I do it manually
When I start a build using Xcode Cloud I get the following errors:
Error:
An internal error was detected which caused this stage to error. The error has been logged, and you can re-run this build again.
Resolve package dependencies
Command exited with non-zero exit-code: 74
fatal: could not read Username for 'http://github.com': terminal prompts disabledan out-of-date resolved file was detected at /Volumes/workspace/repository/<app name>.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved, which is not allowed when automatic dependency resolution is disabled; please make sure to update the file to reflect the changes in dependencies. Running resolver because the following dependencies were added: '<package name>' (https://github.com/<user name>/<package name>.git)2022-11-11 01:21:37.643 xcodebuild[2273:9107] Writing error result bundle to /var/folders/hf/lmqg8qtx531_sq5gwgt5s3ch0000gn/T/ResultBundle_2022-11-11_01-21-0037.xcresult
Make sure that Package.resolved is up to date on the '<branch name>' branch, and that this branch has been pushed to your remote repository.
Save artifacts
Upload <app name> Build 16 Logs for <app name> archive
An internal error occurred while this artifact was being saved.
Questions:
Am I missing something?
How do I resolve this issue?
Is it because of a server issue?
Overview
On macOS, in a NavigationSplitView when the menu button is added to the detail view toolbar, it seems to look disabled
Environment
Xcode: 14.1 beta 3 (14B5033e)
macOS: 13.0 Beta (22A5365d)
Code:
struct ContentView: View {
@State private var selectedNumber: Int?
var body: some View {
NavigationSplitView {
List(0..<100, selection: $selectedNumber) { number in
Text("cell \(number)")
}
} detail: {
Text("Detail")
.toolbar {
ToolbarItem {
Menu {
Button("aa") {}
Button("bb") {}
} label: {
Label("Add Bookmark", systemImage: "book")
}
}
}
}
}
}
Steps to reproduce:
Run the project on macOS
Select cell 0 on the sidebar
Click on the book toolbar button and notice the menu appear
Select cell 1 on the sidebar
Expected Behaviour
After step 4, the book toolbar button should look prominent (like it is enabled)
Actual Behaviour
After step 4, the book toolbar button looks like it is disabled.
Screenshot
Hi,
I have an Xcode project that uses Xcode 14.0 beta 6 (14A5294g).
How to make Xcode Cloud compile code compiled in Xcode beta?
My code uses beta APIs that doesn't seem to compile on Xcode Cloud (throws compilation errors)
Am I missing something as this would be a common scenario for many developers?
How do I make the beta APIs compile on Xcode Cloud?
Overview
I have an existing Xcode project that works fine with Xcode Cloud
I have a separate branch on to which I have migrated and made changes for Xcode 14
On the same branch I have made some code changes that is supported by Swift 5.7
Example:
var price: Int? = 100
guard let price else {
return
}
Problem
Xcode code build fails with the error Variable binding in a condition requires an initializer
Question:
Is it possible to build Xcode Cloud on Swift 5.7 or Xcode 14?
Hi,
My lab appointment status is pending. The lab is for tomorrow.
When would I get to know if my lab appointment has been accepted.
It is my first time for a lab appointment, also I forgot to mention the feedback IDs, would there be a way to amend the request to include the feedback IDs if that would help. (Feedback assistant was down when I booked an appointment so couldn't get the feedback IDs.)
Any help would be much appreciated as I am from a different timezone and would need to plan accordingly .... really praying I get an appointment
Overview:
When running the demo code presented in "The SwiftUI cookbook for navigation" (https://developer.apple.com/wwdc22/10054) I ran into some issues:
Runtime warnings:
2022-06-08 22:20:31.587169+0800 NavigationSplitViewDemo[17797:672165] [SwiftUI] A NavigationLink is presenting a value of type “Category” but there is no matching navigation destination visible from the location of the link. The link cannot be activated.
onChange(of: UpdateTrigger) action tried to update multiple times per frame.
2022-06-08 22:15:23.432289+0800 NavigationSplitViewDemo[17645:662571] [UIFocus] _TtGC7SwiftUI14_UIHostingViewGVS_15ModifiedContentVS_7AnyViewVS_12RootModifier__ implements focusItemsInRect: - caching for linear focus movement is limited as long as this view is on screen.
Feedback filed:
FB10103041 and FB10104196
Aim
To use a keyboard shortcut on a Multiplatform app (iOS and macOS)
When keyboard shortcut is tapped, the price needs to be printed
Problem
The same code doesn't work on iPad but works on macOS
Question:
Why is not working?
How to fix this?
Environment
macOS Big Sur - 11.6 (20G165)
Version 13.0 (13A233)
Code
@main
struct TestApp: App {
@State private var price = 0
var body: some Scene {
WindowGroup {
ContentView(price: $price)
.focusedValue(\.price, $price)
}
.commands {
PriceCommands()
}
}
}
struct ContentView: View {
@Binding var price: Int
var body: some View {
IncreasePriceButton(price: $price)
}
}
struct IncreasePriceButton: View {
@Binding var price: Int
var body: some View {
Button("Increase Price") {
price += 1
print("price = \(price)")
}
}
}
struct PriceCommandButton: View {
@FocusedBinding(\.price) var price
var body: some View {
Button("Print Price") {
print("price = \(price)")
}
}
}
struct PriceCommands: Commands {
var body: some Commands {
CommandMenu("Custom") {
PriceCommandButton()
.keyboardShortcut(KeyboardShortcut("C", modifiers: [.command, .shift]))
}
}
}
struct FocusedPriceKey: FocusedValueKey {
typealias Value = Binding<Int>
}
extension FocusedValues {
var price: FocusedPriceKey.Value? {
get { self[FocusedPriceKey.self] }
set { self[FocusedPriceKey.self] = newValue }
}
}
I am a bit confused about tasks being cancelled.
Overview:
checkCancellation function has 2 child tasks: computeA and computeB that run concurrently,
computeB throws an error.
Doubt:
I expected child task computeA to be cancelled because computeB threw an error, but computeA was never cancelled.
Is my understanding wrong or am I missing something?
Or is this a bug?
Note:
I am using a SwiftUI project (as Swift Playgrounds don't support async let)
macOS Big Sur 11.5.2 (20G95)
Xcode Version 13.0 beta 5 (13A5212g)
Output:
A - started
B - going to throw
A - going to return, Task.isCancelled = false
error: infinity
Concurrent Function Definitions:
import Foundation
import UIKit
enum ComputationError: Error {
case infinity
}
fileprivate func computeA() async throws -> Int {
print("A - started")
await Task.sleep(2 * 100_000_000)
print("A - going to return, Task.isCancelled = \(Task.isCancelled)") //I expected Task.isCancelled to be true
return 25
}
fileprivate func computeB() async throws -> Int {
print("B - going to throw")
throw ComputationError.infinity
}
func checkCancellation() async throws {
async let a = computeA()
async let b = computeB()
let c = try await a + b
print("c = \(c)")
}
Invoking Concurrent function
struct ContentView: View {
var body: some View {
Button("check cancellation") {
Task {
do {
try await checkCancellation()
print("normal exit")
} catch {
print("error: \(error)")
}
}
}
}
}
Aim
I would like to display an alert, when the user dismisses the alert the next alert should be displayed.
If the user doesn't dismiss the first alert, the 2nd alert should wait till the user dismisses the first alert
Functionality like back pressure.
My Attempt:
Given below is code where I have attempted to do it based on an @ObservedObject and @Published property.
Problem:
Alerts are displayed but they don't wait for the alert to be dismissed.
Code:
ContentView:
import SwiftUI
struct ContentView: View {
@ObservedObject var model = Model()
var body: some View {
Text("Hello World!")
.alert(item: $model.employee, content: makeAlert(forEmployee:))
}
private func makeAlert(forEmployee employee: Employee) -> Alert {
let dismissButton = Alert.Button.cancel((Text("Ok")))
return Alert(title: Text("New Employee"),
message: Text(employee.name),
dismissButton: dismissButton)
}
}
Model:
import Foundation
class Model : ObservableObject {
@Published var employee : Employee?
private var index = 0
private lazy var timer = {
Timer.scheduledTimer(withTimeInterval: 3, repeats: true) { [weak self] timer in
self?.createNewEmployee()
print("fired for \(self?.employee?.name ?? "none")")
}
}()
init() {
timer.fire()
}
func createNewEmployee() {
guard let unicodeScalar = UnicodeScalar(index + 65) else {
return
}
let name = String(Character(unicodeScalar))
employee = Employee(id: index,
name: name)
index += 1
}
}
Employee:
import Foundation
class Employee : Identifiable {
var id : Int
var name : String
init(id: Int, name: String) {
self.id = id
self.name = name
}
}
What I had done:I enabled full screen mode on the simulator so I executed the following command:defaults write com.apple.iphonesimulator AllowFullscreenMode -bool YESQuestion:How can I remove this rectangular bar shown in the image (so that it is like the default setting when xcode is installed)?I have tried the following without any success:Executed the above command with a NODeleted /Users/<Username>/Library/Preferences/com.apple.iphonesimulator.plistCreated a new Mac UserDeleted Xcode and installed it again
Overview:I have a class called Player and a class called Song.Player contains a SongA view is showing the song titleAim:When I change the player.song.title, the view needs to be updated.
Problem:When the song's attributes changes, it wouldn't update the view automatically. Only when a new song is assigned will the changes be reflected.My Attempts:I have made 2 attempts (code below), both work as expected.Questions:Is there a better way to do it ? (It seems like a common problem, one would encounter.)Are my attempts reasonable and is attempt 2 better?Or is there something fundamentally flawed with my design? (I was hoping to have the song inside the player because it represented the current song).Original Code (view wouldn't be updated):Modelimport Foundation
import Combine
class Player : ObservableObject {
@Published var duration = 0
@Published var song : Song
init(song: Song) {
self.song = song
}
}
class Song : ObservableObject {
@Published var id : Int
@Published var title : String
@Published var artist : String
init(id: Int,
title: String,
artist: String) {
self.id = id
self.title = title
self.artist = artist
}
}View:import SwiftUI
struct ContentView: View {
@ObservedObject var player : Player
var body: some View {
VStack {
Text(String(player.duration))
Text(player.song.title)
Text(player.song.artist)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
let song = Song(id: 1, title: "title1", artist: "artist1")
let player = Player(song: song)
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
player.song.title = "title2"
}
return ContentView(player: player)
}
}Attempt1 - Using CombineLatestProblem: It is not very scalable as the number of properties in a song increases.class Player : ObservableObject {
@Published var duration = 0
@Published var song : Song
private var songChangeCanceller : AnyCancellable?
init(song: Song) {
self.song = song
songChangeCanceller = song.$title.combineLatest(song.$artist, song.$id).sink { _, _, _ in
self.objectWillChange.send()
}
}
}Attemp2: Uses objectWillChange.sinkclass Player : ObservableObject {
@Published var duration = 0
@Published var song : Song
private var songChangeCanceller : AnyCancellable?
private var songAttributesChangeCanceller : AnyCancellable?
init(song: Song) {
self.song = song
songChangeCanceller = $song.sink { newSong in
self.songAttributesChangeCanceller = newSong.objectWillChange.sink { _ in
self.objectWillChange.send()
}
}
}
}
Hi,I have created a new command line tool project, where I am trying to add a key to the keychain.Error:OSStatus: -34018Error Description: A required entitlement isn't present.Questions:1. How can I resolve this error ? I am able to do the same thing using a mac app instead of a command line tool project.2. Am I missing some key steps ?Points to note:- Signing: Automatically manage Signing- Signing certificate - Developmentmain.swiftimport Foundation
import CryptoKit
func storeKey(label: String) {
//Generate key
let key = P256.Signing.PrivateKey()
let attributes = [kSecAttrKeyType: kSecAttrKeyTypeECSECPrimeRandom,
kSecAttrKeyClass: kSecAttrKeyClassPrivate] as [String: Any]
// Get a SecKey representation.
guard let secKey = SecKeyCreateWithData(key.x963Representation as CFData,
attributes as CFDictionary,
nil) else {
print("Unable to create SecKey representation.")
return
}
let query = [kSecClass: kSecClassKey,
kSecAttrApplicationLabel: label,
kSecAttrAccessible: kSecAttrAccessibleWhenUnlocked,
kSecUseDataProtectionKeychain: true,
kSecValueRef: secKey] as [String: Any]
// Add the key to the keychain.
let status = SecItemAdd(query as CFDictionary, nil)
guard status == errSecSuccess else {
print("Unable to store item: \(status)")
print(SecCopyErrorMessageString(status, nil) ?? "")
return
}
print("successful")
}
storeKey(label: "TEST-KeyChain-Mac")Attempts made:1. Add Info.plist (contents shown below)2. Add TestExample.entitlements (contents shown below)After adding entitlements I get the following error:Message from debugger: Error 1Program ended with exit code: -1Build Settings Changes:CODE_SIGN_ENTITLEMENTS = TestExample/TestExample.entitlements
CODE_SIGN_INJECT_BASE_ENTITLEMENTS
INFOPLIST_FILE = TestExample/Info.plist
CREATE_INFOPLIST_SECTION_IN_BINARY = YES
PRODUCT_BUNDLE_IDENTIFIER = .TestExampleInfo.plist<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
</dict>
</plist>TestExample.entitlements<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)<same reverse DNS>.TestExample</string>
</array>
</dict>
</plist>
Hi,I am trying to extract the data from the P8 file to use it generate JWT.I understand that it is possible using dumpasn1 and extracting the OCTET STRING section. This is great, and is definitely possible.I was wondering if it was possible to do it on macOS using Apple's APIs (example SecItemImport), would make it simpler if it was possible all in the mac app.I tried the following but it didn't work:Error: I got the OSStatus as -25257Questions:- Is there a way to do this using SecItemImport or any other Apple APIs as I am using it in a command line mac app ?- Are the parameters to SecItemImport are incorrect ?- Am down the wrong path? , any direction to the correct API would help.What I tried with SecItemImport:- Data extracted from the file- Decoding the data from the file- Some input formatsMany thanks.import Foundation
import Security
func f1() {
do {
let fileURL = URL(fileURLWithPath: "some valid path");
let data = try Data(contentsOf: fileURL)
guard let string = String(data: data, encoding: .utf8) else {
print("Failed to convert data to string")
return
}
let b64Text = string
.replacingOccurrences(of: "-----END PRIVATE KEY-----", with: "")
.replacingOccurrences(of: "-----BEGIN PRIVATE KEY-----", with: "")
.replacingOccurrences(of: "\n", with: "")
guard let b64Data = b64Text.data(using: .utf8),
let decodedData = Data(base64Encoded: b64Data) else {
print("Was not b64 data")
return
}
print(string)
var outArray : CFArray?
let filename : CFString? = nil
var inputFormat = SecExternalFormat.formatUnknown
var itemType = SecExternalItemType.itemTypePrivateKey
let flags = SecItemImportExportFlags()
//I tried data, b64Data, decodedData all seems to return an error
let status = SecItemImport(decodedData as CFData,
filename,
&inputFormat,
&itemType,
flags,
nil,
nil,
&outArray)
//status = -25257
print("status = \(status)")
for element in (outArray as [AnyObject]?) ?? [] {
print("element = \(element)")
}
}
catch {
print("Error: \(error)")
}
}
f1()