我在Xcode 9 GM上运行我的iOS应用程序的单元测试,其中一些是因为奇怪的NSInternalInconsistencyException而失败,抱怨无法报告某些测试断言,因为所涉及的测试没有关联的XCTestRun对象.我正在使用OCMockito + OCHamcrest进行模拟和呼叫验证.
出于演示目的,假设我的应用程序名为MyTestApp,我有一个测试类FooTest(继承自XCTestCase).在-setUp中,我为测试创建并连接各种模拟对象,而在-tearDown中我将它们设置为nil以防万一.
这是我得到的例外情况的一个例子:
2017-09-19 13:23:01.852729-0700 xctest[17006:5392130] *** Assertion failure in -[FooTest recordFailureWithDescription:inFile:atLine:expected:], /Library/Caches/com.apple.xbs/Sources/XCTest_Sim/XCTest-13201/Sources/XCTestFramework/Core/XCTestCase.m:308
/Users/fooUser/Workspaces/MyTestApp/tests/FooTest.mm:46: error: -[FooTest testSomething] : failed: caught "NSInternalInconsistencyException", "Unable to report test assertion failure 'Expected 1 matching invocation, but received 0' from /Users/fooUser/Workspaces/MyTestApp/tests/FooTest.mm:135 because it was raised inside test case -[FooTest testSomethingElse] which has no associated XCTestRun object. This may happen when test cases are constructed and invoked independently of standard XCTest infrastructure."
(
0 CoreFoundation 0x000000010255d1cb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000101ebff41 … 在Xcode 9" 新构建系统(预览版) ",在选项构建设置(如下图所示的图像)已经出台,并用于改善建造时间作为WWDC会议(规定的项目https://开头开发商. apple.com/videos/play/wwdc2017/402/)
它适用于我最近在Xcode 9中创建的新项目.
但它对我的旧项目(大项目)不起作用,而且我发现大多数项目都有以下类似的问题日志
错误:无法建立节点:"/Users/admin/Library/Developer/Xcode/DerivedData/PROJECTNAME/Build/Products/Debug-iphonesimulator/PROJECTNAME.app/Info.plist"(节点由多个命令产生;例如," 313423sfkjsahdfkashdfklahsdlfkjhsalkfjhh33123sfas:CopyPlistFile /Users/admin/Library/Developer/Xcode/DerivedData/PROJECTNAME-hgfopfsnfsimmzcupjfdhkomofte/Build/Products/Debug-iphonesimulator/PROJECTNAME.app/Info.plist/Users/admin/Projects/Official/PROJECTNAME-ios-2100bd9ec02e/PROJECTNAME/SupportingFiles/Info.plist'和'313423sfkjsahdfkashdfklahsdlfkjhsalkfjhh33123sfas:ProcessInfoPlistFile /Users/admin/Library/Developer/Xcode/DerivedData/PROJECTNAME-hgfopfsnfsimmzcupjfdhkomofte/Build/Products/Debug-iphonesimulator/PROJECTNAME.app/Info.plist/Users/admin /项目/官方/ PROJECTNAME-IOS-2100bd9ec02e/PROJECTNAME/SupportingFiles/Info.plist中')
如何解决这个问题?
我正在使用Xcode在Spritekit中构建游戏.更新到Xcode 9后,我发现每次通过.sks文件设置纹理时,Xcode会立即崩溃.我重新启动了计算机,更新了应用程序,重新加载了纹理,没有任何改变.我有2017年的Macbook Prof 13"w/touch bar.这是诊断:
Process: Xcode [577]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 9.0.1 (13249)
Build Info: IDEFrameworks-13249000000000000~2
App Item ID: 497799835
App External ID: 823984564
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Xcode [577]
User ID: 501
Date/Time: 2017-10-22 17:30:06.029 -0400
OS Version: Mac OS X 10.12.6 (16G29)
Report Version: 12
Anonymous UUID: 0537A8C3-9FB2-836A-088B-E5D2B7FEB3EB
Time Awake Since Boot: 100 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: SKCRenderer_resource_queue
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE …Run Code Online (Sandbox Code Playgroud) 我试图隐藏单个视图控制器的导航控制器没有运气,导航栏被隐藏为第一个vc,但它没有显示第二个vc.
这是我在第一个vc中使用的代码:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Hide the Navigation Bar
self.navigationController?.setNavigationBarHidden(true, animated: animated)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Show the Navigation Bar
self.navigationController?.setNavigationBarHidden(false, animated: animated)
}
Run Code Online (Sandbox Code Playgroud)
swift 4有什么变化?该代码在swift 3中有效...
我收到以下错误:
Generic parameter 'T' could not be inferred
在线: let data = try encoder.encode(obj)
这是代码
import Foundation
struct User: Codable {
var firstName: String
var lastName: String
}
let u1 = User(firstName: "Ann", lastName: "A")
let u2 = User(firstName: "Ben", lastName: "B")
let u3 = User(firstName: "Charlie", lastName: "C")
let u4 = User(firstName: "David", lastName: "D")
let a = [u1, u2, u3, u4]
var ret = [[String: Any]]()
for i in 0..<a.count {
let param = [
"a" : a[i], …Run Code Online (Sandbox Code Playgroud) 我的应用程序已经在应用程序商店中,昨天我将我的Xcode版本更新为9并且除了iPhone x以外工作正常.用户界面崩溃了.
1.我已经创建了两个UIView(两者都是固定高度),名为Header和Tab bar,我已经隐藏了我的NavigationBar整个应用程序.
2.为UIViewController添加了扩展,用于创建Header和Tab栏
func addHeaderTab(currentViewController:UIViewController,content:String, isMenu:Bool){
let noView = TopHeaderView()
noView.tag = 12345
noView.isMenu = isMenu
noView.translatesAutoresizingMaskIntoConstraints = false
currentViewController.view .addSubview(noView)
if isMenu{
noView.menuBtn .setImage(UIImage(named: "Small"), for: .normal)
noView.logoImg.isHidden = false
}else{
noView.menuBtn .setImage(UIImage(named: "arrow_small"), for: .normal)
noView.logoImg.isHidden = true
}
noView.titleLbl.text = content
noView.delegate = (currentViewController as! menuOpen)
NSLayoutConstraint(item: noView, attribute: .leading, relatedBy: .equal, toItem: currentViewController.view, attribute: .leading, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: noView, …Run Code Online (Sandbox Code Playgroud) 我已经对此提出了雷达,但我想知道是否有其他人有这个问题.
似乎重要的位置更改(SLC)在iOS 11上表现不同,但仅限于在Xcode 9上构建的应用程序.看起来好像SLC表现得更糟,并且与iOS 10相比延迟了.我可以支持这个使用来自多个设备的数据和易于重复的实验.我想尝试保持这篇文章的简短,所以如果有人想要更多关于如何更详细地重现问题的数据或说明,我很高兴能够分享我如何做到这一切.
使用这个简约的SLC缓存应用程序:https://github.com/Root-App/root-ios-slc-tester我能够从iOS 10和iOS 11设备获取数据.
问题仅存在于iOS 11设备上,其中接收SLC的应用程序已构建在Xcode 9上.只是为了确保这一点清楚:
大多数时候(但并非总是如此),iOS 11 + Xcode 9版本上的SLC发生的时间明显晚于控制(iOS 10)设备上的SLC.
比较来自上述应用程序的日志文件,iOS 10设备在iOS 11设备之前超过2分钟获得SLC.有时10-15分钟前!
样本删节数据,其中每一行是不同的行程,并表示第一次记录该行程的SLC(以HH:mm:ss):
iOS 10 | iOS 11
-------------------
20:41:08 | 20:44:45
07:21:25 | 07:27:48
18:54:57 | 19:07:36
07:48:17 | 07:51:03
17:29:44 | 17:38:18
Run Code Online (Sandbox Code Playgroud)
iOS 10与iOS 11中存在SLC之间的差距似乎有所不同.
是否有其他人看到这种降级的SLC行为?
使用Xcode 9.
2查询
在iOS 11设备上删除UITableViewCell意外的白色背景出于某种原因,但在故事板中所有背景颜色都设置为蓝色(在iOS10上正常工作).
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[self.bookmarks removeObjectAtIndex:indexPath.row];
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
Run Code Online (Sandbox Code Playgroud)
尝试了所有类型的UITableViewRowAnimation,并没有解决问题.
我运行我的程序,模拟器显示进度条并突然消失,弹出窗口出现并写在那里
无法启动与模拟器的服务连接
DTServiceHubClient无法为模拟器iPhone 8(81F102A0-7BDB-4A51-903B-CBC4AFFF93FB)祝福服务中心
xcode9 ×10
ios ×6
xcode ×4
swift4 ×3
ios11 ×2
swift ×2
autolayout ×1
codable ×1
encoder ×1
iphone-x ×1
sktexture ×1
sprite-kit ×1
uitableview ×1
xcode9-beta ×1
xctest ×1