번들에 NIB를로드 할 수 없습니다.
Janrain Engage를 Appcelerator Titanium과 맞춤 모듈로 통합하려고합니다. 샘플 모듈을 만들고 Jainrain 문서에 표시된대로 JREngage 폴더를 샘플 모듈 xcodeproj로 드래그했습니다.
이제이 프로젝트에 빌드 명령을 ./build.py
내린 다음를 실행하고 마지막으로 titanium run
명령을 실행합니다 . 빈 화면으로 시뮬레이터에서 응용 프로그램을 시작하고 즉시 충돌하여 다음 오류가 발생합니다.
포착되지 않은 예외 'NSInternalInconsistencyException'으로 인해 앱 종료, 이유 : '번들에 NIB를로드 할 수 없음 :'NSBundle </ Users / abhilash / Library / Application Support / iPhone Simulator / 4.2 / Applications / CA167346-4091-4E16-B841-955D1D391713 / test.app> (로드 됨) '이름이'JRProvidersController '입니다.
이 오류가 발생하는 이유는 무엇입니까?
파일 검사기에서 .xib 파일의 속성, 선택 상자의 속성 "Target Membership"피치를 방문하면 xib 파일이 타겟과 연결됩니다.
에 Targets -> Build Phases
.xib가에 추가되었는지 확인하고 Copy Bundle Resources
,없는 경우 .xib 파일을 추가합니다.
모두 알아 내려고
XXXController = [[XXXControlloer alloc] initWithNibName:@"XXXController" bundle:nil];
코드에서 XXXController
철자가 올바른지 확인하십시오.
xcode를 3.2에서 4.02로 업그레이드 한 후에도 동일한 문제가 발생했습니다 ( '번들에 NIB를로드 할 수 없음 : ..'예외). Xcode 3.2로 내 앱을 배포하면 위에서 언급 한 예외가 발생하는 xcode 4와 충돌하지만 IOS Simulator (v.4.2)에 배포하려고 할 때만 작동합니다. IOS 기기 (v.4.1) 타겟팅은 Xcode 4에서도 작동합니다.
그 이유는 .xib 파일에 거의 "숨겨진"설정이라는 것이 밝혀졌습니다.
파일 검사기에서 .xib 파일의 속성을 방문합니다. 모든 .xib 파일에 대해 '위치'속성이 '그룹에 상대적'으로 설정되었습니다. 나는 그것을 'Relative to project'로 변경했고 짜잔 : 이제 모든 .xib 파일이 IOS 시뮬레이터에 올바르게로드되었습니다!
이 이상한 Xcode4 동작에 대한 이유가 무엇인지 모르겠지만 시도해 볼 가치가 있습니까?
제 경우에는 매우 이상했습니다 (스토리 보드 사용) : 어떤 이유로 plist에서 "Main storyboard file base name"에서 "Main nib file base name"으로 변경되었습니다.
"기본 스토리 보드 파일 기본 이름"(UIMainStoryboardFile)으로 다시 변경하면 문제가 해결되었습니다.
이 오류는 "JRProvidersController"
이름이있는 .xib 파일이 없음을 의미합니다 . JRProvidersController.xib
존재 하는지 다시 확인하십시오 .
당신은로드 .xib file
와 함께
controller = [[JRProvidersController alloc] initWithNibName:@"JRProvidersController" bundle:nil];
빌드 대상이 내 iOS 기기 중 하나 인 상태에서 제품 파일 (xyzw.app)을 마우스 오른쪽 버튼으로 클릭하고 Finder에 표시 팝업 항목을 선택했습니다. xyzw.app이있는 창이 열렸습니다. 패키지 내용 표시를 사용하여 번들을 열고 이름에 소문자 i 대신 대문자 I (zoomieView.nib 대신 zoomieVIew.nib)가있는 파일 하나를 제외하고 예상했던 모든 파일을 확인했습니다. ). 나는 xib의 파일 이름에서 대문자 I를 발견하고 그것을 변경하고 다시 빌드했습니다. Xcode는 생성 된 .nib 이름을 그대로 남겼습니다. 번들에서 zoomieVIew.nib를 삭제하고 다시 빌드했으며 Xcode가 파일을 zoomieView.nib로 정식으로 다시 생성했습니다. 앱이 기기에서 작동하기 시작했습니다.
스토리 보드에이 문제가 있었고 펜촉은 'bKD-J3-fhr-view-ZSR-8m-2da'와 같은 이름으로 불 렸습니다.
뷰 컨트롤러의 init (withCoder)에서 self.view에 하위 뷰를 추가하려고했기 때문입니다. 셀프 뷰는 아직 존재하지 않습니다.
viewDidLoad 등으로 이동했습니다!
Objective-C보기 컨트롤러에서 사용자 지정 Swift보기를 사용하여 (예, <<PROJECT NAME>>-Swift.h
파일 을 가져온 후에도) 다음 을 사용하여 펜촉을로드하려고했습니다.
MyCustomView *customView = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([MyCustomView class]) owner:self options:nil] objectAtIndex:0];
...하지만 NSStringFromClass([MyCustomView class])
반환 <<PROJECT NAME>>.MyCustomView
되고로드가 실패합니다. TL; DR All은 문자열 리터럴을 사용하여 펜촉을 잘로드했습니다.
MyCustomView *customView = [[[NSBundle mainBundle] loadNibNamed:@"MyCustomView" owner:self options:nil] objectAtIndex:0];
프로젝트 살펴보기
Target -> Buid Phases -> Copy Bundle Resources
xib / storyborad가 빨간색으로 표시됩니다.
그냥 제거하고 프로젝트에서 누락 된 파일의 모든 참조를 제거하십시오.
이제이 스토리 보드 / xib 파일을 다시이 Copy Bundle Resources
.It로 드래그 하면 파일이 여전히 빨간색으로 표시되지만 걱정하지 마세요.
프로젝트를 정리하고 빌드하십시오.
이제 프로젝트가 성공적으로 다시 실행됩니다 !!
스토리 보드 용
여기에 게시 된 모든 단일 솔루션을 시도했지만 Swift 5와 함께 Storyboard를 사용하고 있으므로 아무것도 효과가 없었습니다.
스토리 보드 테스트 앱에서 새로운 컨트롤러와 뷰를 빌드하기 시작했습니다. 제가 발견 한 것은 My View Controller의 스토리 보드 ID가 없다는 것입니다.
그래서 여기 내 해결책이 있습니다. ViewController A에서 이동하려면-> View Controller B
1 단계. 스토리 보드 : ViewControllerA가 내비게이션 컨트롤러에 포함되어 있는지 확인하세요.
2 단계. 스토리 보드에서 : 이제 코드에서 식별자로 사용할 ViewControllerB의 스토리 보드 ID를 언급 했는지 확인합니다.
Step 3. and finally make sure you are pushing controller this way in your ViewControllerA with Button click.
if let viewControllerB = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ViewControllerB") as? ViewControllerB {
if let navigator = navigationController {
navigator.pushViewController(viewControllerB, animated: true)
}
}
I also found that it failed when I tried to load the XIB with a name like @"MyFile.xib". When I just used @"MyFile" it worked - apparently it always adds the extension. But the error message just said it couldn't find MyFIle.xib in the bundle - if it had said MyFile.xib.xib, that would have been a big clue.
Working on Xcode 4.6.3 and localizing my NIB files I also run into this issue.
For me nothing else helped besides changing "Document Versioning" in File Inspector to Deployment 5.0 instead of 6.1.
It happens when you rename the nib file. If you have already, create new nib(meaning copy current nib file contents to new nib), delete old nib file and it will solve your problem.
Edit: With new Xcode starting version 4.6.3, If you rename(with refactor feature) Controller class, it will rename nib file too and you need not worry about nib loading problem.
I just had an interesting experience using Xcode 6.3.
I kept getting this error also, despite trying everything you would normally think of with spelling, target membership, etc. as suggested above. I also tried cleaning, deleting derived data, and also deleting the app from the simulator several times to ensure the bundle was being built correctly but to no avail.
Finally, following Brian Michael Bentley's answer, I finally decided to inspect my .app file in my simulator's folder on my HD. I found that all of my nibs were there but with a abc~ipad.nib instead of the expected abc.nib. I manually renamed all of these files to remove the ~ipad part, built and it worked!
Trying to see why these have been appended with the ~ipad keyword, I looked at my project settings and in fact, in my General>Deployment Info tab, I had only iPad selected. I was trying to run on an iPhone simulator. I believe that in the past, Xcode would give an error indicating that the binary did not support iPhone and you would not succeed in running the app.
I deleted the app from the simulator and did the same thing again - again with only iPad supported. This time, the .app contained abc~iphone.nib AND abc~ipad.nib for each expected storyboard and it ran on the iPhone simulator just fine. Again - If we choose iPad only in our Deployment Info settings, it shouldn't run on iPhone Simulator. This is an Xcode bug.
So, there is some inconsistent behavior here on the part of Xcode and unfortunately it's an intermittent bug and this may be difficult to reproduce, but I put this here so that it may help others in the future.
Had this same issue nothing worked, so I figured something weird with derived data.
In xcode 6.3.2 I had to:
In XCode Menu --> Preferences --> Locations Tab --> In Locations Change Derived Data to Relative and then toggle back to Default
Then the nib loaded fine.
Your XIB file is probably outside your project folder. This leads to not showing up the Target Inspector. However, moving the XIB file into your project folder should fix it.
DO NOT PUT .xib WHEN YOU INSERT IN THE XIB NAME! IT IS ALREADY IMPLIED!
Dont do this:
UIView *viewFromNib = [[NSBundle mainBundle] loadNibNamed:@"ResultsAssessmentView.xib" owner:self options:nil][0];
Do this:
UIView *viewFromNib = [[NSBundle mainBundle] loadNibNamed:@"ResultsAssessmentView" owner:self options:nil][0];
Swift4 example if your MyCustomView.swift and MyCustomView.xib in a framework. Place this in the MyCustomView's init:
let bundle = Bundle(for: type(of: self))
let nib = UINib(nibName: "MyCustomView", bundle: bundle)
if let nibView = nib.instantiate(withOwner: self, options: nil).first as? UIView {
self.aViewInMyCustomView = nibView
self.aViewInMyCustomView.frame = self.frame
self.addSubview(self.aViewInMyCustomView)
// set constraints
self.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint(item: self.aViewInMyCustomView, attribute: .leading, relatedBy: .equal, toItem: self, attribute: .leading, multiplier: 1.0, constant: 0).isActive = true
NSLayoutConstraint(item: self.aViewInMyCustomView, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing, multiplier: 1.0, constant: 0).isActive = true
NSLayoutConstraint(item: self.aViewInMyCustomView, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1.0, constant: 0).isActive = true
NSLayoutConstraint(item: self.aViewInMyCustomView, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true
}
In case you are using frameworks in your project, you need to make sure you are loading from the correct bundle:
NSBundle *bundle = [NSBundle bundleWithIdentifier:@"<your bundle id here>"];
ABCViewController *vc = [[ABCViewController alloc] initWithNibName:@"<your nib name>" bundle:bundle];
Be careful: Xcode is caseSensitive with file names. It's not the same "Fun" than "fun".
Got this problem while transforming my old code from XCode 3x to XCode 4 and Solved it by just renaming wwwwwwww.xib into RootViewController.xib
I ran into the same problem. In my case the nib name was "MyViewController.xib" and I renamed it to "MyView.xib". This got rid of the error.
I was also moving a project from XCode 3 to 4.2. Changing the Path type did not matter.
Also the reason can be the file is looked up in the wrong language specific folder when you messed with localizations.
Every time I refactor a view controller's name that's in my appDelegate I waste time on this. Refactoring doesn't change the nib name in initWithNibName:@"MYOldViewControllerName".
I had same problem, renaming my view controller identifier in storyboard worked for me.
I noticed that it may happen if you switch between branches in git and forget to make a clean. So xib is there and everything is find, but the exact build may have problems. So just in case don't forget to make a clean
SecondViewController *secondViewController = [[SecondViewController alloc]initWithNibName:@"SecondView.xib" bundle:nil];
[self.navigationController pushViewController:secondViewController animated:YES];
In the above code, if you also give a file extension like "SecondView.xib", then it's wrong and will give you above error. Use "SecondView" instead. I have made that mistake.
This is worked for me.. Make sure you typed nib name correctly.
[[NSBundle mainBundle]loadNibNamed:@"Graphview" owner:self options:nil];
Graphview(nib name)
I've got same issue and my .xib
file has already linked in Target Membership
with the Project. Then I unchecked the file's target checkbox and checked again, then Clean
and Build
the project. Interestingly it has worked for me.
참고URL : https://stackoverflow.com/questions/5337337/could-not-load-nib-in-bundle
'code' 카테고리의 다른 글
jQuery를 사용하여 선택 목록에서 옵션 숨기기 (0) | 2020.08.24 |
---|---|
EntityType 'IdentityUserLogin'에 정의 된 키가 없습니다. (0) | 2020.08.24 |
누군가가 방향성 비순환 그래프가 무엇인지 간단한 용어로 설명 할 수 있습니까? (0) | 2020.08.24 |
Angular 2 아래로 스크롤 (채팅 스타일) (0) | 2020.08.24 |
데이터베이스 트랜잭션이란 무엇입니까? (0) | 2020.08.24 |