오류 메시지 '_BSMachError : (os / kern) 유효하지 않은 기능 (20)'
이 오류 메시지는 매우 낮은 수준이므로 시나리오에 따라 다른 이유로 잘립니다. 아래 답변 중 하나에 언급되지 않은 시나리오가있는 경우 상황을 추가하는 것도 고려하십시오. 따라서이 오류 메시지를 발생시키는 다양한 상황에 대한 중심 답변 일 수 있습니다.
2015 년 11 월 10 일 편집 또한 내 답변을 답변으로 표시했지만 다른 사람이 게시하기 전에 수행했습니다. 우리가 지금 아래에서 볼 수 있듯이, 아무도 실제로 답으로 표시되어서는 안된다고 생각합니다 ...이 오류는 레벨이 낮아서 단 하나의 대답 만하지 않습니다.
나는 뛰고있어
- iOS 9.0 시뮬레이터
- XCode 7.0
어제 모든 것이 잘 작동했습니다.
오늘날 회전 관련 항목에 대한 많은 작업을 한 후에 시뮬레이터에서 앱을 실행하고 회전 할 때 콘솔 출력 에서이 오류가 발생하기 시작했습니다.
_BSMachError : (OS / Kern) 유효하지 않은 기능 (20)
_BSMachError : (os / kern) 잘못된 이름 (15)
-빌드 폴더를 지 웠습니다.-파생 데이터 폴더를 정리했습니다.-시뮬레이터를 재설정했습니다.
나는 함께 일하고 있었다
UIViewController viewWillLayoutSubviews
UIViewController viewWillTransitionToSize:...
또한 IB의 속성 관리자에서 다양한 '도면'설정을 확인하고있었습니다.
또한 UIView에서 유틸리티 카테고리를 만들었습니다. 여기서를 작성 CGRect
하고 뷰에 프레임을 할당하는 데 도움 이되는 많은 메소드를 만들었습니다 .
https://forums.developer.apple.com/thread/15683 기반으로 :
대신 " Localization native development region " info.plist
을 미국으로 변경하십시오 en
.
업데이트 : 그런 다음 이러한 변경 사항을 되돌릴 수 있습니다.
또한 동작 _BSMachError
에서 iOS 9의 설정 앱에 딥 링크하는 동안 콘솔 오류가 발생했습니다 UIAlertController
. A는 dispatch_async
내 문제를 해결 :
[aAlertVC addAction:[UIAlertAction actionWithTitle:@"Settings" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
});
}]];
좋아, 나는 그것을 완전히 고정 시키지는 않았지만, 이것이 99 %의 방법을 얻을 것이다. ESRI의 타사 맵 컨트롤을 사용하고 있는데 속성 관리자의 이러한 도면 설정 중 하나가 마음에 들지 않습니다. 어떤 설정인지 확인하기 위해 각 설정을 개별적으로 시도하지는 않았지만 (빨간색 상자에서) 모든 설정을 끄면 모든 것이 매력처럼 작동하여 콘솔에서 위의 오류 메시지가 표시되지 않습니다. 정확한 설정이나 설정 조합으로 시간을 정할 때 답을 업데이트하겠습니다.
미친 짓이지만 해결책은 오류가 발생한 파일의 모든 중단 점을 제거하는 것이 었습니다.
원인은? 현재 줄에 중단 점을 만들기 위해 실수로 바로 가기 키를 쳤다고 생각합니다. 의도하지 않았기 때문에 동일한 바로 가기 키를 다시 눌러 삭제했습니다.
오 내 사랑 XCode ...
같은 오류가 발생했습니다 ...
_BSMachError: (os/kern) invalid capability (20)
_BSMachError: (os/kern) invalid name (15)
에서 openURL ()을 호출했습니다. UIAlertAction
alert.addAction(UIAlertAction(title: actionTitle, style: .Default) {
UIApplication.shared.openURL(url)
}
다음 실행 루프가 수정 될 때까지 블록 실행 지연 ...
alert.addAction(UIAlertAction(title: actionTitle, style: .Default) {
OperationQueue.main.addOperation {UIApplication.shared.openURL(url)}
}
새 데이터를 제공 할 때 다음을 얻었습니다.
> _BSMachError: (os/kern) invalid capability (20)
> _BSMachError: (os/kern) invalid name (15)
버튼을 사용하여 새 데이터를 제공 할 때 오류가 발생했습니다. NSTimer
는 performSegueWithIdentifier
작업 에서 돌아올 때 데이터를 새로 고치고 업데이트 하는 데 사용되었습니다 . 타이머가 활성화 된 후 반환 시간에 사용한 직후에 무효화되었습니다. 는 MSMachError
타이머가 제거 될 때 중단하고 - (void)viewWillAppear:(BOOL)animated
과 (void)viewDidAppear:(BOOL)animated
동일한 기능을 수행하는 데 사용 하였다. 이 오류는 Xcode 7로 업그레이드하면서 시작되었습니다.
나는 값 변경하여 고정이 문제를 가지고 Localization native development region
열쇠 United Kingdom
[또는 특정 지역] 기본 값의 en
존재를 info.plist
프로젝트의합니다.
- 고르다
Project Navigator
info.plist
ProjectNameTests 폴더에있는 파일을 찾으십시오 .- 예를 들어
Localization native development region key
특정 지역의 값을 변경하십시오 . 영국
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.
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.
I did face the same error invalid capability (20) & invalid name (15). I tried the solutions as mentioned by others such as:
- Localisation native development region key in info.plist
- Changing drawing settings in the Attributes Inspector
- Even altered ATS Exception Dictionary in info.plist
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.
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;
}];
});
});
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.
In my case it was Little Snitch, it was blocking urls automatically.
I could reproduce the error for me: If a make changes to one of the Views within a View that I am actually closing already (popViewControllerAnimated) I receive the error.
I am having a UINavigationButton action that makes an asynchronous task (POSTRequest). Before performing this request I set the customView of that button to an progress indicator. When coming back from the asynchronous call I dispatch to the main thread and reset the customView of that button. After that I am closing the view (popViewControllerAnimated).
This is the CORRECT code where the error does not appear:
/* right way, working without BSMachError */
@IBAction func sendRequest(sender: UIBarButtonItem) {
/* setting the progress indicator as customView of the self.saveButton */
self.showActivityIndicatory(self.saveButton)
/* asynchronous REST call */
UserDataManager.sharedInstance.requestFeedback(request, onCompletion: { error in
dispatch_async(dispatch_get_main_queue(),{
/* resetting the saveButton again to default by setting customView to nil */
self.saveButton.customView = nil
/* closing the view */
self.navigationController!.popViewControllerAnimated(true)
})
})
}
What caused the error was switching lines: closing the view and then setting the customView to nil:
/* WRONG way, causing BSMachError */
@IBAction func sendRequest(sender: UIBarButtonItem) {
/* setting the progress indicator as customView of the self.saveButton */
self.showActivityIndicatory(self.saveButton)
/* asynchronous REST call */
UserDataManager.sharedInstance.requestFeedback(request, onCompletion: { error in
dispatch_async(dispatch_get_main_queue(),{
/* closing the view */
self.navigationController!.popViewControllerAnimated(true)
/* resetting the saveButton again to default by setting customView to nil */
self.saveButton.customView = nil
})
})
}
This error started popping up after I added some observers:
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.keyboardWillHideOrShow(_:)), name:UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.keyboardWillHideOrShow(_:)), name:UIKeyboardWillHideNotification, object: nil)
The problem went away when I specified the class name instead of self
:
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(MyClass.keyboardWillHideOrShow(_:)), name:UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(MyClass.keyboardWillHideOrShow(_:)), name:UIKeyboardWillHideNotification, object: nil)
I had the same error and none of the above applied to my problem. The problem appeared when I registered my view controller as an observer to a device orientation change, so the views could be resized and the drawings in the view could be made according to the new size of the view.
I had an outlet of a viewGraph which was a subclass of UIView in which I drew some graphics.In landscape mode the size of the viewGraph is larger than in portrait mode. So when the device changes its orientation the speedGraph needed to be redrawn.
The problem was, that I added several subviews to the speedGraph view, that contained graphics. These subviews needed to be laid out anew in the speedGraph view and then be redrawn. After the device changed its orientation I called viewDidAppear again to make the speedGraph view and all its subviews to be laid out anew and redraw themselves. Calling setNeedsDisplay for speedGraph doesn't work with orientation changes and subviews in a view.
What did I do wrong that caused the error to appear. In viewDidAppear I call a method which does some calculations and adds the subviews to the speedGraph view. The problem was that these subviews were created in the method and were added to the speedGraph view in this method. After leaving the method, the references to these subviews are, of course, deleted, but the subviews in the speedGraph view remain, since they are added. When the device changes, the subviews are created again and added to the speedGraph view, that already has these subviews, but can't find the references to these subviews anymore. The array of subviews of speedGraph view gets longer and longer with (i think) dangling subviews.
I solved the problem by defining the subviews that will be added to the speedGraph view as a class property and then do what needed to be done with the views inside this method. With this change the problem was gone.
Since we can post all situations returning the same error here, I felt free to post mine :). I got the Error when I changed privacy settings in the background. My app opened the settings app so the user can grant it permission to its photolibrary, when the permission switch is set, the app crashes with the mensioned error:
_BSMachError: (os/kern) invalid capability (20)
_BSMachError: (os/kern) invalid name (15)
This appears to be a forced restart of your app by the OS, because the user changed what your app can acces. So in my case it is an action of the OS who caused the error.
I got the same error message, because I assign
a object
property like @property (assign, nonatomic) NSNumber *aVariable;
, fixed by changing to strong
.
For what it's worth - it seems that a lot of situations throw this error. In my case, I had posted an alert when the user was dismissing a data entry form and data was in the form. I was able to eliminate the error by programmatically resigning the first responder from all applicable fields before unwinding the view controller.
I saw this when I pressed the Home
button while a UIAlertController
was displayed, which was dismissed when I relaunched the app. I added code to dismiss the UIAlertController
in the appDelegate
:
func applicationWillResignActive(application: UIApplication) {
window?.rootViewController?.dismissViewControllerAnimated(false, completion: nil)
}
and the error message disappeared.
I had this error when dismissing a popover via delegate. In the delegateMethod I triggered some GUI-Stuff. Putting the GUI-Stuff in the completionBlock of dismissViewControllerAnimated fixed it.
[myPopoverView dismissViewControllerAnimated:YES completion:^{ //GUI-Stuff}];
I am a newb at this so take this for what it is worth.
What fixed this for me was changing the Simulated Metrics > Size > to iPad Full Screen. All of my views EXCEPT for the one that threw this error we set to iPad Full Screen. When I changed it, the error went away...
The reason some developers doesn't get the error came back after changing from "Unites States" to "en" (or) other region, is that there is discrepancy between "Property list" and "Source code" views. It's probably Xcode bug. Whenever there is mismatch between these two views will throw this error, whatever it is "en" or "English". If you changed to "en" or "United States" for both views to be the same, will fix the issue.
I got this error from:
var promptsArr = StartRegAlerts() //Instance of the class
etc
func textFieldDidBeginEditing(textField: UITextField) {
switch textField.tag {
case 0:
alert(promptsArr.prompts["Name"]!)
case 1:
alert(promptsArr.prompts["CellPhone"]!)
case 4:
alert2(promptsArr.prompts["NUMBERCORRECT"]!)
//alert(promptsArr.prompts["Wait4Pin"]!)
default: break
}
It only occurred for case 0 but not the other cases:
As a work around for now I commented out case 0 and that stopped the error.
I then changed calling promptsArr.prompts by:
creating a new dictionary prompt and:
override func viewDidAppear(animated: Bool) {
prompt = promptsArr.prompts //
}
and then used prompt in my alert calls. That fixed the problem.
So it appears that it is a timing issue.
with Xcode 8.1 and iOs 10 I also faced
_BSMachError: (os/kern) invalid capability (20)
_BSMachError: (os/kern) invalid name (15)
trying to override UiTraiCollection var to change at runtime the iPad’size classes to have two different interface layouts in Portraid and Landscape. It worked without any crash but generate our errors.
This was the "maliciuos" code:
override public var traitCollection: UITraitCollection {
if UIDevice.currentDevice().userInterfaceIdiom == .Pad && UIDevice.currentDevice().orientation.isPortrait.boolValue {
return UITraitCollection(traitsFromCollections:[UITraitCollection(horizontalSizeClass: .Compact), UITraitCollection(verticalSizeClass: .Regular)])
}
return super.traitCollection
}
The errors gone using override func viewWillTransition
as alternative to detect interface rotation.
I hope this will be useful to someone
제 경우에는 오류의 원인이 크기 조정 때문이었습니다. IB에 내장. 텍스트 필드의 크기를 변경할 수 있거나 줄 길이를 변경하는 것과 같은 것이 있으면이 오류가 발생할 수 있습니다. 필자의 경우 모든 가능성을 포괄하도록 텍스트 필드 크기를 조정해야하므로 상자 크기를 조정할 필요가 없으며 다른 것과 충돌 할 필요가 없습니다.
참고 URL : https://stackoverflow.com/questions/32899586/error-message-bsmacherror-os-kern-invalid-capability-20
'Programing' 카테고리의 다른 글
GNU 화면 스크롤 백 버퍼를 파일로 복사 (확장 하드 카피)? (0) | 2020.05.25 |
---|---|
set.seed 함수를 사용하는 이유 (0) | 2020.05.25 |
javadoc에서 @ 문자를 어떻게 벗어날 수 있습니까? (0) | 2020.05.25 |
Sublime Text 2에서 Ctrl + D를 사용하여 여러 항목을 선택할 때 일치 항목을 건너 뛰려면 어떻게합니까? (0) | 2020.05.24 |
각도 2 라우터 기본 설정 없음 (0) | 2020.05.24 |