In the following simplified app I want to change the status bar color from default black to white (the main iPhone theme is light) but nothing else. I'm partly succeeded doing so, but the theme of keyboard is wrong: when it is first appeared it is good (light) and as soon as i start typing it changes itself to unwanted dark. Is there a way to change just the status bar color but nothing else? Note that I want the status bar color be dynamic - sometimes white, sometimes black depending upon what the app is doing.
import SwiftUI
struct ContentView: View {
@State var string = "Hello, World"
var body: some View {
TextField("EditableText", text: $string)
.font(.largeTitle)
.frame(maxHeight: 1000)
.navigationTitle("Hello, World")
.background(
Color(red: 1, green: 0.7, blue: 0.7, opacity: 1)
)
.colorScheme(.light) // attempt to "undo" the effect
.preferredColorScheme(.dark)
}
}
@main struct NavBarTestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
PS. I don't mind dropping to UIKit for status bar handling if it is not possible to do it in SwiftUI. The rest of app itself is SwiftUI and it is quite big, here I am showing a stripped down version.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
hello,
i know i could be overly paranoid at times.. but
is this the case that i need to protect my global memory location (that i read from / write to) with read/write memory barriers even if i'm only accessing that location from a single serial DispatchQueue? considering the fact that GCD can pick a different thread to run operations on that queue, and a further fact that different threads can run on different cores and thus have different L1/L2 caches, so that the barrier unprotected write to a location in one code invocation (that runs on my serial queue, that happens to be bound to thread1/core1 at the time) might not yet be visible to a different invocation of my code that runs a bit later on the same serial GCD queue but it so happens that now it runs on thread2/core2, so that the barrier unprotected read from that global memory location returns some stale data?
is the answer any different if we consider a serial (maxConcurrentCount=1) OperationQueue instead of a serial dispatch queue?
finally, is the answer any different if we consider a single NSThread / pthread instead of a serial dispatch queue? can a single thread be bound to different cores during its lifetime? (e.g. work on one core, then sleep, then awake on a different core).
thank you.
Tried to ask as a comment in the other thread:
https://developer.apple.com/forums/thread/650386?answerId=628394022#reply-to-this-question
But can't leave a comment in there for some reason (the thread is locked?). Asking exactly the same question, now for iOS 15. Anything changed in this area?
When selecting a stroke path for object on PKCanvas, the option "Snap to Shape" appears.
I understand this function is still in beta and has not made available natively to other PencilKit app. Is there a way using Stroke API to call this function directly after the user hold pencil for half a second when stroke is done drawing, just like how it behaves in native apps?
What best to pass to the options parameter of:
MTLDevice.makeBuffer(length:options:)
MTLDevice.makeBuffer(bytes:length:options:)
MTLDevice.makeBuffer(bytesNoCopy:length:options:deallocator:)
Basically I'm looking for a "plain English" explanation of MTLResourceOptions doc page.
i thought it is impossible to have CallKit show system UI for outgoing calls. but then i saw this:
"For incoming and outgoing calls, CallKit displays the same interfaces as the Phone app..."
https://developer.apple.com/documentation/callkit
how do i present it though? or is this a documentation error?
Our app has "allow arbitrary loads" in the "App Transport Security Settings" and generally allows both "http" and "https" connections. I want to restrict basic authentication usage to secure connections only, what is the best way to do that?
I have URLSessionTaskDelegate's:
func urlSession(_ session: URLSession, task: URLSessionTask, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
where I can put the relevant logic, but how do I check if the connection attempt in question is happening over TLS or not? I can check task.currentRequest.url scheme being "http" vs "https", and port being nil vs 80 vs 443, but I hope there is a more robust check.
Hi, is it possible to have the SwiftUI's NavigationView set to show both panels side by side in landscape mode on iPhone Plus/Max sized devices? Similar to how Messages.app does it. Thank you.
When calling CBCentralManager's connectPeripheral:options: with some Bluetooth devices I'm getting the "Bluetooth Pairing Request" alert on iOS and a similar "Connection Request from:" alert on macOS. Is there a way to determine upfront if the alert is going to be presented or not? Alternatively is there a way to prohibit presenting this alert (in which case the connect request could fail, which is totally fine)? I tried specifying these options:
var manager: CBCentralManager
...
manager.connect(
peripheral,
options: [
CBConnectPeripheralOptionNotifyOnConnectionKey: false,
CBConnectPeripheralOptionNotifyOnDisconnectionKey: false,
CBConnectPeripheralOptionNotifyOnNotificationKey: false
]
)
but those didn't help (and by the doc they shouldn't help as they relate to the use case of app running in background, which is not applicable in my case – my app runs and calls connect when it is in foreground, the unwanted alert is displayed immediately).
I'm creating a simple p2p server to advertise a service:
// server
let txtRecord = NWTXTRecord(["key": "value"])
NWListener.Service(name: name, type: "_p2p._tcp", domain: nil, txtRecord: txtRecord)
and client to look that service up:
// client
switch result.endpoint {
case let .service(name: name, type: type, domain: domain, interface: interface):
print(result.metadata)
The client is getting the advertisement ok, but metadata is nil. I expected to see a txt record there, is that not supported?
public let metadata: NWBrowser.Result.Metadata
/// Additional metadata provided to the browser by a service. Currently,
/// only Bonjour TXT records are supported.
Is the above server making a Bonjour TXT record or something else?
Basically what I want is to pass a short key/value data as part of advertisement.
how do i make TextEditor autoscrolled? i want to implement a log view based on it - when the scroll position is at bottom, adding new lines shall autoscroll it upwards so the newly added lines are visible. and when the scroll position is not at bottom - adding new lines shall not autoscroll it.
Is it possible to use network from within iOS Thumbnail Extension?
I tried - it works fine under simulator, but I'm getting this error when running on real device:
networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception.
Adding "App Transport Security Settings / Allow Arbitrary Loads" plist entry didn't help. As the error seems to be specific access to a particular file I tried adding "com.apple.security.temporary-exception.files.absolute-path.read-only" but it didn't help and looks like it couldn't help on iOS: "Note: This chapter describes property list keys specific to the macOS implementation of App Sandbox. They are not available in iOS."
Topic:
App & System Services
SubTopic:
General
Tags:
Extensions
QuickLook Thumbnailing
App Sandbox
Network
I am struggling to see why the following low-level audio recording function - which is based on tn2091 - Device input using the HAL Output Audio Unit - (a great article, btw, although a bit dated, and it would be wonderful if it was updated to use Swift and non deprecated stuff at some point!) fails to work under macOS:
func createMicUnit() -> AUAudioUnit {
let compDesc = AudioComponentDescription(
componentType: kAudioUnitType_Output,
componentSubType: kAudioUnitSubType_HALOutput, // I am on macOS, os this is good
componentManufacturer: kAudioUnitManufacturer_Apple,
componentFlags: 0, componentFlagsMask: 0)
return try! AUAudioUnit(componentDescription: compDesc, options: [])
}
func startMic() {
// mic permision is already granted at this point, but let's check
let status = AVCaptureDevice.authorizationStatus(for: AVMediaType.audio)
precondition(status == .authorized) // yes, all good
let unit = createMicUnit()
unit.isInputEnabled = true
unit.isOutputEnabled = false
precondition(!unit.canPerformInput) // can't record yet, and know why?
print(deviceName(unit.deviceID)) // "MacBook Pro Speakers" - this is why
let micDeviceID = defaultInputDeviceID
print(deviceName(micDeviceID)) // "MacBook Pro Microphone" - this is better
try! unit.setDeviceID(micDeviceID) // let's switch device to mic
precondition(unit.canPerformInput) // now we can record
print("\(String(describing: unit.channelMap))") // channel map is "nil" by default
unit.channelMap = [0] // not sure if this helps or not
let sampleRate = deviceActualFrameRate(micDeviceID)
print(sampleRate) // 48000.0
let format = AVAudioFormat(
commonFormat: .pcmFormatFloat32, sampleRate: sampleRate,
channels: 1, interleaved: false)!
try! unit.outputBusses[1].setFormat(format)
unit.inputHandler = { flags, timeStamp, frameCount, bus in
fatalError("never gets here") // now the weird part - this is never called!
}
try! unit.allocateRenderResources()
try! unit.startHardware() // let's go!
print("mic should be working now... why it doesn't?")
// from now on the (UI) app continues its normal run loop
}
All sanity checks pass with flying colors but unit's inputHandler is not being called. Any idea why?
Thank you!
Where's CBAdvDataManufacturerData format documented?
It looks like there's the company code stored in little endian order in the first two bytes (referencing the companies found in company_identifiers.yaml on bluetooth site). And the rest is arbitrary?
I'd like to see the official documentation about this.
Thank you.
How do I download a folder from opensource.apple.com without going inside recursively and downloading individual files?
e.g. one from here: "https://opensource.apple.com/source/Libm/"
PS. no idea what's the proper tag for this post, and as forum insists on having a non-empty tag field I'm using "Foundation" arbitrarily.
Posting this on behalf of my colleague, who has a project in mind that requires a huge amount of RAM. Is it true that modern Mac Pro's can only have up to 192GB of RAM which is about 8 times less than 5 years old intel based Mac Pros?