ios 错误消息 '_BSMachError: (os/kern) 无效能力 (20)'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32899586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error message '_BSMachError: (os/kern) invalid capability (20)'
提问by Logicsaurus Rex
Please note that this error message is pretty low level, so it crops up for different reasons in different scenarios. If you have a scenario that isn't mentioned in one of the answers below, please consider adding your situation as well, so maybe this could be a central answer for various situations that raise this error message.
请注意,此错误消息的级别非常低,因此在不同情况下会因不同原因出现。如果您的情况未在以下答案之一中提及,请考虑添加您的情况,因此这可能是引发此错误消息的各种情况的核心答案。
Edit Nov 10, 2015Also note, I marked my own answer as the answer, but that was before anyone else had posted. I guess none should really be marked as the answer, because as we've now seen below... this error doesn't have just one answer because it's so low level.
2015 年 11 月 10 日编辑另请注意,我将自己的答案标记为答案,但那是在其他人发布之前。我想没有一个真的应该被标记为答案,因为正如我们现在在下面看到的......这个错误不仅有一个答案,因为它的级别太低了。
I'm running
我在跑
- iOS 9.0 Simulator
- XCode 7.0
- iOS 9.0 模拟器
- 代码 7.0
Everything was working fine yesterday.
昨天一切正常。
Today, after a bunch of work on rotation related stuff, I started getting this error in my console output when I run the app in the Simulator and I rotate it.
今天,经过一系列与旋转相关的工作后,当我在模拟器中运行应用程序并旋转它时,我开始在控制台输出中收到此错误。
_BSMachError: (os/kern) invalid capability (20)
_BSMachError: (os/kern) invalid name (15)
_BSMachError: (os/kern) 无效能力 (20)
_BSMachError: (os/kern) 无效名称 (15)
- I've cleared my build folder,
- I've cleaned the derived data folder,
- I've reset the simulator.
- 我已经清除了我的构建文件夹, - 我已经清除了派生数据文件夹, - 我已经重置了模拟器。
I was working with
我正在与
UIViewController viewWillLayoutSubviews
UIViewController viewWillTransitionToSize:...
UIViewController viewWillLayoutSubviews
UIViewController viewWillTransitionToSize:...
I was also checking various 'Drawing' settings on the Attributes Inspector in IB.
我还在 IB 中的属性检查器上检查各种“绘图”设置。
I also made a utility category on UIView where I created a bunch of methods that create CGRect
's and helps me assign frames to views.
我还在 UIView 上创建了一个实用程序类别,在那里我创建了一堆方法来创建CGRect
's 并帮助我将框架分配给视图。
采纳答案by Logicsaurus Rex
Ok, I haven't pinned it down completely, but this will get you 99% of the way there. I'm using a third party map control from ESRI, and something about it doesn't like one of these drawing settings in the Attributes Inspector. I haven't tried each setting individually to see which setting it is, but when I turned all of them off (in the red box), everything worked like a charm, and I quit getting the error message above in the console. If and when I get time to nail it down to the precise setting or combination of settings, i'll update the answer.
好吧,我还没有完全确定它,但这会让你完成 99% 的工作。我正在使用来自 ESRI 的第三方地图控件,并且它的某些方面与 Attributes Inspector 中的这些绘图设置之一不一样。我没有单独尝试每个设置来查看它是哪个设置,但是当我关闭所有设置(在红色框中)时,一切都像魅力一样,我不再在控制台中收到上面的错误消息。如果我有时间将其确定为精确的设置或设置组合,我会更新答案。
回答by blacharnia
Based on the https://forums.developer.apple.com/thread/15683:
基于https://forums.developer.apple.com/thread/15683:
Change "Localization native development region" in info.plist
to United States instead of en
.
将“本地化本地开发区域”info.plist
改为美国en
。
Updated: Then you can revert these changes back.
更新:然后您可以恢复这些更改。
回答by 19Craig
I also ran into the _BSMachError
console errors while deep linking into the Settings app on iOS 9 from a UIAlertController
action. A dispatch_async
solved my problem:
我_BSMachError
在通过操作深度链接到 iOS 9 上的“设置”应用程序时也遇到了控制台错误UIAlertController
。Adispatch_async
解决了我的问题:
[aAlertVC addAction:[UIAlertAction actionWithTitle:@"Settings" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
});
}]];
回答by agro1986
It's crazy but for me the solution was just to remove all breakpoints in the file where the error occured.
这很疯狂,但对我来说,解决方案只是删除发生错误的文件中的所有断点。
As for the cause? I think I accidentally hit a shortcut key to create a breakpoint in the current line. Because that was unintended I hit the same shortcut key again to delete it.
至于原因?我想我不小心按了快捷键在当前行中创建了一个断点。因为这是无意的,所以我再次按下相同的快捷键将其删除。
Oh my dear XCode...
哦,我亲爱的 XCode...
回答by Murray Sagal
I was getting the same errors...
我遇到了同样的错误...
_BSMachError: (os/kern) invalid capability (20)
_BSMachError: (os/kern) invalid name (15)
I was calling openURL() from a UIAlertAction
我从一个调用 openURL() UIAlertAction
alert.addAction(UIAlertAction(title: actionTitle, style: .Default) {
UIApplication.shared.openURL(url)
}
Deferring execution of the block until the next run loop fixed it...
将块的执行推迟到下一个运行循环修复它...
alert.addAction(UIAlertAction(title: actionTitle, style: .Default) {
OperationQueue.main.addOperation {UIApplication.shared.openURL(url)}
}
回答by Patt
I was getting the following when supplying new data:
提供新数据时,我得到以下信息:
> _BSMachError: (os/kern) invalid capability (20)
> _BSMachError: (os/kern) invalid name (15)
The error occurred when a button was used to supply new data. An NSTimer
was used to refresh and update data upon returning from a performSegueWithIdentifier
action. The timer was being activated and then invalidated immediately after use at return time. The MSMachError
stopped when the timer was removed and - (void)viewWillAppear:(BOOL)animated
and (void)viewDidAppear:(BOOL)animated
were employed to perform the same function. This error started with upgrade to Xcode 7.
使用按钮提供新数据时发生错误。AnNSTimer
用于在从performSegueWithIdentifier
操作返回时刷新和更新数据。定时器被激活,然后在返回时间使用后立即失效。的MSMachError
-除去计时器时并停止(void)viewWillAppear:(BOOL)animated
和(void)viewDidAppear:(BOOL)animated
被用来执行相同的功能。此错误始于升级到 Xcode 7。
回答by Jayprakash Dubey
I got this issue fixed by changing value of Localization native development region
key to United Kingdom
[or any Specific region]from its default value en
present in info.plist
of your project.
我通过将Localization native development region
键的值从项目中存在的默认值更改为United Kingdom
[或任何特定区域]来解决此问题。en
info.plist
- Select
Project Navigator
- Locate
info.plist
file present in ProjectNameTests folder. - Change value of
Localization native development region key
to any specific region for eg.United Kingdom
- 选择
Project Navigator
- 找到
info.plist
ProjectNameTests 文件夹中的文件。 - 将 的值更改
Localization native development region key
为任何特定区域,例如。英国
回答by 1218GG
I did face the same error invalid capability (20) & invalid name (15). I tried the solutions as mentioned by others such as:
我确实遇到了同样的错误无效能力(20)和无效名称(15)。我尝试了其他人提到的解决方案,例如:
- Localisation native development region key in info.plist
- Changing drawing settings in the Attributes Inspector
- Even altered ATS Exception Dictionary in info.plist
- info.plist 中的本地化本地开发区域键
- 在属性检查器中更改绘图设置
- 甚至在 info.plist 中更改了 ATS 异常字典
But none of those solutions solved my problem. Actually, I was trying to share some document but generating document would take some time and wanted to display an UIActivityIndicatorView to the user till the time document loads.
但是这些解决方案都没有解决我的问题。实际上,我试图共享一些文档,但生成文档需要一些时间,并且希望在文档加载之前向用户显示 UIActivityIndicatorView。
The solution for my error was:
我的错误的解决方案是:
//Create a alertView add UIActivityIndicatorView to it and present it in ViewController
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
//Call method 1 todo background process like getting data
dispatch_sync(dispatch_get_main_queue(), ^{
//Call method 2 to update the UI
[alert dismissViewControllerAnimated:YES completion:^(void){
//My mistake was: I was calling method 2 over here to update the UI
return;
}];
});
});
回答by Kellen Styler
I also ran into the same problem in an NSOperation running on a background thread and I was still getting this error because a UIAlertController was still removing itself as another UI transaction was trying to take place. Modifying my code to this fixed the issue.
我还在后台线程上运行的 NSOperation 中遇到了同样的问题,但我仍然收到此错误,因为 UIAlertController 仍在尝试进行另一个 UI 事务时正在删除自己。将我的代码修改为此修复了问题。
defer {
dispatch_async( dispatch_get_main_queue(),{
completion()
})
}
A lot of people don't know about defer -It lets the current scope complete and then runs after. Kinda neat.
很多人不知道 defer - 它让当前范围完成然后运行。挺整洁的
回答by AlphaCodaSeven
Changing localization string from en to United States fixed this for me. However, make sure you clean after you change Info.plist. I've noticed that updates don't work when you just build after making plist changes.
将本地化字符串从 en 更改为 United States 为我解决了这个问题。但是,请确保在更改 Info.plist 后进行清理。我注意到当您在进行 plist 更改后进行构建时,更新不起作用。