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()
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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
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?
Hi,
I have a Mac app that uses calendar. When the user has not granted access and still wants to access the calendar I would like to open System Settings Privacy and Security pane for calendar on the mac. How can I do this?
Is it ok to open system settings this way?
Or is there a better way?
I would like to publish this app to the AppStore so want to know if this is ok?
if let urlString = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Calendars") {
NSWorkspace.shared.open(urlString)
}
Overview
I am using Xcode Cloud to create builds.
It contains 2 post actions:
TestFlight Internal Testing - Succeeded
TestFlight External Testing - Failed
Error
Xcode doesn't display the exact error it only shows the status as Not Submitted for Beta Review
When I checked AppStoreConnect > TestFlight I saw the status as Read to Submit. When I manually tried to add external testers to the build using AppStoreConnect website, then I got the error: You can only submit two builds per day to Beta App Review.
Questions
This seems like a very odd limitation. How do we test multiple builds?
Why isn't Xcode the exact error? It only shows Not Submitted for Beta Review
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
App Store Connect
TestFlight
Xcode Cloud
Hi,
Overview
I am using Xcode Cloud for my multi platform app.
The macOS test case fails, however the iOS test case runs and succeeds.
I don't have any UI test cases written, the test case are simple and have nothing platform (macOS) specific.
Questions
What can I do to fix this?
Is there any user privileges needed to launch the macOS app for testing? I ask because when I ran the UI tests locally it launched the app and asked for my macOS user password. Just wondering if that is the reason it didn't launch in Xcode Cloud.
Error:
<Appname> encountered an error (Failed to install or launch the test runner. If you believe this error represents a bug, please attach the result bundle at /Volumes/workspace/resultbundle.xcresult.(Underlying Error: Could not launch "AppnameTests. The LaunchServices launcher has returned an error. Please check the system logs for
the underlying cause of the error. (Underlying Error: The operation couldn't be completed. Launch failed. (Underlying Error: Launch job spawn failed) )))
× Could not launch "<Appname>"
× Could not launch "AppnameTests"
× AppnameUITests.testExample()
Failed to get launch progress for <XCUIApplicationImpl: 0x600000564630 <BundleID> at /Volumes/workspace/TestProducts/Debug-Dev/<Appname>.app>: Could not launch "app name". The LaunchServices launcher has returned an error. Please check the system logs for the underlying cause of the error. (Underlying Error: The operation couldn't be completed. Launch failed. (Underlying Error: Launch job spawn failed))
AppnameUITests.swift:28
* AppnameUITests.testLaunchPerformance)
Failed to get launch progress for «XCUIApplicationimpl: 0x60000054630 <BundleID> at /Volumes/workspace/TestProducts/Debug-Dev/<Appname>.apps: Could not launch "<Appname>". The LaunchServices launcher has returned an error. Please check the system logs for the underlying cause of the error. (Underlying Error: The operation couldn't be completed. Launch failed. (Underlying Error: Launch job spawn failed))
AppnameUITests.swift:37 g
* AppnameUITestsLaunchTests.testLaunch)
Failed to get launch progress for «XCUIApplicationimpl: 0x60000054630 <BundleID> at /Volumes/workspace/Testroducts/Debug-Dev/<Appname>.apps: Could not launch "<Appname>". The LaunchServices launcher has returned an error. Please check the system logs for the underlying cause of the error. (Underlying Error: The operation couldn't be completed. Launch failed.
Hi,
Overview:
My app's icon uses Display P3 colors.
The PNG when opened in Preview seems to have the correct colours, but when added to Asset catalog as App icon, the installed app's app icon doesn't have the correct colors.
The Preview app's inspector shows the following:
Colour Model: RGB
Depth: 16
DPI Height: 72
DPI Width: 72
Orientation: 1 (Normal)
Pixel Height: 1,024
Pixel Width: 1,024
Profile Name: Display P3
Steps followed:
I have an app icon that uses the Display P3 color profile.
In Sketch, I have assigned the P3 Display color profile, exported as PNG.
Realised it was using only 8 bits / channel color depth.
So opened PNG in Pixelmator and changed color depth to 16 bits / channel and exported the PNG.
The PNG when opened in Preview seems to have the correct colours, but when used in
I even tried to use Display P3 Gamut in asset catalog and provide the same icon for sRGB and Display P3, yet the installed app's icon's colors don't match
Questions:
What should I do to correct this problem?
Any help would be much appreciated.
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)
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
I have a SwiftUI list with a search field
I would like to add a keyboard shortcut for search field to be in focus
Questions:
How can I add a keyboard shortcut for search field?
import SwiftUI
struct ContentView: View {
@State private var searchText = ""
var body: some View {
NavigationStack {
List(0..<100) { index in
Text("Cell \(index)")
}
.searchable(text: $searchText)
}
}
}
I am only able to upgrade from Ventura to Sonoma.
I don't want to upgrade, I would like to download the installer so that I can install Sonoma on a separate Volume instead of upgrading.
Am I missing something?
I only see an option to upgrade and the developer website only allows me to download a IPSW file. I have only 1 Mac and I am not sure how I can use the IPSW file to install macOS Sonoma.
Any help would be much appreciated, thanks
Problem
When copyable is used with NavigationSplitView then it doesn't work
The menu Edit > Copy is disabled
Note
When copyable is not used with a NavigationSplitView and used only with a plain List then it works.
Question
Is there anything I am missing?
Feedback
FB12990593
Platform
macOS 14.0 Beta (23A5312d)
Xcode 15.0 beta 6 (15A5219j)
Steps to reproduce
Run the app on mac
Select some cars
Press Command C
Expected Behaviour
Menu Edit > Copy should be enabled
Pressing Command C should allow user to copy selected cars
Actual Behaviour
Menu Edit > Copy is disabled
Pressing Command C doesn't allow user to copy selected cars
Code
struct ContentView: View {
@State private var dataStore = DataStore()
var body: some View {
NavigationSplitView {
Color.brown
} detail: {
CarListView(dataStore: dataStore)
}
}
}
struct CarListView: View {
let dataStore: DataStore
@State private var selectedCarIDs = Set<UUID>()
var body: some View {
List(selection: $selectedCarIDs) {
ForEach(dataStore.cars) { car in
CarCell(car: car)
.draggable(car)
}
}
.copyable(selectedCars())
}
private func selectedCars() -> [Car] {
dataStore.cars.filter { selectedCarIDs.contains($0.id) }
}
}
struct CarCell: View {
let car: Car
var body: some View {
VStack(alignment: .leading) {
Text(car.name)
Text("\(car.price)")
}
}
}
@Observable
class DataStore {
var cars = [
Car(name: "aaa", price: 10),
Car(name: "bbb", price: 20),
Car(name: "ccc", price: 30),
Car(name: "ddd", price: 40)
]
}
struct Car: Codable, Transferable, Identifiable {
let id: UUID
let name: String
let price: Int
init(name: String, price: Int) {
self.id = UUID()
self.name = name
self.price = price
}
static var transferRepresentation: some TransferRepresentation {
CodableRepresentation(contentType: .car)
}
}
extension UTType {
static let car = UTType("com.example.car")!
}
Problem
The following code doesn't work:
let predicate = #Predicate<Car> { car in
car.size == size //This doesn't work
}
Console Error
Query encountered an error: SwiftData.SwiftDataError(_error: SwiftData.SwiftDataError._Error.unsupportedPredicate)
Root cause
Size is an enum, #Predicate works with other type such as String however doesn't work with enum
Enum value is saved however is not filtered by #Predicate
Environment
Xcode: 15.0 (15A240d) - App Store
macOS: 14.0 (23A339) - Release Candidate
Steps to reproduce
Run the app on iOS 17 or macOS Sonoma
Press the Add button
Notice that the list remains empty
Expected behaviour
List should show the newly created small car
Actual behaviour
List remains empty inspite of successfully creating the small car.
Feedback
FB13194334
Code
Size
enum Size: String, Codable {
case small
case medium
case large
}
Car
import SwiftData
@Model
class Car {
let id: UUID
let name: String
let size: Size
init(
id: UUID,
name: String,
size: Size
) {
self.id = id
self.name = name
self.size = size
}
}
ContentView
struct ContentView: View {
var body: some View {
NavigationStack {
CarList(size: .small)
}
}
CarList
import SwiftUI
import SwiftData
struct CarList: View {
let size: Size
@Environment(\.modelContext)
private var modelContext
@Query
private var cars: [Car]
init(size: Size) {
self.size = size
let predicate = #Predicate<Car> { car in
car.size == size //This doesn't work
}
_cars = Query(filter: predicate, sort: \.name)
}
var body: some View {
List(cars) { car in
VStack(alignment: .leading) {
Text(car.name)
Text("\(car.size.rawValue)")
Text(car.id.uuidString)
.font(.footnote)
}
}
.toolbar {
Button("Add") {
createCar()
}
}
}
private func createCar() {
let name = "aaa"
let car = Car(
id: UUID(),
name: name,
size: size
)
modelContext.insert(car)
}
}
Overview
I have a custom type Statistics that has 3 properties inside it
I am trying to return this as part of the AppIntent's perforrm method
struct Statistics {
var countA: Int
var countB: Int
var countC: Int
}
I would like to implement the AppIntent to return Statistics as follows:
func perform() async throws -> some IntentResult & ReturnsValue<Statistics> {
...
...
}
Problem
It doesn't make much sense to make Statistics as an AppEntity as this is only computed as a result.
Statistics doesn't exist as a persisted entity in the app.
Questions
How can I implement Statistics?
Does it have to be AppEntity (I am trying to avoid this)? (defaultQuery would never be used.)
What is the correct way tackle this?
Overview
I have an iOS project where I have a list with sections.
Each cell in the section can be swiped to have some action
What needs to be done
When swipe button is pressed the cell needs to move from one section to the other without a UI glitch.
Problem
When I press the swipe action button, there is a UI glitch and some warnings are thrown.
UICollectionView internal inconsistency: unexpected removal of the current swipe occurrence's mask view. Please file a bug against UICollectionView. Reusable view: <SwiftUI.ListCollectionViewCell: 0x10700c200; baseClass = UICollectionViewListCell; frame = (16 40.3333; 370 52); hidden = YES; layer = <CALayer: 0x600000c12fa0>>; Collection view: <SwiftUI.UpdateCoalescingCollectionView: 0x106820800; baseClass = UICollectionView; frame = (0 0; 402 874); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600000c13330>; backgroundColor = <UIDynamicSystemColor: 0x60000173a9c0; name = systemGroupedBackgroundColor>; layer = <CALayer: 0x600000c3a070>; contentOffset: {0, -62}; contentSize: {402, 229}; adjustedContentInset: {62, 0, 34, 0}; layout: <UICollectionViewCompositionalLayout: 0x10590edb0>; dataSource: <_TtGC7SwiftUI31UICollectionViewListCoordinatorGVS_28CollectionViewListDataSourceOs5Never_GOS_19SelectionManagerBoxS2___: 0x106822a00>>; Swipe occurrence: <UISwipeOccurrence: 0x103c161f0; indexPath: <NSIndexPath: 0xab1f048608f3828b> {length = 2, path = 0 - 0}, state: .triggered, direction: left, offset: 0>
Test environment:
Xcode 26.0.1 (17A400)
iOS 26 Simulator (iPhone 17 Pro)
Feedback filed:
FB20890361
Code
I have pasted below the minimum reproducible code
ContentView
import SwiftUI
struct ContentView: View {
@State private var dataStore = DataStore()
var body: some View {
List {
ToDoSection(status: .notStarted, toDos: notStartedToDos)
ToDoSection(status: .inProgress, toDos: inProgressToDos)
ToDoSection(status: .completed, toDos: completedTodos)
}
}
var notStartedToDos: [Binding<ToDoItem>] {
$dataStore.todos.filter { $0.wrappedValue.status == .notStarted }
}
var inProgressToDos: [Binding<ToDoItem>] {
$dataStore.todos.filter { $0.wrappedValue.status == .inProgress }
}
var completedTodos: [Binding<ToDoItem>] {
$dataStore.todos.filter { $0.wrappedValue.status == .completed }
}
}
ToDoSection
import SwiftUI
struct ToDoSection: View {
let status: ToDoItem.Status
let toDos: [Binding<ToDoItem>]
var body: some View {
if !toDos.isEmpty {
Section(status.title) {
ForEach(toDos) { toDo in
Text(toDo.wrappedValue.title)
.swipeActions(edge: .trailing) {
if status == .notStarted {
Button("Start") {
toDo.wrappedValue.status = .inProgress
}
}
if status != .completed {
Button("Complete") {
toDo.wrappedValue.status = .completed
}
Button("Move back") {
toDo.wrappedValue.status = .notStarted
}
}
}
}
}
}
}
}
ToDoItem
import Foundation
struct ToDoItem: Identifiable {
let id: UUID
let title: String
var status: Status
}
extension ToDoItem {
enum Status: Equatable {
case notStarted
case inProgress
case completed
var title: String {
switch self {
case .notStarted:
"Not Started"
case .inProgress:
"In Progress"
case .completed:
"Completed"
}
}
}
}
DataStore
import Foundation
@Observable
class DataStore {
var todos: [ToDoItem]
init() {
todos = [
ToDoItem(id: UUID(), title: "aaa", status: .notStarted),
ToDoItem(id: UUID(), title: "bbb", status: .notStarted),
ToDoItem(id: UUID(), title: "ccc", status: .notStarted)
]
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI