Post

Replies

Boosts

Views

Activity

AVFoundation CaptureDevice and Mac virtual cameras
Hello, on Mac OS, is it possible to see a virtual Camera, such as OBS (https://obsproject.com) as a CaptureDevice? I see that, for example, Google Chrome can use this camera, but using AVCaptureDevice.DiscoverySession I am unable to see it. Am I doing wrong?     var deviceTypes: [AVCaptureDevice.DeviceType] = [.builtInMicrophone, .builtInWideAngleCamera]     #if os(OSX)     deviceTypes.append(.externalUnknown)     #else     deviceTypes.append(contentsOf: [.builtInDualCamera, .builtInDualWideCamera, .builtInTelephotoCamera, .builtInTripleCamera, .builtInTrueDepthCamera, .builtInUltraWideCamera])     #endif     let discoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: deviceTypes,         mediaType: nil, position: .unspecified)     result = discoverySession.devices.map { device in         device.localizedName     }
1
0
1.7k
Nov ’21
Lauch a Script (Python) app in ARM64
Today I was reminded that apps on the Mac do not have to be Mach-O Executables: They can be scripts! For example, a python script. But what I found out that if the app is started directly from the terminal, the app starts as ARM64. But if starting from the Finder (i.e. launchd), it is launched as Intel. Is there an Info.plist key that fixes this?
1
0
1.1k
Mar ’22
Loading an Image in an Widget View
Primary Objective My Widget displays pictures from a list. If I load in all the pictures when setting up the timeline, I run into a memory issue (EXC_RESOURCE RESOURCE_TYPE_MEMORY), because Widgets have a strict limit on how much memory they can use. My Solution Instead of storing a UIImage in my timeline entry, I store the URL to the picture, and load it with a .taskattached to the view. This works, when the view is displayed in the app, and is also shown in the Preview window. The Problem The image is apparently loaded, but not updated for the Widget. Not if running in the simulator or on device, or in the Preview canvas. The Question Obviously: Am I doing it wrong? Do I need to update my timeline more conservatively? Can I load the pictures on demand? Is there a different way of doing this? The Sample Sample code illustrating this can be found here: https://github.com/below/WidgetSample
0
0
2.1k
Oct ’22
Diffie Hellman Key exchange with .Net Cryptography
Hello, I am attempting to perform a Diffie Hellman Keyexchange with a server running on .Net. However, the secretKey I am creating on the client side does not match with the secretKey on the server side, which I have for testing purposes. I can import the server secret key as a SymetricKey, and if I use it to seal and open a box, it works. However, if I seal the box with my client key, I can not open it with the server shared key. I create the SymetricKey like this: let sharedHash = SHA256.self let sharedInfo = serverPublicKey.rawRepresentation let sharedLength = 32 let symetricKey = sharedSecret.x963DerivedSymmetricKey( using: sharedHash, sharedInfo: Data(), outputByteCount: sharedLength) The server key is created using .Net like this: bob.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash; bob.HashAlgorithm = CngAlgorithm.Sha256; bobPublicKey = bob.PublicKey.ToByteArray(); bobKey = bob.DeriveKeyMaterial(CngKey.Import(Alice.alicePublicKey, CngKeyBlobFormat.EccPublicBlob)); My assumption is the keys should be the same. Is that correct? How can I find out what format the server key is in? The .Net documentation is not particularly precise on that You can find a Playground of my code, and when you google for ECDiffieHellmanCng Class, you will find an example on what .Net does. Any help is appreciated
2
0
1.4k
Aug ’23
WKWebView: Select Text and scroll beyond what's visible
Prime Objective I am trying to have a scroll view with a fixed header, a fixed footer, and a WKWebView in between. Using JavaScript, the height of the webView is determined and set to be large enough to hold the entire content. The Problem When selecting text on the webView, the view does not scroll when the edges are reached (this works if the webView is shown without being embedded in a Scroll view, or if it is the last element) What did I try? I tried reading the scroll view, or adding a gesture recognizer, but all of that does not work because the selection is essentially a system task Sourcecode Sourcecode to demonstrate the issue can be found on GitHub
1
0
334
Mar ’25
Recording WKWebView
I am trying to record the requests and responses in a WKWebView, but instruments does not seem to record them. Is this to be expected? The webView is set to inspectable, and I am using the HTTP Traffic instrument. All the requests the app is doing are recorded, but neither the original request for the webView, nor subsequent traffic is recorded. When I use Safari to inspect the webView, all I see is the last page (even when I start the inspector before the first request is made). How can I see these requests?
0
0
115
May ’25
Swift framework for Objective-C
Hello,hopefully, this is a real beginer question, so hopefully it is easy to answer …I want to create a new framework for an existing Objective-C app. And because Swift is all shiny, and we already are using Swift in other parts of the app, I am writing the framework in Swift.However, when I #include "${MODULENAME}-Swift.h" in my umbrella header, Xcode tells me on a clean compile: ‘'${MODULENAME}-Swift.h' file not found'If I comment that line, build, then uncomment it and build again, Xcode will find it. This, however, is unacceptable for, say, build servers.Questions:1) It appears, that when I am importing the Framework as a module (i.e. @import ${MODULENAME} ), I don't need to #include "${MODULENAME}-Swift.h" in my umbrella header.Is this true? Is it not necessary to explicitly expose the -Swift.h headers when importing the Framework as a module?2) This leads me to the next question:Do Swift Frameworks have to be imported as modules? The app is an old codebase and currently sets CLANG_ENABLE_MODULES to NO. Is it necessary to set this to YES when using a Swift Framework?3) Am I doing something wrong with the #import? If I can use the Framework not as a module, but #import <Framework/Umbrella.h> is good, what do I have to do to have{MODULENAME}-Swift.h available even on a clean compile?Again, hopefully these are simple questions, and someone can easily answer them 😉
3
0
7.1k
Dec ’20
CBService changed: How handle this in iOS 14 and 15?
Building my app with Xcode 13, a dependency threw an error related to the changes in CoreBluetooth: Some properties are now returned as optionals in iOS 15. Wanting to fix that, I would like to make sure that the library will run on both iOS 15 and SDKs prior to that, but the current availability markers will not help me:     func peripheralManager(_ peripheral: CBPeripheralManager, didAdd service: CBService, error: Error?) {         let peripheral: CBPeripheral         // So what I would like is something like this         // But this does not work :(         if  #available(iOS 15, *) {             guard let nonOptional = service.peripheral else {                 return             }             peripheral = nonOptional         } else {             peripheral = service.peripheral         }         let result: CBPeripheral = peripheral         print ("\(result)")     }``` This code will cause the compiler to throw an error both on Xcode 13 and Xcode 12. Is there any good way to solve this?
1
0
2.6k
Jun ’21
Request times out with iCloud Private Relay: Why?
We have our own backend, running on our own server. When iCloud Private Relay is enabled, the requests to the server time out. How can we find out what precisely is failing? TLS 1.3 is enabled on the backend finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=-2102, NSUnderlyingError=0x281b0a3d0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <CBAE9DA5-9988-4E55-A732-B759842E411F>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(     "LocalDataTask <CBAE9DA5-9988-4E55-A732-B759842E411F>.<1>" ), NSLocalizedDescription=The request timed out.,
2
0
1.3k
Nov ’21
Generics and AssociatedTypes
Sorry, I did not have a better title for this, I hope it gets clearer with code. The idea is to build a simple facade for Persistent Storage of some objects: class PersistantStorage<T, Codable, Identifiable> {     func store(_ object: T) throws { }          func objectFor(_ key: T.ID) -> T? {         return nil     } } As apparent, there is the generic type T, which is constrained to Codable and Identifiable. Now I want to use the later constraint to define my objectFor method, but the compiler complains: 'ID' is not a member type of type 'T' How would I do this? Or is this completely the wrong approach? Thanks Alex
1
0
1.5k
Jun ’22
Reading (NS)Bundle in iOS after relaunch
Sorry, I did not have a catchier title: Prelude Avid followers of my Twitter account know: I was looking for an easy, preferably human editable container for documents, and — being the old Mac developer I am — I went with bundles, stored in the Documents folder. The Problem At some point in my app, the user can choose which file to use. And then, of course, on next launch, that file should be used. Selecting the file works all nice and well, including reading from the created Bundle. The problem occurs when the App is relaunched, and reads the absoluteString of the file from the UserDefaults. This works, and I can create a URL from it. But creating a bundle fails, and I don't get any error. This happens on iOS 15 and 16, on device and in the simulator. Is this some permissions things? Is the url not formatted correctly? What is going on? To Reproduce I have created a sample App here: https://github.com/below/BundleSample Launch the App, in the Simulator or on device Select "Copy Bundle" (You can "Test Resource Bundle", but it does not matter) Finally, select "Test Documents Bundle". You should see a picture Close the app, either by stopping it in Xcode or force quit Restart the App Expected Result You see the picture Acutal Result You see the "Gear" placeholder
3
0
1.3k
Sep ’22
Info.plist preprocessing appears to have issues
The environment We have a rather large project, where the main app is ReactNative/Expo, and there are some native extensions and components. We are building two flavors, development and production, and these are deployed as separate applications, with separate bundle ids. Let's call them com.example.dev and com.example.prod. These flavors are build via Schemes. For each flavor, four variants exist ("debug", "release", "appstore", and "automation" The two flavors thus have different Shared Group Idenfiers (group.com.example.dev and group.com.example.prod, and we use a shared container to share data between this apps. The Main Objective We want to share the group identifier between the main app and its various extensions. If you have a better idea than what we are describing, please absolutely say so. I'd rather solve the problem, than care about details. The Solution We are putting the setting into a react native .env file, which is read by the react native parts and is basically structured like an .xcconfig file. For example, the debug.env file looks like this: BUILD_CONFIG=debug SHARED_GROUP_NAME_IOS=group.com.example.dev Then, there is a debug.xcconfig file, which includes the pods.xcconfig, and the debug.env file: #include "Pods/Target Support Files/Pods-App/Pods-App.debug.xcconfig" #include "../../react-native-config/debug.env" Side node: People who know about ReactNative files may interject that these environment variables should be available because there is a build setting INFOPLIST_PREFIX_HEADER = ${CONFIGURATION_BUILD_DIR}/../GeneratedInfoPlistDotEnv.h This, however does not seem to work for me, not in this nor in a a sample project. Finally, the Info.plist contains: <key>SharedGroupName</key> <string>$(SHARED_GROUP_NAME_IOS)</string> The idea then is that the app and the extensions can simply retrieve this value using Bundle.main.object(forInfoDictionaryKey: "SharedGroupName) The Issue Because the SharedGroupName key remained empty in the generated plist. I took a look at the Preprocessed-Info.plist in the build output, and found something extremely curious: <key>SharedGroupName</key> <string>$(group.com.example.dev)</string> So the variable was substituted with another variable! And thus, it ultimately get's resolved to an empty string Am I doing it wrong? At what point, in the build settings, the variable seems to resolve correctly How can I possibly debug this better? Is this a bug? Thanks for any hints or insights you might have
1
0
1.8k
Jun ’23
Accessibility Localization Questions
For practice, I have implemented accessibility labels and announcement in a very simple test app (All SwiftUI, all iOS 18). The app is not localized, default language is English. When running this on a German phone, odd things happen in the localization. My accessibility labels are read with an accent, but when they contain a url, the "dots" are read as the German "Punkt" (with an English Accent). When I am providing the same text as accessibility announcement, the same text (which is in English), is read with a German voice. I am also providing a Button with an "arrow.clockwise" image, and VoiceOver reads this, in an English Voice with "Refresh, Button". This is great and was to be expected. However, when the button is disabled, VoiceOver reads "Refresh, grau dargestellt, Button", all in an English Voice. Is this an error? Am I doing it wrong? The video at the link should show the issue https://share.icloud.com/photos/0757FJW2Q3fsA_cdhMX6ls46Q
2
0
1.2k
Dec ’24