酢ろぐ!

カレーが嫌いなスマートフォンアプリプログラマのブログ。

iOSでreason: 'Could not load NIB in bundle: 'の例外が発生して起動しなくなった

Xcode 6.4で開発していたアプリをXcode 7.1で起動する状態にして、数ヶ月放置してXcode 7.3でまた起動させようとしたらアプリが起動しなくなってしまった。

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle

具体的に書くと、スプラッシュ画像は表示されるけれどapplication:didFinishLaunchingWithOptions:が呼ばれる前にクラッシュしてしまう。

2016-03-29 00:59:17.762 sakusanapp[55474:1285546] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/ch3cooh/Library/Developer/CoreSimulator/Devices/16929A22-84CB-414B-91D0-5A26CB0C610C/data/Containers/Bundle/Application/1F20D133-70BD/sakusanapp.app> (loaded)' with name 'UIViewController-Hb2-TP-jNi' and directory 'Main.storyboardc''
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010c03bd85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010baacdeb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010c03bcbd +[NSException raise:format:] + 205
    3   UIKit                               0x000000010d267c89 -[UINib instantiateWithOwner:options:] + 499
    4   UIKit                               0x000000010d5e2314 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181
    5   UIKit                               0x000000010d5e2467 -[UIStoryboard instantiateInitialViewController] + 69
    6   UIKit                               0x000000010ce9f89f -[UIApplication _loadMainStoryboardFileNamed:bundle:] + 94
    7   UIKit                               0x000000010ce9fbcf -[UIApplication _loadMainInterfaceFile] + 260
    8   UIKit                               0x000000010ce9e3ef -[UIApplication _runWithMainScene:transitionContext:completion:] + 1392
    9   UIKit                               0x000000010ce9b714 -[UIApplication workspaceDidEndTransaction:] + 188
    10  FrontBoardServices                  0x00000001159d28c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
    11  FrontBoardServices                  0x00000001159d2741 -[FBSSerialQueue _performNext] + 178
    12  FrontBoardServices                  0x00000001159d2aca -[FBSSerialQueue _performNextFromRunLoopSource] + 45
    13  CoreFoundation                      0x000000010bf61301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    14  CoreFoundation                      0x000000010bf5722c __CFRunLoopDoSources0 + 556
    15  CoreFoundation                      0x000000010bf566e3 __CFRunLoopRun + 867
    16  CoreFoundation                      0x000000010bf560f8 CFRunLoopRunSpecific + 488
    17  UIKit                               0x000000010ce9af21 -[UIApplication _run] + 402
    18  UIKit                               0x000000010ce9ff09 UIApplicationMain + 171
    19  sakusanapp                             0x000000010a2eebe2 main + 114
    20  libdyld.dylib                       0x000000010eada92d start + 1
    21  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

localizationのJapaneseのチェックをつけてチェックを外したところうまく動くようになった。

f:id:ch3cooh393:20160329092227p:plain

変更されたコードといえばsakusanapp/ja.lproj/Main.stringsが追加されただけですがこれで動くようになった。

追記

そもそもの原因が特定できました。左のソリューションペインにはMain.storyboardが存在していたが、Build/PhasesのCopy Bundle ResourcesからMain.storyboardが消えていたのが原因だった。