Posts

Post not yet marked as solved
0 Replies
616 Views
Overview I have a 3 column NavigationSplitView On iPad I would like to detect if the sidebar (red) / content (green) is a slide over I don't want to rely on orientation as it is possible to have multiple apps side by side and that can change the view size Questions: On iPad, how can I detect if sidebar (red) / content (green) is a slide over? Or is there an alternate approach? Code: struct ContentView: View { @State private var splitViewVisibility = NavigationSplitViewVisibility.automatic var body: some View { NavigationSplitView(columnVisibility: $splitViewVisibility) { Color.red } content: { Color.green } detail: { Color.blue } } } Screenshot Slide over Not Slide Over
Posted
by newwbee.
Last updated
.
Post not yet marked as solved
0 Replies
1.1k Views
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'
Posted
by newwbee.
Last updated
.
Post marked as solved
1 Replies
2.1k Views
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?
Posted
by newwbee.
Last updated
.
Post marked as solved
4 Replies
1.2k Views
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?
Posted
by newwbee.
Last updated
.
Post marked as solved
13 Replies
6.3k Views
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
Posted
by newwbee.
Last updated
.
Post not yet marked as solved
0 Replies
939 Views
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?
Posted
by newwbee.
Last updated
.
Post marked as solved
1 Replies
989 Views
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
Posted
by newwbee.
Last updated
.
Post not yet marked as solved
0 Replies
1.1k Views
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 -&gt; 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 -&gt; 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)") } } } } }
Posted
by newwbee.
Last updated
.
Post not yet marked as solved
1 Replies
792 Views
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 } } }
Posted
by newwbee.
Last updated
.
Post marked as solved
2 Replies
21k Views
Aim:I have a model which is an ObservableObject. It has a Bool property, I would like to use this Bool property to initialise a @Binding variable.Questions:How to convert an @ObservableObject to a @Binding ?Is creating a @State the only way to initialise a @Binding ?Note:I do understand I can make use of @ObservedObject / @EnvironmentObject, and I see it's usefulness, but I am not sure a simple button needs to have access to the entire model.Or is my understanding incorrect ?Code:import SwiftUI import Combine import SwiftUI import PlaygroundSupport class Car : ObservableObject { @Published var isReadyForSale = true } struct SaleButton : View { @Binding var isOn : Bool var body: some View { Button(action: { self.isOn.toggle() }) { Text(isOn ? "On" : "Off") } } } let car = Car() //How to convert an ObservableObject to a Binding //Is creating an ObservedObject or EnvironmentObject the only way to handle a Observable Object ? let button = SaleButton(isOn: car.isReadyForSale) //Throws a compilation error and rightly so, but how to pass it as a Binding variable ? PlaygroundPage.current.setLiveView(button)
Posted
by newwbee.
Last updated
.
Post not yet marked as solved
4 Replies
4.4k Views
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, &amp;inputFormat, &amp;itemType, flags, nil, nil, &amp;outArray) //status = -25257 print("status = \(status)") for element in (outArray as [AnyObject]?) ?? [] { print("element = \(element)") } } catch { print("Error: \(error)") } } f1()
Posted
by newwbee.
Last updated
.
Post marked as solved
8 Replies
3.9k Views
Hi,I would like to create a JWT to interact with Apple's Webservices.As the first step, I have a private key file, I have loaded it as Data.I would like to create an instance of Private Key instance (not sure what is the correct struct to use, tried HMAC, P256.Signing.PrivateKey etc)Every time an exception is thrown.Any help and direction would greatly help. Many thanks.let privateKeyPath = URL(fileURLWithPath: "some valid path") let privateKeyData = try Data(contentsOf: privateKeyPath, options: .alwaysMapped) let message = "abcd" let messageData = message.data(using: .utf8)! do { //Option1: //This throws: Error: incorrectParameterSize let signature1 = try P256.Signing.ECDSASignature(rawRepresentation: privateKeyData) //Option2: let key2 = SymmetricKey(data: privateKeyData) //This throws: Error: incorrectKeySize var encryptedContent2 = try AES.GCM.seal(messageData, using: key2).combined } catch { print("Error: \(error)") }
Posted
by newwbee.
Last updated
.
Post marked as solved
2 Replies
2k Views
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     } }
Posted
by newwbee.
Last updated
.
Post marked as solved
3 Replies
1k Views
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/&lt;Username&gt;/Library/Preferences/com.apple.iphonesimulator.plistCreated a new Mac UserDeleted Xcode and installed it again
Posted
by newwbee.
Last updated
.
Post not yet marked as solved
8 Replies
4.9k Views
I have created an AsyncOperation which is a subclass of Operation.I am overriding the following methods to use KVC:- isExecuting- isFinishedProblem:When I use String in place of KeyPath, my completion block gets executed. If I use KeyPath the completion block of the operation is not getting executed.Works ok:willChangeValue(forKey: "isExecuting")didChangeValue(forKey: "isExecuting")willChangeValue(forKey: "isFinished")didChangeValue(forKey: "isFinished")Doesn't work (Compiles ok, but at runtime the completion block doesn't get executed):willChangeValue(for: \.isExecuting)didChangeValue(for: \.isExecuting)willChangeValue(for: \.isFinished)didChangeValue(for: \.isFinished)Note: I am using the following:- macOS 10.12.5 (16F73)- Xcode 9.0 beta (9M136h)Questions:1. Why isn't KeyPath working when using the String works ?2. How to fix using KeyPath ?Complete Code:class AsyncOperation : Operation { private var _executing = false private var _finished = false override var isExecuting : Bool { get { return _executing } set { willChangeValue(for: \.isExecuting _executing = newValue didChangeValue(for: \.isExecuting) } } override var isFinished : Bool { get { return _finished } set { willChangeValue(for: \.isFinished) _finished = newValue didChangeValue(for: \.isFinished) } } override var isAsynchronous : Bool { return true } func markAsCompleted() { isExecuting = false isFinished = true } }
Posted
by newwbee.
Last updated
.