Post

Replies

Boosts

Views

Activity

How to exit from `RunLoop`
I'm subclassing InputStream from iOS Foundation SDK for my needs. I need to implement functionality that worker thread can sleep until data appear in the stream. The test I'm using to cover the functionality is below: func testStreamWithRunLoop() { let inputStream = BLEInputStream() // custom input stream subclass inputStream.delegate = self let len = Int.random(in: 0..<100) let randomData = randData(length: len) // random data generation let tenSeconds = Double(10) let oneSecond = TimeInterval(1) runOnBackgroundQueueAfter(oneSecond) { inputStream.accept(randomData) // input stream receives the data } let dateInFuture = Date(timeIntervalSinceNow: tenSeconds) // time in 10 sec inputStream.schedule(in: .current, forMode: RunLoop.Mode.default) // RunLoop.current.run(until: dateInFuture) // wait for data appear in input stream XCTAssertTrue(dateInFuture.timeIntervalSinceNow > 0, "Timeout. RunLoop didn't exit in 1 sec. ") } Here it is the overriden methods of InputStream public override func schedule(in aRunLoop: RunLoop, forMode mode: RunLoop.Mode) { self.runLoop = aRunLoop // save RunLoop object var context = CFRunLoopSourceContext() // make context self.runLoopSource = CFRunLoopSourceCreate(nil, 0, &context) // version 0 CFRunLoopSource let cfloopMode: CFRunLoopMode = CFRunLoopMode(mode as CFString) CFRunLoopAddSource(aRunLoop.getCFRunLoop(), self.runLoopSource!, cfloopMode) } public func accept(_ data: Data) { guard data.count > 0 else { return } self.data += data delegate?.stream?(self, handle: .hasBytesAvailable) if let runLoopSource { CFRunLoopSourceSignal(runLoopSource) } if let runLoop { CFRunLoopWakeUp(runLoop.getCFRunLoop()) } } But calling CFRunLoopSourceSignal(runLoopSource) and CFRunLoopWakeUp(runLoop.getCFRunLoop()) not get exit from runLoop. Runloop exits after 10 seconds. [![Test is failing][1]][1] Does anybody know where I'm mistaking ? Thanks all! PS: [2]: Here the Xcode project on GitHub
1
0
735
Jan ’23
Can't create IOS_DISTRIBUTION certificate using AppStore Connect API. Error 409/ENTITY_ERROR.ATTRIBUTE.INVALID/Invalid Certificate
I'm trying to create a certificate [using **AppStore Connect API**][1]. For that I created valid *(I used it to fetch certificates list using GET method, it works)* JWT token : `eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiIsImtpZCI6IkZZREszQlVIOE0ifQ.eyJpc3MiOiIwNWNiN2M3Yy00Y2RkLTRlYjMtYWRiZC1kNzkwYWEyYTBhNjEiLCJleHAiOjE1ODc3OTg1MjMuMjI3ODIyLCJhdWQiOiJhcHBzdG9yZWNvbm5lY3QtdjEifQ.Vs1xpLL2xF_WtQNXg3m1XySG-mdSsR2fQalhDgFy5NkIhtRWtWfxkyxMOTe3la-zqWAKjZ7iiCGf8Fkm5_cl2Q`Pretty printed JSON Http body is: { "data":{ "attributes":{ "certificateType":"IOS_DISTRIBUTION", "csrContent":"'$(cat private.csr | base64)'" }, "type":"certificates" } }where `private.csr` file generated by **Keychain Access** and contains: -----BEGIN CERTIFICATE REQUEST----- MIIClDCCAXwCAQAwTzEnMCUGCSqGSIb3DQEJARYYaWdvci5rb3Rrb3ZldHNAZHVt bXkuY29tMRcwFQYDVQQDDA5JZ29yIEtvdGtvdmV0czELMAkGA1UEBhMCQlkwggEi MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDnON+o9OZCRAF0oJqnjt7RBDJj ZDJjj04iH/UvqEaJ/T8iq7iWZFQBpnLD11vcProtA+v4rNI/H5N4R+BPJclmvbPE BGOSvyQHXf92blCzL9e9Lqk6GVTvdh+7YDlJV+dTqceP0evQleybWn7bp/lnRKtb o5NWOfDKv5dgUXEFi5e0Hy9FMem5AlKGN7NObSypi7mBqscpRpg70ZLrODZxg8Ee E/R8ZHWesuIvMBp+m4J6O2+gMRTOVb+jA+577StbkZM4lxDhYB1XEy3nmXkCJXqi C/mgxmfNnCBK4s9OYJnEVu703aPYm9c9qI4eHdQzyEE0WqRits2CDckWGIBFAgMB AAGgADANBgkqhkiG9w0BAQsFAAOCAQEAtLXvHejf2zPlMhJeWU6BBnsc2z2P6ZWS 92GZCMpTLX/apN8IjzxZWG+x5hW4ub6YL3SWTgz7l4OJzyIzV4t5xupcRwGessOt XvBvDEshd9k7LkueNtoXO6buJEKa5sDEZ+31BxUKGgqRXBTxsVxvTJSQTF1quutN j8AQzWBRRp1HkTRS89iBS1G7eY9NR1Abvp2Omr8RRdvqsOm5i1aJ7HvOc4SxlnyL PZFGYQFKCX1wT6la8RYPbq96hAAwAKDvCf2pqT9iYwJOOPRHvpLuA8N9TlQGjEtJ O+QUtQJ4PFTRTGhHxNEDXdGRH2JMSQD1ral4PiYy/YCfNZiyrtMDgg== -----END CERTIFICATE REQUEST-----Next I perform `curl` request: curl -v -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiIsImtpZCI6IkZZREszQlVIOE0ifQ.eyJpc3MiOiIwNWNiN2M3Yy00Y2RkLTRlYjMtYWRiZC1kNzkwYWEyYTBhNjEiLCJleHAiOjE1ODc3OTg1MjMuMjI3ODIyLCJhdWQiOiJhcHBzdG9yZWNvbm5lY3QtdjEifQ.Vs1xpLL2xF_WtQNXg3m1XySG-mdSsR2fQalhDgFy5NkIhtRWtWfxkyxMOTe3la-zqWAKjZ7iiCGf8Fkm5_cl2Q' -d '{"data":{"attributes":{"certificateType":"IOS_DISTRIBUTION","csrContent":"'$(cat private.csr | base64)'"},"type":"certificates"}}' https://api.appstoreconnect.apple.com/v1/certificatesBut server responds the error:&gt; &lt; HTTP/1.1 100 Continue&gt; * We are completely uploaded and fine&gt; &lt; HTTP/1.1 409 Conflict&gt; &lt; Server: daiquiri/3.0.0&gt; &lt; Date: Sat, 25 Apr 2020 07:20:08 GMT&gt; &lt; Content-Type: */*&gt; &lt; Content-Length: 254&gt; &lt; Connection: keep-alive&gt; &lt; Cache-Control: no-store, no-cache, must-revalidate&gt; &lt; Pragma: no-cache&gt; &lt; X-XSS-Protection: 1; mode=block&gt; &lt; X-Frame-Options: ALLOW-FROM https://devcms.apple.com SAMEORIGIN&gt; &lt; Strict-Transport-Security: max-age=31536000; includeSubDomains&gt; &lt; X-Request-ID: QRCVNTSDFD6UA4O62U7ZZM67ZM&gt; &lt; X-Rate-Limit: user-hour-lim:3600;user-hour-rem:3598;&gt; &lt; x-daiquiri-instance: daiquiri:38493002:pv50p00it-hyhk10063901:7987:20E24&gt; &lt;&gt; {&gt; "errors" : [ {&gt; "id" : "7470a152-5d89-4d85-8e6e-987754c519c3",&gt; "status" : "409",&gt; "code" : "ENTITY_ERROR.ATTRIBUTE.INVALID",&gt; "title" : "An attribute in the provided entity has invalid value",&gt; "detail" : "Invalid Certificate"&gt; } ]&gt; * Connection #0 to host api.appstoreconnect.apple.com left intactI already have no idea what is wrong. I checked that there are no limits for iOS Distribution certificates in my account. [1]: https://developer.apple.com/documentation/appstoreconnectapi/create_a_certificate
1
0
3.3k
Apr ’20