第一个测试将启动,大约半秒钟后,Xcode将锁定,而不是启动另一个测试。之后大约30秒,Xcode崩溃,我得到以下崩溃日志(请参见下文)。
Process: Xcode [823]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 11.0 (14936)
Build Info: IDEFrameworks-14936000000000000~3
App Item ID: 497799835
App External ID: 832762837
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Xcode [823]
User ID: 501
Date/Time: 2019-09-23 16:39:38.684 -0700
OS Version: Mac OS X 10.14.6 (18G95)
Report Version: 12
Bridge OS Version: 3.6 (16P6571)
Anonymous UUID: BC74C3A5-0B03-9716-16C5-8C448AD75627
Time Awake Since Boot: 1600 seconds
System Integrity Protection: enabled …Run Code Online (Sandbox Code Playgroud) 我有两个用于测试我的应用程序的iPhone.
在设备A上:
NSLog(@"Unfinished Transactions: [%i]", [[SKPaymentQueue defaultQueue].transactions count]);
Run Code Online (Sandbox Code Playgroud)
哪个输出:"未完成的交易:[0]"
当我做的时候:
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
Run Code Online (Sandbox Code Playgroud)
功能
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
Run Code Online (Sandbox Code Playgroud)
在Transactions数组中调用17个项目,每个项目都标记为RESTORED.所以,我循环设置并调用[[SKPaymentQueue defaultQueue] finishTransaction: transaction]每个.
在处理每个项目之后,(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue被调用,并且[[queue transactions] count]等于4,而不是17,这是一个令人惊讶的事情.
如果我[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]在这个设备上重新运行,我会反复得到相同的结果 - 尽管已经告诉每个事务我希望它从队列中删除,但更新的事务会被调用,需要处理17个项目.
在设备B上,
$NSLog(@"Unfinished Transactions: [%i]", [[SKPaymentQueue defaultQueue].transactions count]);
Run Code Online (Sandbox Code Playgroud)
仍然输出"未完成的交易:[0]"
我跑的时候
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
Run Code Online (Sandbox Code Playgroud)
, 功能
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
Run Code Online (Sandbox Code Playgroud)
永远不会被召唤.终于
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
Run Code Online (Sandbox Code Playgroud)
被称为
[[queue transactions] count]
Run Code Online (Sandbox Code Playgroud)
等于0.
可能是什么导致了这个?这几乎就像支付队列链接到设备ID,而不是测试帐户Apple ID.另外,请原谅这个问题的可怕格式,我还是习惯了StackOverflow.:)
我编写了一个NSURLProtocol将检查http针对plist本地路径映射的URL的出站请求并改为提供本地内容,然后使用它来缓存它NSURLCache:
- (void)startLoading
{
//Could this be why my responses never come out of the cache?
NSURLResponse *response =[[NSURLResponse alloc]initWithURL:self.request.URL
MIMEType:nil expectedContentLength:-1
textEncodingName:nil];
//Get the locally stored data for this request
NSData* data = [[ELALocalPathSubstitutionService singleton] getLocallyStoredDataForRequest:self.request];
//Tell the connection to cache the response
[[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageAllowed];
//Have the connection load the data we just fetched
[[self client] URLProtocol:self didLoadData:data];
//Tell the connection to finish up
[[self client] URLProtocolDidFinishLoading:self];
}
Run Code Online (Sandbox Code Playgroud)
我限制了本地数据被提取到一个的次数.第一次获取它的意图来自于它 …