Search code examples
iosobjective-cxcodexcode-storyboardglkview

GLKView in IB will cause crash when app is run without Xcode


I have an app that displays a ViewController at some point, which includes a GLKView. All defined within a storyboard. It works just fine, that is, unless you run the app from the phone itself, not launched from within Xcode. Upon presentation of the ViewController and therefore the GLKView, the app instantly crashes.

It doesn't matter if the Installed checkbox is ticked or unticked for the GLKView. Only when I delete it from the storyboard altogether, it won't crash.

Any ideas?


Solution

  • I don't know why these things happen but I would consider them a bug. A similar situation happens when adding a WKWebView directly from storyboard. For both the solution is pretty simple: All you need to do is import the module for it. So in your case in your view controller add:

    import GLKit
    

    It seems otherwise the framework is not loaded or something.

    With ObjectiveC the problem seems to go a level deeper. It seems that the module must manually be imported. Go to your project settings. Select your target. Select "General". Scroll down to bottom and find "Linked Frameworks and Libraries". Below it find a "+" button and search for "GLKit.framework" and add it. This should fix the issue.

    enter image description here