Posts

Post not yet marked as solved
11 Replies
2.7k Views
I'm using the iOS simulator with a StoreKit configuration file. I can see that there have been transactions while the app has been closed, but my StoreKit 2 listener is never called with those updates to be able to finish them When I open my app from a cold start. I've added a listener on application(_:didFinishLaunching:launchOptions:) like this: func startObservingTransactions() { task = Task(priority: .background) { for await result in Transaction.updates { if case .verified(let transaction) = result { await transaction.finish() } } } } But the Transaction.updates loop never gets called (have added breakpoints to check). It's only ever called when a purchase is made, or subsequent transaction renewals when the app is open. Only then it will get the previously unfinished transactions. Steps to reproduce: Create an app with a StoreKit config file (with sped up transactions) to purchase an item Make a purchase then quit the app Wait for a bit for more transactions to be made while the app is closed. Open the app from a cold start and none of the transactions will be finished by the listener in your app. Cancel the subscription via the transaction manager. Close and open the app from a cold start. The first transaction will be finished by the listener but none of the others will be. In Apple's docs it says If your app has unfinished transactions, the listener receives them immediately after the app launches Why is this not the case?
Posted
by itsyusuf.
Last updated
.
Post not yet marked as solved
0 Replies
848 Views
I have a publisher, pipelinePublisher, which runs a combine pipeline of various operations, some of which send a state update to a statePublisher passed in as an argument. pipelinePublisher gets removed on completion of its Combine pipeline: func myFunction(_ request: MyRequest) -> PassthroughSubject<State, Never> { let statePublisher = PassthroughSubject<State, Never>() let presentationSubject = CurrentValueSubject<MyRequest, Error>(request) var pipelinePublisher: AnyCancellable! pipelinePublisher = presentationSubject .eraseToAnyPublisher() .checkSomething(returningStateTo: statePublisher) // a few more operators here... .sink( receiveCompletion: { [weak self] _ in self?.cancellables.remove(pipelinePublisher) // Crash happens here }, receiveValue: { _ in } ) pipelinePublisher.store(in: &cancellables) return statePublisher .receive(on: DispatchQueue.main) .eraseToAnyPublisher() } However, very occasionally when I call the function multiple times in very quick succession, the app crashes on the line self?.cancellables.remove(pipelinePublisher). This usually brings up one of two possible stack traces. This first is this: 2022-12-21 15:24:51.926131+0000 MyApp[23082:12933690] -[_NSCoreDataTaggedObjectID member:]: unrecognized selector sent to instance 0x8000000000000000 2022-12-21 15:24:51.931941+0000 MyApp[23082:12933690] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_NSCoreDataTaggedObjectID member:]: unrecognized selector sent to instance 0x8000000000000000' *** First throw call stack: ( 0 CoreFoundation 0x000000018040e7c8 __exceptionPreprocess + 172 1 libobjc.A.dylib 0x0000000180051144 objc_exception_throw + 56 2 CoreFoundation 0x000000018041d47c +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0 3 CoreFoundation 0x00000001804126c8 ___forwarding___ + 1308 4 CoreFoundation 0x0000000180414b4c _CF_forwarding_prep_0 + 92 5 libswiftCore.dylib 0x000000018be6ee68 $sSh8_VariantV6removeyxSgxF + 160 6 MyApp 0x00000001026c6080 $s12MyApp0A0C17myFunctiony7Combine12AnyPublisherVyAA12StateOs5NeverOGAA19MyRequestVFyAE11SubscribersO10CompletionOy_s5Error_pGcfU_ + 440 7 Combine 0x000000019baa2a70 $s7Combine11SubscribersO4SinkC7receive10completionyAC10CompletionOy_q_G_tF + 364 8 Combine 0x000000019baa2f28 $s7Combine11SubscribersO4SinkCy_xq_GAA10SubscriberA2aGP7receive10completionyAC10CompletionOy_7FailureQzG_tFTW + 20 9 Combine 0x000000019bb541cc $s7Combine10PublishersO7FlatMapV5Outer33_E91C3F00A6DFAAFEA2009FAF507AE039LLC7receive10completionyAA11SubscribersO10CompletionOy_7FailureQzG_tF + 1516 10 Combine 0x000000019bb55328 $s7Combine10PublishersO7FlatMapV5Outer33_E91C3F00A6DFAAFEA2009FAF507AE039LLCy_xq__qd__GAA10SubscriberA2aJP7receive10completionyAA11SubscribersO10CompletionOy_7FailureQzG_tFTW + 20 11 Combine 0x000000019bb53474 $s7Combine10PublishersO7FlatMapV5Outer33_E91C3F00A6DFAAFEA2009FAF507AE039LLC12receiveInner10completion_yAA11SubscribersO10CompletionOy_7FailureQzG_SitF + 1668 12 Combine 0x000000019bb52de4 $s7Combine10PublishersO7FlatMapV5Outer33_E91C3F00A6DFAAFEA2009FAF507AE039LLC4SideV7receive10completionyAA11SubscribersO10CompletionOy_7FailureQzG_tF + 20 13 Combine 0x000000019bac45ec $s7Combine6FutureC7Conduit33_3AE68DE9BADC00342FC052FEBC7D3BA6LLC7fulfillyys6ResultOyxq_GF + 1056 14 Combine 0x000000019bac4960 $s7Combine6FutureC7Conduit33_3AE68DE9BADC00342FC052FEBC7D3BA6LLC6finish10completionyAA11SubscribersO10CompletionOy_q_G_tF + 336 15 Combine 0x000000019bac2de4 $s7Combine6FutureC7promise33_3AE68DE9BADC00342FC052FEBC7D3BA6LLyys6ResultOyxq_GFyAA11ConduitBaseCyxq_GXEfU0_ + 156 16 Combine 0x000000019bac6b28 $s7Combine6FutureC7promise33_3AE68DE9BADC00342FC052FEBC7D3BA6LLyys6ResultOyxq_GFyAA11ConduitBaseCyxq_GXEfU0_TA + 16 17 Combine 0x000000019bae5140 $s7Combine11ConduitListO7forEachyyyAA0B4BaseCyxq_GKXEKF + 212 18 Combine 0x000000019bac2bfc $s7Combine6FutureC7promise33_3AE68DE9BADC00342FC052FEBC7D3BA6LLyys6ResultOyxq_GF + 716 19 Combine 0x000000019bac6b08 $s7Combine6FutureCyACyxq_Gyys6ResultOyxq_GcccfcyAGcfU_TA + 20 20 MyApp 0x0000000102541dd8 $s7Combine6FutureC12MyApps5Error_pRs_rlE9operationACyxsAE_pGxyYaKc_tcfcyys6ResultOyxsAE_pGccfU_yyYaYbcfU_TY2_ + 212 21 MyApp 0x0000000102542705 $s7Combine6FutureC12MyApps5Error_pRs_rlE9operationACyxsAE_pGxyYaKc_tcfcyys6ResultOyxsAE_pGccfU_yyYaYbcfU_TATQ0_ + 1 22 MyApp 0x000000010242f1a1 $sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTQ0_ + 1 23 MyApp 0x000000010242f749 $sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTA.24TQ0_ + 1 24 libswift_Concurrency.dylib 0x00000001b03bedcd _ZL23completeTaskWithClosurePN5swift12AsyncContextEPNS_10SwiftErrorE + 1 ) libc++abi: terminating with uncaught exception of type NSException The second is in the same place but with the error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber member:]: unrecognized selector sent to instance 0x8000000000000000' What is causing this? I've tried making pipelinePublisher optional and having a check that it exists before it gets removed but it does actually exist and still crashes. I can't figure this out, please help!
Posted
by itsyusuf.
Last updated
.
Post not yet marked as solved
1 Replies
874 Views
I have a StoreKit 2 transaction observer. I am making a purchase with StoreKit 1, by adding the payment to the SKPaymentQueue. I then want to listen to Transaction.updates to get details about the transaction. My listener looks like this: final class TransactionObserver { private var updates: Task<Void, Never>? init(delegate: TransactionObserverDelegate) { updates = newTransactionObserverTask() } private func newTransactionObserverTask() -> Task<Void, Never> { Task(priority: .utility) { [weak self] in for await verificationResult in Transaction.updates { await self?.handle(updatedTransaction: verificationResult) } } } private func handle(updatedTransaction verificationResult: VerificationResult<Transaction>) async { ... } } For some reason, the handle(updatedTransaction:) function never gets called on the first transaction. Only on subsequent renewals. Why? Am I doing something wrong? Shouldn't this call the listener when the transaction completes?
Posted
by itsyusuf.
Last updated
.
Post marked as solved
10 Replies
2.7k Views
Hey, there's an issue in the latest Xcode 14.1 beta (14B5024h) where importing the GameController module causes the build to fail. It produces the following error: Failed to build module 'GameController' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug Steps to reproduce Create new Xcode app project Add the line import GameController to the top of the file It can't build and fails with the above error. I've also filed a bug report with Apple (FB11538209). Please fix this issue!
Posted
by itsyusuf.
Last updated
.
Post not yet marked as solved
6 Replies
5.0k Views
I'm trying to access the MusicKit API but it keeps returning a 401 unauthorized error. I can't figure this out. I have this code to generate a Developer Token:const privateKey = fs.readFileSync("resources/AuthKey.p8").toString(); const teamId = "MYTEAMID"; const keyId = "MYKEYID"; const options = { algorithm: "ES256", expiresIn: "180d", issuer: "MYTEAMID", // your 10-character Team ID, obtained from your developer account header: { alg: "ES256", kid: "MYKEYID", // your MusicKit Key ID }, }; return new Promise((resolve: any, reject: any) =&gt; { jwt.sign({}, privateKey, options, (error, token) =&gt; { if (error) { return reject(error); } else { // token created return resolve(token); } }); });This generates a successful token. When decoded, this token has header the values like:{ "alg": "ES256", "typ": "JWT", "kid": "MYKEYID" }and the payload values like:{ "iat": 1558197586, "exp": 1573749586, "iss": "MYTEAMID" }I then try to use that in a curl request for a sample artist like `curl -v -H 'Authorization: Bearer &lt;MYTOKEN&gt;' "https://api.music.apple.com/v1/catalog/us/artists/36954"` but it comes back with a 401 error:Trying 23.13.216.88... * TCP_NODELAY set * Connected to api.music.apple.com (23.13.216.88) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * successfully set certificate verify locations: * CAfile: /etc/ssl/cert.pem CApath: none * TLSv1.2 (OUT), TLS handshake, Client hello (1): * TLSv1.2 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server key exchange (12): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS change cipher, Client hello (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS change cipher, Client hello (1): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384 * ALPN, server accepted to use h2 * Server certificate: * subject: businessCategory=Private Organization; jurisdictionCountryName=US; jurisdictionStateOrProvinceName=California; serialNumber=C0806592; C=US; ST=California; L=Cupertino; O=Apple Inc.; OU=Internet Services for Akamai; CN=itunes.apple.com * start date: May 1 00:00:00 2019 GMT * expire date: May 1 12:00:00 2020 GMT * subjectAltName: host "api.music.apple.com" matched cert's "api.music.apple.com" * issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 Extended Validation Server CA * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Using Stream ID: 1 (easy handle 0x7ff42a004600) &gt; GET /v1/catalog/us/artists/36954 HTTP/2 &gt; Host: api.music.apple.com &gt; User-Agent: curl/7.54.0 &gt; Accept: */* &gt; Authorization: Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjlYNFBRNUI5TkQifQ.eyJpYXQiOjE1NTgxOTcwNzgsImV4cCI6MTU3Mzc0OTA3OCwiaXNzIjoiVzY5REI0NzRTOSJ9.Erd6KRY7BkkMPMuptdMFcmerehRd_k7BEwqFz16lHhxw9qSYwGANNNat37a-hmw-l95p38Vz0n8Znwpu41kIVQ &gt; * Connection state changed (MAX_CONCURRENT_STREAMS updated)! &lt; HTTP/2 401 &lt; content-type: application/json; charset=utf-8 &lt; access-control-allow-origin: * &lt; strict-transport-security: max-age=31536000; includeSubDomains &lt; date: Sat, 18 May 2019 16:33:58 GMT &lt; x-cache: TCP_MISS from a104-117-183-52.deploy.akamaitechnologies.com (AkamaiGHost/9.6.4.1-25700704) &lt; * Connection #0 to host api.music.apple.com left intactWhy???
Posted
by itsyusuf.
Last updated
.