Xcode: “Scene is unreachable due to lack of entry

2019-01-16 13:23发布

Xcode 4.5.2 gives me the following warning:

Unsupported Configuration    
Scene is unreachable due to lack of entry points and does not have an identifier 
for runtime access via -instantiateViewControllerWithIdentifier:.

Unfortunately I can't identify the incriminated scene. Selecting the warning in the Issue Navigator doesn't highlight anything in the Storyboard. I have a fairly complicated storyboard (30+ scenes).

Any suggestions?

Screenshot for warning

22条回答
三岁会撩人
2楼-- · 2019-01-16 14:00

For me, it wasn't because of a Storyboard ID or a Segue. I was receiving this warning because I had not set the View Controller's Custom Class.

Select the View Controller on the Storyboard, then in the Utilities Pane, select the Identity Inspector icon. Under Custom Class, see what value is inside of the Class field.

If it just says UIViewController, then you need to type in the class name. This will be the name of your .h and .m files that make up your custom UIViewController subclass.

查看更多
仙女界的扛把子
3楼-- · 2019-01-16 14:01

I just had this exact error with a simple single-scene Storyboard, and all I had to do to fix it was check the "Is Initial View Controller" checkbox for the 1 view controller in the Storyboard. I suspect Xcode used to check this box for you by default in this situation, but no longer does.

Check the box at the bottom

                                     

Check the box for exactly one of the view controllers in your storyboard and you should be good.

查看更多
做自己的国王
4楼-- · 2019-01-16 14:01

With Xcode 7 this can be handled easily. There is no need to manually go through all the scenes to find a problematic one. First go to the Report navigator, where you can get more detail info about known issues. Issue description can look like this:

Base.lproj/Main.storyboard:fPh-fe-F5F: warning: Scene is unreachable due to lack of entry points and does not have an identifier for runtime access via -instantiateViewControllerWithIdentifier:.

With this info, you can copy object id, in this case it was fPh-fe-F5F, and search workspace for the occurrence of this string. String will be found in Main.storyboard file. Double click on search result and it will be opened Main.storyboard with selected scene. Once you know a problematic scene you can easily fix the issue, by setting storyboard ID or setting "Is Initial View Controller"

查看更多
一夜七次
5楼-- · 2019-01-16 14:02

The easiest way to see which controller, or scene, is causing this problem is by:

  • Ctrl-clicking your .storyboard in the Project Navigator and selecting Open As > Source Code. This will bring up the underlying XML of the Storyboard.
  • In this view, the warning will be clearly related to a line in the XML that relates to the offending scene.

Now, in my case, the warning was particularly annoying because the "offending scene" had an identifier and a segue! I was able to remedy the problem by deleting the scene and then undoing the deletion. Not elegant, but worked. I saved my Storyboard before doing this. In retrospect, I should have made a copy and diff'd the before-after.

查看更多
冷血范
6楼-- · 2019-01-16 14:04

This issue can happen in one the following scenarios:

Case I: If none of the scene in the storyboard is marked as "isInitialViewController".

Fix: Identify the root view controller and mark it as "isInitialViewController" in your SB. In this case storyboard id is is not mandatory.

Case II

There can be situations where you do not need to have a initialViewController in a storyboard. For eg: when using Multiple storyboards.

Fix: In such cases make sure the "storyboard id" is correctly given and you refer to the first scene to used in the storyboard using this id. For eg:

UIStoryboard *myStoryBoard = [UIStoryboard storyboardWithName:@"MyStoryBoardName" bundle:nil];
MyViewController *myViewController = (MyViewController *)[myStoryBoard instantiateViewControllerWithIdentifier:@"MyViewControllerId"];

In this case "storyboard id" is mandatory.

Case III

You have your initialViewController connected. But still you get this warning. This is because some of the scenes in the storyboard may not be connected with a "segue" and also they do not have a "storyboard id". Scan your storyboard, see if a "segue" is needed. Connect the segue if that is missing. If a segue is not needed make sure you need to give a "storyboard id" since it is the only way to refer the scene from your code, as shown in the example code above.

Hope this helps

查看更多
老娘就宠你
7楼-- · 2019-01-16 14:04

I had the same issue,but i realized that i was using container view and instead of deleting default view controller i deleted its segue.So view controller remained in storyboard and so was the warning. So this is one of the case where warning pops up if default view controller of container view is not deleted properly when you don't need it.

查看更多
登录 后发表回答