Post not yet marked as solved
Does "natural scrolling" system preference affect NSEvent.scrollingDeltaY?
BTW, I find that "natural scrolling" on my Sonoma (Mac mini m1) stops working; turning on/off has no effect when I scroll in Finder app.
Post not yet marked as solved
I have a general question that confusing me.
I am on M1 and I can build my app on Xcode (or create an archive) for device. Looking in to derived data I can see Debug-iphones (and simulators) folders, I can get the .app and drag/drop it to the simulator. When trying to run the app the app will crash with error:
EXEC 14 Binary with wrong platform
I understand that it wasn't build for simulators but rather it was build for devices and there fore the crash, but when thinking about it I dont understand why? (at least theoretically it shouldn't crash as it was build for arm64 ). Inspected the binary with lipo it was build for arm64. Comparing the binaries for simulator and device (with otool) I dont see a lot of difference except the rpath.
So how does IOS knows it was build for device and not simulator (wrong platform)?
is there a way to add some sort of relaxation (in the end both binaries were build for arm64).
Post not yet marked as solved
With SCNetworkReachabilityCreateWithAddress now depreciated I'm having to use NWPathMonitor to determine if I have a good connection to access some HTML and JSON files. I have this working just fine if the network connection is down but if the network connection comes back up it detects an event but still shows the status as unsatisfied. I can't seem to capture or pickup that when I've got a good connection again so I can proceed with the right status. Here is my current code. Any suggestions would be appreciated:
import Network
import Combine
class NetworkStatus: ObservableObject {
static let shared = NetworkStatus()
private var monitor: NWPathMonitor?
private var queue = DispatchQueue(label: "NetworkMonitor")
@Published var isConnected: Bool = false
private init() {
monitor = NWPathMonitor()
startMonitoring()
}
deinit {
stopMonitoring()
}
func startMonitoring() {
monitor?.pathUpdateHandler = { [weak self] path in
DispatchQueue.main.async {
let status = path.status == .satisfied
self?.isConnected = status
print(">>> \(path.status)")
}
}
monitor?.start(queue: queue)
}
func stopMonitoring() {
monitor?.cancel()
monitor = nil
}
}
Post not yet marked as solved
I've a workspace with multiple packages, and due to the a bug in Xcode I cannot export the app localizations using the Xcode GUI tool, but I need to resort on using a command from terminal
xcodebuild -exportLocalizations -localizationPath . -workspace <path_workspace> -sdk iphoneos -exportLanguage en
One of my packages contains some macros, and I use them from my code without any problem, the code compile
But when I try to export localizations using that command, the build fails due to "compiler plugin not loaded"
So I cannot use Xcode normal exporting because Xcode bug, and cannot export by running a command due to the macro problem
What should I do? It is very discouraging this situation, do you have any suggestion?
I've found a similar problem
Post not yet marked as solved
in Swift languange,
CVMetalTextureCacheCreateTextureFromImage return CVMetalTexture, and CVMetalTexture is Swift class, so. it doesn't need to call CVBufferRelease manually.
My question is : should I use a variable to keep strong reference until GPU finished (until addCompleteHandler callback ) ?
cvmetaltexturecachecreatetexture
Post not yet marked as solved
I have a tableview with a column which has an inner tableview. I want to change height of the outer tableview to match the height of the inner tableview.
outerTableView.reloadData()
let range = outerTableView.rows(in: summaryTableView.superview!.visibleRect)
outerTableView.noteHeightOfRows(withIndexesChanged: IndexSet(integersIn: range.lowerBound..<range.upperBound))
The above code will cause an exception:
WARNING: NSTableView detected a rowView was requested from inside of the -heightOfRow delegate method. That is not supported!
(
0 CoreFoundation 0x000000019093eccc __exceptionPreprocess + 176
1 libobjc.A.dylib 0x0000000190426788 objc_exception_throw + 60
2 AppKit 0x000000019420be98 -[NSTableRowData _availableRowViewWhileUpdatingAtRow:] + 0
3 AppKit 0x000000019425a470 -[NSTableView viewAtColumn:row:makeIfNecessary:] + 32
Post not yet marked as solved
I have an uncommon scenario here.
outer tableview
+--------------------------+
| column 1| inner tableview|
+--------------------------+
Now most often the out tableview has many rows and vertical scrollbar visible.
When user try to scroll vertically in the inner tableview but it has no vertical scrollbar (because it has only a few items), I want the scroll event sink into its parent view or better outer tableview, so that user does not have to move cursor to first column in outer tableview and scrolls.
Is this possible?
Post not yet marked as solved
I am no expert at coordinate systems. I am kind of aware I can use its enclosingScrollView but don't know the details.
Any suggestions would be appreciated.
Post not yet marked as solved
To me, the documentation for this method is not at all clear and needs to provide sample code. I tried searching the dev site for sample projects, but they're no longer where they lived for decades before. And where's the TextEdit sample project?!
I need to override shouldCloseWindowController so I can make sure some sub-windows can be closed before closing the document's one and only window. I've done that, but then have no idea what I'm supposed to do to all the document to close. I tried this, which is what I think the NSDocument version header says to do:
if ((self.windowControllers.first?.shouldCloseDocument) != nil){
self.canClose(withDelegate:delegate as Any, shouldClose:shouldCloseSelector, contextInfo:contextInfo);
}
But the document never gets the close() method called - only the window goes away.
I have developed a framework for my customer, thats a swift dyanmic framework. For code modularization i have divided this framework features in to multiple static libraries as shown in the diagram below.
Currently we have on main swift dynamnic framework and it contains 2 static libraries too. Also the first static library here in turn nested with another static library,
Key points to note here is
My static libraries contains other third party iOS frameworks
My static libraries using CoccoaPods as the dependency for Alarmofire at the moment.
My questios are
Is there any problem in the current architecture , because i heard nested libraries are not supported in iOS . but since we dont have frameworks nested here, all of our second level frameworks are static libraries only.
What are link/libary search path guidance we needed to take care to make a successful build.
Post not yet marked as solved
Hi. I'm trying to compile simple swift source file with stripping types metadata and names from it. I use these frontend flags:
swiftc -O -Xfrontend -disable-reflection-names -Xfrontend -disable-reflection-metadata -Xfrontend -reflection-metadata-for-debugger-only -Xfrontend -disable-generic-metadata-prespecialization -gnone test.swift
After compiling this test source file I still facing metadata and names in binary after dissembling it with Hopper.
What I'm doing wrong? Please help.
Post marked as Apple Recommended
I've had a little personal utility running for several versions of macOS that uses
let client = CWWiFiClient.shared()
if let ssid_name = client.interface()?.ssid()
to get the current SSID name and prints it (along with a bunch of other active network details.
With the most recent Sonoma Beta 2 and Xcode beta 2, this always returns nil.
Doing the same thing in a playground works as expected.
Is this a purposeful change or a bug I should file?
Post not yet marked as solved
Xcode 15 and Sonoma expose the property NSView.clipsToBounds. On Sonoma I need to set this property to TRUE and this is working well.
However, for reasons, I also need to compile my macOS project with Xcode 13 and Xcode 14. I am having difficulty figuring out the Swift #available and @available directives to allow this.
No matter how I wrap the self.clipsToBounds = true statement, on these earlier versions of Xcode I get a Swift error telling me that clipsToBounds cannot be found.
Any help would be appreciated.
Post not yet marked as solved
Hello,
I am trying to use the SwiftUI fileImporter to get the URL of a direcotry and access it for the files in it.
If I follow the document( Access the directory’s content ) and use url.startAccessingSecurityScopedResource for each file, it always returns false. but this seems to be different from the documentation. If the current behavior is correct, will the documentation be updated in the future?
Related: Access all files in UIDocumentPick… | Apple Developer Forums
I asked this question because I am concerned that if I remove the standardAccessingSecurityScopedResource to match the current situation, the standardAccessingSecurityScopedResource may become necessary due to future iOS updates.
Also, is there any way to know if the status of the AccessingSecurityScopedResource?
It would be helpful if we could callstartAcesingSecurityScopedResource only when needed.
Thanks
Here is a sample code
@main
struct SampleApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
@State private var isShowingImportFolder = false
@State private var isShowingImportFile = false
var body: some View {
VStack(spacing: 48) {
Button("Read Folder") {
isShowingImportFolder = true
}
.fileImporter(isPresented: $isShowingImportFolder, allowedContentTypes: [.folder]) { result in
switch result {
case .success(let url):
processDirectory(url)
case .failure(let error):
print("failed. error: \(error)")
}
}
Button("Read File") {
isShowingImportFile = true
}
.fileImporter(isPresented: $isShowingImportFile, allowedContentTypes: [.data]) { result in
switch result {
case .success(let url):
readFile(url)
case .failure(let error):
print("failed. error: \(error)")
}
}
}
}
private func processDirectory(_ directory: URL) {
guard directory.startAccessingSecurityScopedResource() else {
fatalError("failed. directory.startAccessingSecurityScopedResource")
}
defer { directory.stopAccessingSecurityScopedResource() }
var error: NSError?
NSFileCoordinator().coordinate(readingItemAt: directory, error: &error) { url in
let urls = try! FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: [.nameKey, .isDirectoryKey])
urls.lazy
.filter { !$0.hasDirectoryPath }
.forEach { readFile($0) }
}
}
private func readFile(_ url: URL) {
guard url.startAccessingSecurityScopedResource() else {
print("failed access. \(url.path)")
return
}
defer { url.stopAccessingSecurityScopedResource() }
let data = try! Data(contentsOf: url)
print("file.path: \(url.path()), size: \(data.count)")
// read file...
}
}
Dear all,
I have initialized an array of a variable number of items
@State private var squadre: [Squadre] = Squadre.test()
Now, I'm showing in the following way the array:
List {
ForEach(squadre) { squadre in
HStack {
Text(squadre.squadra)
Text("\(squadre.punti)")
}
}
}
I'd like to perform the following actions:
Sort the array by the value "punti" (Int type)
Show only the first half of the array in the list
Do you have clue of how I can achieve it? I tried indexing the array, but didn't make it.
Please support me.
Thanks,
A.
According to the doc:
The value returned is the same as the value returned in the kEventParamKeyCode when using Carbon Events.
So where can I find kEventParamKeyCode?
Post not yet marked as solved
Hello,
We've an iOS application that can be launched on macOS (with the "designed for iPhone" available with Catalyst).
This application request authorization on MPMediaLibrary and play MPMediaItem with an audio player. After accepted, the authorization status is well flagged as .authorized
I can browse all MPMediaItem without issue and display them in my app.
But, when it comes the time to convert the MPMediaItem file's URL in AVAudioFile with:
AVAudioFile(forReading: fileURL)
We got 2 warnings in the console:
ExtAudioFile.cpp:211 about to throw -54: open audio file
AVAEInternal.h:109 [AVAudioFile.mm:135:AVAudioFileImpl: (ExtAudioFileOpenURL((CFURLRef)fileURL, &_extAudioFile)): error -54
We finally get an exception with this error:
Error Domain=com.apple.coreaudio.avfaudio Code=-54 "(null)" UserInfo={failed call=ExtAudioFileOpenURL((CFURLRef)fileURL, &_extAudioFile)}
This working perfectly on iOS and iPadOS, but with Catalyst we always got this error whatever the audio (from iTunes library) we try to play.
Why do we have this permission issue only on macOS ? There is something different to do to get permission on macOS ?
thanks !
Post not yet marked as solved
I encountered a runtime error in a project I'm working on, where I tapped a specific sentence to move the cursor position and then tried to insert a newline. When I pressed backspace to cancel the newline, the app crashed due to a runtime error.
Believing that the issue might not be with our project, I attempted the same actions in Apple's default Notes app and encountered a crash there as well.
This appears to be a UIKit bug... Can it be resolved?
I will attach the video I tested this with and the text used for testing below.
Test Text:
https://shorturl.at/uISV7
Test Video:
https://github.com/leeari95/leeari95/assets/75905803/1665fd8e-73ea-4be0-9c02-abc682f8552b
Post not yet marked as solved
I am embedding WKWebView in my macOS application and need to automate entering text and clicking form buttons on a webpage. I tried using selenium and it doesn't support WKWebView, it can only create a new Safari instance. What are my options?
Post not yet marked as solved
When distributing a 3rd party SDK as an XCFramework in order to include the privacy manifest to the bundle you need to include the resources key in the target configuration to point to the correct file, for example:
resources: [.process("Resources/PrivacyInfo.xcprivacy")]
However, when distributing the xcframework as a binaryTarget resources is not available. How can I include my privacy manifest when configuring Package.swift ?