Posts

Post not yet marked as solved
0 Replies
138 Views
So I am trying to implement a custom control using UIViewRepresentable. Basically I want to wrap a UITextField to have more precise control over the focus behavior. I would like to have this control integrate with the SwiftUI focus system. As far as I have gotten, I understand that I would probably need to have my custom coordinator refer events back and fourth between the UITextField and the @FocusState somehow, but I cannot find any documentation on this. Is there an example out there somewhere, or else is there any open-source code which shows how @FocusState is working with existing controls?
Posted
by skohan.
Last updated
.
Post not yet marked as solved
0 Replies
132 Views
So I have asked this question on Stack Overflow as well: https://stackoverflow.com/questions/71374690/touch-events-seemingly-not-registering-at-top-of-screen I'm seeing very strange behavior within a view. Here's my layout: struct EventDetailViewContainer: View { let eventID: EventRecord.ID @State var event: EventRecord = EventRecord(keyResults: [], text: "", achievesKR: false) @State var editing: Bool = true var body: some View { if #available(iOS 15.0, *) { VStack { HStack { Spacer() Toggle("Editing", isOn: $editing) .padding() } EventDetailView(event: $event, editing: $editing) } } else { // Fallback on earlier versions } } } @available(iOS 15.0, *) struct EventDetailView: View { @Binding var event: EventRecord @Binding var editing: Bool @FocusState var textIsFocused: Bool var body: some View { VStack { TextField( "Event text", text: $event.text ) .focused($textIsFocused) .disabled(!editing) .padding() DatePicker("Event Date:", selection: $event.date) .disabled(!editing) .padding() Toggle("Goal is Reached?", isOn: $event.achievesKR) .disabled(!editing) .padding() HStack { Text("Notes:") Spacer() } .padding() TextEditor(text: $event.notes) .disabled(!editing) .padding() Spacer() } } } struct EventRecord: Identifiable, Equatable { typealias ID = Identifier struct Identifier: Identifiable, Equatable, Hashable { typealias ID = UUID let id: UUID = UUID() } let id: ID var keyResults: [KeyResult.ID] var date: Date var text: String var notes: String var achievesKR: Bool init( id: ID = ID(), keyResults: [KeyResult.ID], date: Date = Date(), text: String, notes: String = "", achievesKR: Bool ) { self.id = id self.keyResults = keyResults self.date = date self.text = text self.notes = notes self.achievesKR = achievesKR } } So this works perfectly when I run it as an iPad app, but when I run it on the simulator, the the top toggle doesn't respond to text input. The strange thing is, when I simply duplicate the toggle, the top one doesn't work and the bottom one works perfectly: struct EventDetailViewContainer: View { let eventID: EventRecord.ID @State var event: EventRecord = EventRecord(keyResults: [], text: "", achievesKR: false) @State var editing: Bool = true var body: some View { if #available(iOS 15.0, *) { VStack { HStack { Spacer() Toggle("Editing", isOn: $editing) .padding() } HStack { Spacer() Toggle("Editing", isOn: $editing) .padding() } EventDetailView(event: $event, editing: $editing) } } else { // Fallback on earlier versions } } } It seems like this should be totally unrelated to the touch behavior of the other views. Btw this is being displayed in the context of a navigation view. Is there anything that can explain this? And how can I fix it? Here's a gif of the behavior being demonstrated:
Posted
by skohan.
Last updated
.
Post not yet marked as solved
0 Replies
334 Views
So I am trying to load a preview for a SwiftUI view, and it always fails with this error: MessageSendFailure: Message send failure for update ================================== |  RemoteHumanReadableError: The operation couldn’t be completed. XPC error received on message reply handler |   |  BSServiceConnectionErrorDomain (3): |  ==NSLocalizedFailureReason: XPC error received on message reply handler |  ==BSErrorCodeDescription: OperationFailed What does this mean and how can I fix it? The previews on my other views are working fine. Here's the view in question: import SwiftUI @available(iOS 15.0, *) struct EventEntryView: View {     @Environment(\.dismiss) var dismiss     let keyResult: KeyResult     @State var text: String = ""     @FocusState var textIsFocused: Bool     @State var completesKeyResult: Bool = false     var body: some View {         VStack {             Button("Cancel") {                 dismiss()             }             Text("Key Result: \(keyResult.text)")                 .padding()             Toggle("Goal is Reached?", isOn:$completesKeyResult)                 .padding()             TextField(                 "Event note",                 text: $text             )             .focused($textIsFocused)             .onSubmit {                 print("Note: \(text)")             }             .padding()             Button("Record Event") {                 print("Recording: \(text) goal is reached? \(completesKeyResult)")             }             .padding()         }     } } struct EventEntryView_Previews: PreviewProvider {     static var previews: some View {         if #available(iOS 15.0, *) {             EventEntryView(keyResult: KeyResult.default)         } else {             Text("preview")         }     } } This view also works when it's included in other views for preview, it's only not working for this preview.
Posted
by skohan.
Last updated
.
Post not yet marked as solved
0 Replies
231 Views
So we're trying to distribute an app to one of our investors. He was previously in our internal testing group, and we have since switched to distributing the app using external testing via public link, so we've taken him out of our internal testing group and started to distribute the app that way. However, when he tries to download the app, he sees this on the app page inside of testflight: Tester Removed The developer removed you from the test program So it seems like somehow his status as a former internal tester is overriding the public link. How can we solve this? It's extremely important to get him access to the app.
Posted
by skohan.
Last updated
.
Post not yet marked as solved
5 Replies
4.6k Views
I got this message when installing something via PIP today:DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.Is there a plan in place to update the default version for macOS? I believe the current default is stil 2.7.
Posted
by skohan.
Last updated
.
Post not yet marked as solved
3 Replies
742 Views
I'm working on an IoT device, and we would like to streamline the onboarding process as much as possible.We have looked at the Apple TV as a good example: the user just touches their phone to the device, and the Apple TV copies the login for the network the iPhone is currently connected to.Is it possible to achieve something like this for a 3rd party device?
Posted
by skohan.
Last updated
.
Post not yet marked as solved
0 Replies
290 Views
I'm attemptig to build a custom aperture exporter to get all my photos out so I can migrate to catalina. It would be extremely useful to be able to get a unique ID for each image as it's being exported. It looks like the export plugin idetifies images via an index which is relative to the export; is there a way to get some kind of a uuid for each image? I assume aperture must somehow identify images internally.
Posted
by skohan.
Last updated
.
Post marked as solved
2 Replies
314 Views
So now that Aperture is no longer supported on Catalina, I want to implement a simple export plugin to get my photos out.I found some documentation here:https://developer.apple.com/library/archive/documentation/Aperture/Conceptual/AppleApp_Aperture_3.4/Overview/Overview.htmlBut I can't find the examples on disk. I assume they're just not shipped with the newer versions of XCode since Aperture has been EOL for so long.Is there anywhere to get the code examples, and whatever libraries I need to implement an Aperture plugin?
Posted
by skohan.
Last updated
.
Post not yet marked as solved
2 Replies
856 Views
I have a project which links against the bullet physics library, and while it worked perfectly under XCode 10.3, the build suddenly fails with zero changes to the project after updating to XCode 11.The project in question is a C++ library project, generated using swift package manager (`swift package generate-xcodeproj`). It's built using clang, with C++ dialect C++17.The error is being thrown from this file: https://github.com/bulletphysics/bullet3/blob/master/src/LinearMath/btVector3.h on line 335:y = bt_splat_ps(y, 0x80);The error is this: "Argument value 10880 is outside the valid range [0, 255]"Here bt_splat_ps is a macro defined like so:#define _mm_shuffle_ps(a, b, mask) \ (__m128)__builtin_ia32_shufps((__v4sf)(__m128)(a), (__v4sf)(__m128)(b), \ (int)(mask)) #define BT_SHUFFLE(x, y, z, w) ((w) << 6 | (z) << 4 | (y) << 2 | (x)) #define bt_pshufd_ps(_a, _mask) _mm_shuffle_ps((_a), (_a), (_mask)) #define bt_splat_ps(_a, _i) bt_pshufd_ps((_a), BT_SHUFFLE(_i, _i, _i, _i)) ... y = bt_splat_ps(y, 0x80);So it looks like maybe this error is coming from the argument which is provided to `__builtin_ia32_shufps`?Is there anything which has changed in the XCode 11 tools which would explain why this was previously working and no longer works?
Posted
by skohan.
Last updated
.
Post not yet marked as solved
1 Replies
373 Views
I am developing an iOS app which will connect to a server via websocket. Authentication requires me to sign a token using a .pem file.My question is, what's the "correct" way to store my certificate securely? I can put it in the bundle, or serialize it and include it in the source code, but is this the best way? Is there an official designated way to deal securely with certificates and keys on iOS?
Posted
by skohan.
Last updated
.
Post not yet marked as solved
2 Replies
861 Views
So I am developing an application which interacts with a bluetooth peripheral, and I am running into the issue that there is currently no way to tell if the user rejected the peripheral's pairing request or not.The current flow which is implemented is:1. Scan for peripherals2. Connect to peripheral3. Discover services4. Discover characteristics(Pairing request is sent here by the peripheral, and the OS presents the pairing permission popup)5. Read from characteristicsI would like to present an error state if the user rejects the pairing request, but I do not seem to be able to tell whether this has happened:- There is no error callback executed on the CBCentralManagerDelegate or CBPeripheralDeleagate- All the characteristics are discovered, whether or not paring has been accepted- Reading from/ writing to characteristics fails silently: i.e. the peripheral just doesn't return a value when a characteristic is read from, but there's no affirmative error to let me know that it's because of a permission failure.According to [this article](https://medium.com/@kbabcockuf/bridging-the-gap-bluetooth-le-security-653078852c24) it indicates that there's no direct way to know that the pairing request was cancelled.According to [this answer](https://stackoverflow.com/questions/28351579/bluetooth-4-0-low-energy-and-ios-how-do-i-detect-if-device-is-bondable-or-not) it looks as if there is not currently a direct way to detect whether a peripheral is bonded in iOS.Is there any known workaround for this issue?
Posted
by skohan.
Last updated
.
Post not yet marked as solved
7 Replies
1.8k Views
I'm working on a graphics application, and I'm experimenting with parallelizing the rendering and simulation. My first attempt has been using three queues: the main queue for simulation, a queue for rendering, and a queue for synchronization: let renderQueue = DispatchQueue(label: "render", qos: .userInitiated) let syncQueue = DispatchQueue(label: "sync", qos: .userInitiated) // The currentState is the shared state between rendering and simulation var currentState = SimState() func run() { DispatchQueue.main.async { while true { let newState = simulation.update(currentState) syncQueue.sync { currentState = newState } } } renderQueue.async { var renderState: SimState! syncQueue.sync { renderState = currentState } renderer.render(renderState) } }So this works, but with performance stutters. When I profile the application, I can see that there are periods where all my queues are blocked at the same time.I notice that in the slides for the "metal game performance optimization" from Apple, they are actually using pthread primitives for parallelization.So is pthread just more suitable for performance-critical parallelization, or is Dispatch still suitable for this application?
Posted
by skohan.
Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
`So I am attempting to use GLFW with Swift to create a very simple application, and I am running into an issue I don't understand with AppKit.Currently the application should only create a window and then poll input on a timer. My `main.swift` looks like this://main.swift // GLFW is imported via bridging header import Foundation glfwInit() let window = glfwCreateWindow(400, 400, "window", nil, nil) let timer = DispatchSource.makeTimerSource() timer.schedule(deadline: DispatchTime.now() + 1.0, repeating: 1.0, leeway: DispatchTimeInterval.nanoseconds(10)) timer.setEventHandler { DispatchQueue.main.sync { print("work work work") glfwPollEvents() } } timer.resume() dispatchMain()So the problem is, when I run this application, I get the following fatal exception:Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'nextEventMatchingMask should only be called from the Main Thread!'What's strange is, this exception is resulting from the following line being executed from within `glfwPollEvents`: NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];I thought this should be safe, siunce it is being called from within a `DispatchQueue.main.sync` block, but apparently the main queue does not guarantee that the main thread is being used as I am also getting this warning from GLFW:Attempting to perform block on main runloop, but the main thread as exited. This message will only log once. Break on _CFRunLoopError_MainThreadHasExited to debug.So my questions are:1. What is the difference between the main queue and the main thread, and2. What is the correct way to execute timed repeating work on the main thread
Posted
by skohan.
Last updated
.