Post

Replies

Boosts

Views

Activity

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
6.6k
Apr ’18
Adding App Group Container without Team Account?
Hello,I have a mobile provisioning profile and a developer certificate for a certain team (let’s call it Team ABC), but I am not a member of that team (i.e., in Xcode accounts, I am not logged in as a member of that team).When I want to add a container in the App Groups capability, Xcode tells me I don’t have an account to do that.Is it correct that I must have an active developer account for Team ABC in order to add a container in App Groups?ThanksAlex
0
1
783
Dec ’19
NSUserActivity does not appear in Shortcuts app
Hello, in my app, I am using NSUserActivity in order to donate SiriShortcuts. The one that I am donating through the INUIAddVoiceShortcutViewController shows up in the Shortcuts Application, the one that I am donating via becomeCurrent does not. The later does appear in the Siri Suggestion pull-down. For both I am using the same identifier, one comes without additional userData, one does. Might that be the issue?
0
0
615
Jul ’20
SwiftUI: Show Modal Dialog from … anywhere?
Context: Authorized Network requests. I have a process (a publisher, to be precise), which will give me a fresh access token for a request. To do that, I may need user interaction, i.e. show a View, Alert, or something like that. How can I do that in SwiftUI? Can I just (modally) display something, without explicitly being in a View body? Should I have to pass in a "superview" to do this, or do you have other ideas? Thanks Alex
0
0
1.2k
Mar ’21
@EnvironmentObject and Protocols?
I would like to declare an @EnvironmentObject as a protocol, namely as protocol AccessTokenProvider: Authenticator {     func accessToken() - AccessTokenPublisher } where Authenticator is public class Authenticator: NSObject, ObservableObject However, when I add this to the environment as var authenticator: AccessTokenProvider = MyAuthenticator() […] ContentView().environmentObject(authenticator) the compiler throws an error at: struct ContentView: View { // error: property type 'AccessTokenProvider' does not match that of the 'wrappedValue' property of its wrapper type 'EnvironmentObject'     @EnvironmentObject var authenticator: AccessTokenProvider                            ^ Is this even a good idea? If so, what am I doing wrong?                            ^
2
1
4.8k
Mar ’21
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.4k
Jun ’21
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.5k
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.1k
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
912
Mar ’22
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.4k
Jun ’22
MKMapView and Accessibility
As I currently live in ReactNative Hell, I like to flesh out all my native iOS demos and samples to the max. Including things like accessibility. Recently, I wrote a very simple demo containing a map, and I stumbled upon some issues I was unable to resolve. I think they present very general usecases, and so I would be happy if anyone of you had any idea. The condensed source code for the issues can be found on GitHub Issue 1: The Phantom Overlay To reproduce Run the app on a device, and be sure that VoiceOver is on. Swipe right to get to the Annotations. Expected Result The title of the annotation is read. Actual Result The title of the annotation is read twice. What I know For every annotation on the map view, there is also an overlay, an MKCircle, generated by an MKCircleRenderer. When this overlay is not present, the title is — correctly — only read once. What I have tried In ViewController.swift, lines 54 and 92, I have set both the overlay's and the renderer's isAccessibilityElement property to false. This does not fix the issue (probably because neither of them are the actual views). The overlay should never be an accessible element. Any information should be encoded in the annotation (e.g. "There is a 10m region around this marker") Issue 2: The Unknown Trait While it is correct that the title of the annotation should be read, there is no indication that the annotation can be clicked or interacted with. I have set annotationView.accessibilityTraits = [.button], but this does not change anything. My expectation would be "Cologne Cathedral, Button" or a similar hint that the item is clickable. Issue 3: The Unreachable Callout With VoiceOver active, click on an annotation. I have taken some hints from Stackoverflow, and tried to disable the accessibility on the annotation, and enable it on the callout. This leads to the callout being reachable somehow, but it is absolutely not obvious if you can not see the screen. How can I indicate to the VoiceOver user that now a callout is being shown? A Working Extra: The Annotation Rotor The app also contains a custom rotor, to go through the annotations one by one, without also reading the default Points-Of-Interest on the map. Interestingly (or maybe rather as expected), the title of the annotation is correctly only read once. I whould be extremely happy to get some feedback on these issues, it sounds like most of them could be rather common. Thanks! Alex
1
1
1.7k
Jul ’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.1k
Sep ’22