Post

Replies

Boosts

Views

Activity

TestFlight – can't add build to external group
Hi, I'm unable to add the 3rd build of my TestFlight app to any external testing group (but I can for an internal testing group). The 2nd build was successfully added to an external testing group, the 3rd build has the status "Ready to test", and I've expired all other builds. I've also completed the "What to test" section in English (U.K) and English (U.S). Any idea what I might be doing wrong? Thanks!
1
1
543
Jun ’24
accuracy vs RSSI to compare proximity to iBeacons
Hi, I want to see which iBeacon is the closest in a medium-sized radius (I don't care about actual distances). CLBeacon has a proximity property –- but if two iBeacons have the same proximity enum value I'd like to disambiguate using one of CLBeacon's other properties. Should I pick the one with the smallest accuracy, which per Apple's docs should should decrease with distance, or should I pick the one with the highest rssi? Or a mix of both? Thanks in advance!
0
0
494
Aug ’22
Lazy encryption in NWListener
Hi, I'd like to lazily enable encryption on my NWListener. Basically, right now, I've implemented encryption in the NWListener's initialization phase, like so: import CryptoKit import Network extension NWParameters {     // Create parameters for use with Connection and Listener.     convenience init(secret: String, identity: String) {         let tcpOptions = NWProtocolTCP.Options()         tcpOptions.enableKeepalive = true         tcpOptions.keepaliveIdle = 2         let tlsOptions = NWProtocolTLS.Options()         let authenticationKey = SymmetricKey(data: secret.data(using: .utf8)!)         var authenticationCode = HMAC<SHA256>.authenticationCode(for: identity.data(using: .utf8)!, using: authenticationKey)         let authenticationDispatchData = withUnsafeBytes(of: &authenticationCode) { (ptr: UnsafeRawBufferPointer) in             DispatchData(bytes: ptr)         }         let psk = authenticationDispatchData as __DispatchData         var identityData = identity.data(using: .unicode)!         let identityDispatchData = withUnsafeBytes(of: &identityData) { (ptr: UnsafeRawBufferPointer) in             DispatchData(bytes: ptr)         }         let psk_identity = identityDispatchData as __DispatchData sec_protocol_options_add_pre_shared_key( tlsOptions.securityProtocolOptions, psk, psk_identity ) let ciphersuite = tls_ciphersuite_t(rawValue: TLS_PSK_WITH_AES_128_GCM_SHA256)!  sec_protocol_options_append_tls_ciphersuite( tlsOptions.securityProtocolOptions, ciphersuite )         self.init(tls: tlsOptions, tcp: tcpOptions)         self.includePeerToPeer = true         let customProtocol = NWProtocolFramer.Options(definition: TLVMessageProtocol.definition)       self.defaultProtocolStack.applicationProtocols.insert(customProtocol, at: 0)     } } The preshared key (secret) would be a combination of the user's and a peer's CLBeacon major/minor. However, I want to be able to create an NWListener before detecting a peer's CLBeacon, since it's quite a heavy and time-consuming operation. Is there a way to create an NWListener first, and then give it the encryption / preshared key later?
5
0
947
Aug ’21
Get contact info of current user
Hi, I want to display the contact card of the current user with a CNContactViewController. I'm wondering how I can retrieve only the contact info of the current user. I was thinking of filtering through the contacts using NSFullUserName(), but the user could have changed their contact name to something other than their username. Is there a way to get the contact info of just the current user?
0
0
674
Jul ’21
Replace Xcode Project with Swift Package while keeping same repo?
Hi, I'm currently refactoring my Xcode project into a Swift Package with multiple modules, which I combine with a lightweight Xcode project using an XCWorkspace (kind of like Pointfree's isowords). Right now, my Xcode project is hosted on a GitHub repo. However, with this refactoring, it's the Swift Package which will be hosted on GitHub. Can I replace my Xcode project with the Swift Package on the repo, without losing all my history? Will the history of files inside my Xcode project still show up?
0
0
493
Jun ’21
Detect when @EnvironmentObject variable has been initialised inside property wrapper
I'm making a custom property wrapper, and inside of it is an @EnvironmentObject variable. A dummy version of it looks like this: swift @propertyWrapper struct Store: DynamicProperty {     @EnvironmentObject var centralStore: CentralStore     var wrappedValue: CentralStore {         centralStore     }     @State var value: Int = 0     var cancellable: AnyCancellable?     init() {         cancellable = centralStore             .statePublisher             .filter { (n: Int) in n % 2 == 0 }             .sink { [_value] n in _value.wrappedValue = n }     } } When I run this, the program crashes with "Fatal error: No ObservableObject of type CentralStore found." (and I double-checked that I injected it into the view hierarchy with environmentObject(_:)). It seems like the initialisation of the @Store property wrapper is run before centralStore is found - so accessing it leads to a fatalError. Is there a way to detect that my CentralStore environment object has been found, so that I can subscribe to the statePublisher there? (property observers don't seem to work)
1
0
1.1k
May ’21
Convert CALayerGradient to SwiftUI Gradient?
Hi folks! I'm trying to recreate the Instagram app icon gradient in SwiftUI, and came across this code which replicated it perfectly: var view = UILabel() view.frame = CGRect(x: 0, y: 0, width: 1024, height: 1024) view.backgroundColor = .white let layer0 = CALayer() layer0.backgroundColor = UIColor(red: 0.881, green: 0.106, blue: 0.496, alpha: 1).cgColor layer0.bounds = view.bounds layer0.position = view.center view.layer.addSublayer(layer0) let layer1 = CAGradientLayer() layer1.colors = [ &#9;&#9;UIColor(red: 0.259, green: 0.389, blue: 0.874, alpha: 1).cgColor, &#9;&#9;UIColor(red: 0.835, green: 0.208, blue: 0.522, alpha: 0).cgColor ] layer1.locations = [0.04, 1] layer1.startPoint = CGPoint(x: 0.25, y: 0.5) layer1.endPoint = CGPoint(x: 0.75, y: 0.5) layer1.transform = CATransform3DMakeAffineTransform(CGAffineTransform(a: 0.33, b: 0.9, c: -0.9, d: 0.33, tx: 0.56, ty: -0.16)) layer1.bounds = view.bounds.insetBy(dx: -0.5*view.bounds.size.width, dy: -0.5*view.bounds.size.height) layer1.position = view.center view.layer.addSublayer(layer1) // + some more constraints stuff However, as you see, this is using the Core Animation libarary, of which I have absolutely no knowledge, and couldn't possibly translate to SwiftUI Gradient code myself. Maybe I could use UIViewRepresentable? However, I want the resulting view / gradient to conform to ShapeStyle so that I can use it with .fill(_: ShapeStyle) on any Shape I want (I'm actually using a brilliant tool by Quassum Manus to convert SVG code to a SwiftUI Shape). Many thanks!
0
0
1k
Apr ’21
Should not require a network connection - Swift Student Challenge
Hi, I'm thinking of using Network Framework's peer-to-peer capabilities for this years WWDC 2021 Swift Student Challenge. In the requirements, they say that "your Swift playground should not rely on a network connection". Peer-to-peer doesn't require an actual network connection, but just for the Wi-Fi to be turned on (similar to if I were using MultipeerConnectivity). Does needing Wi-Fi to be toggled on constitute requiring a network connection, even though I don't need a connection per se?
1
0
638
Mar ’21
Network Framework or MultipeerConnectivity?
Hi, I'm wondering if I should choose between Network Framework or MultipeerConnectivity for my peer-to-peer needs. It'll only be between two devices, and won't be with huge amounts of data (some text and an image). Since I'm using SwiftUI, I won't be needing to support older iOS versions. I like the idea of Network Framework - https://developer.apple.com/documentation/network/nwparameters/3020639-includepeertopeer, because: It's newer, so it has a much nicer API which doesn't feel like a thin layer over Objective-C. It lets me define my own transport protocol - https://developer.apple.com/documentation/network/nwprotocolframer, so I have more fine-grain control over how I send, receive, and parse my messages. Meanwhile, MultipeerConnectivity seems to use a weird combination of TCP and UDP which is abstracted away from us. What do you think?
1
0
1.4k
Mar ’21