Macos app displays view in Xcode, but is totally blank when launched outside of Xcode

旧城冷巷雨未停 提交于 2019-12-11 04:57:32

问题


I'm working on a small macos app, which I'm building with storyboards/interface builder in Xcode 10.2.1 on MacOS 10.14.5 (though I've set a deployment target of 10.13, if that matters).

When I run the app within Xcode, i.e., by hitting the "play" button, it loads up just fine and is visible and operates.

However, when I "archive" it to a freestanding executable and then try to run the app from the hard drive, it opens up on a blank screen. (See screenshots below.)

I've cleaned the build folder. I've also made sure to clear any/all build warnings and autolayout constraint warnings.

Here it is, running perfectly fine within xcode:

And here it is, displaying nada when run on its own:

The app uses no third-party libraries, no bundle assets, and only has one ViewController---nothing fancy at all happening here. The only weird UI thing that I'm doing is that there's a very small webview in the bottom-right corner that I'm using as a hack to load js-based web content (the mysterious white dot in the working screenshot).


回答1:


Ok, I figured this one out myself, so for the purposes of google/if someone else has this problem: there seems to be a bug in WKWebView of some kind, adding it to IB kills everything else in the view. (Or maybe this is intended, and WKWebView requires it's own independent view? Dunno.)

The solution is to create it programmatically and never put it in the view at all. You can still load web content in the background, scrape information from pages, etc. without it ever being part of a view.




回答2:


Not only WKWebView, also AVPlayerView should not placed int IB, too.

it cause same result.



来源:https://stackoverflow.com/questions/56550970/macos-app-displays-view-in-xcode-but-is-totally-blank-when-launched-outside-of

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!