I have a major problem with Xcode not loading anything - xcode

I was trying to build an app using a map view kit. It was all fine and I used advice to add the wk map kit framework to the build phase library.
Now nothing loads, can’t add any UI elements as the whole thing just stalls. I’ve uninstalled Xcode and still have same problem. Any ideas?
I’m just trying to create a new app and add things like image view / map kit / buttons. Nothing works it just sits there loading with the spinning wheel of death.

Related

SwiftUI Preview Canvas Build Fails but Project Build does Not

I am working on a project to add SwiftUI to a legacy app that uses Cocoapods. When I try to run the preview canvas the build fails and the canvas cannot run.
The cause is an issue building one of the included pods in the project (we’ll call this pod ‘LibraryX’). When XCode tries to build LibraryX it encounters a segmentation fault. But when I build the project itself there is no problem building LibraryX and starting the app.
I have tried looking for SwiftUI-preview-specific build settings in the XCode project build settings and have not been able to find anything. I have double checked the build path settings (as in this answer) and also verified that I am building on the correct device (as in this answer). In general, Googling for others who are facing similar issues has not turned up anything like my issue so far.
What I am wondering then is this: Does XCode use different build settings for building the project for use in creating the preview canvas? If so is there some way to configure how the preview canvas build works?
Because LibraryX is proprietary and the SwiftUI view I’m trying to add is simply the default “hello world” view that XCode creates there is not much I can share in the way of code samples for this question.
SwiftUI has still some bugs and is not perfect yet.
The canvas is part of SwiftUI and "shares" some of these bugs.
Sometimes you find yourself in a situation, where (a.) something does not work on Canvas or (b.) does not work correct on the simulator but (c.) works on a real device perfectly.
Most likely everything will get better over time, because SwiftUI is quite new (less then a year old) and Apple is pushing it.
My "solution" for the moment in similar situations is to not rely on canvas and just test on simulator.

Swift UI Canvas not showing with macOS 10.15 and Xcode 11.1

Canvas does not appear in my 2-year old project even though I recently upgraded to macOS 10.15 (19A547) and Xcode 11.1 (15405). I have selected Editor menu/Canvas to show it. Simulator works fine, and building a new project shows Canvas working properly. Must I enable/select/configure other parts of my project?
Read before looking at image
Canvas is actually for SwiftUI, Also you can use the benefits of it by porting your UIKit elements into the SwiftUI preview. But sometimes for some un/known reason, canvas can not reload the view in time and it's not working.
For example:
When you work on a catalyst project and select mac as a target.
When you use a custom run script that cause a change on the xcworkspace during the build process (like auto build number increment script or etc.)
When you have a long task that triggers the watch dog event. (like recursion or massive loop)
Syntax error
Complex swift code
etc.
These are just a few of them that I faced and conformed. For more information about the issue, most of the time the canvas itself reports the issue and you can read about it with clicking on Diagnostics button above the canvas window:
But some times you can't even see this pan. Sometimes disable and enable the canvas works for that situation and sometimes restarting Xcode (or even mac) works, but some times not!
Hope it helps you save some time.

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

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).
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.
Not only WKWebView, also AVPlayerView should not placed int IB, too.
it cause same result.

Changing design layout in realtime?

Just curious - is it possible to change the color/design of elements in storyboard and see them reflected on the app that is running?
For example, changing the background color of a label, and then seeing that result on my iPhone (assuming Xcode is currently running the app) WITHOUT rebuilding the whole app?
You want to see changes made in your source reflected in the application running on your device, without having to rebuild and deploy the app (I think). If so, you cannot do that at this time using Xcode and iOS.

How do I initialize IKImageView?

I am completely stumped with this one: I'm new to Xcode, coming from Windows. I create a brand new Cocoa app, place an IKImageView in Interface Builder, save and launch the app. Xcode shows the app icon bouncing forever, never launching. If I trace into it I get application crash right away.
I've downloaded examples from Apple but I cannot see how they initialize IKImageView, if that's what I'm failing to do. I've been searching for a solution for hours. Help?
The problem is that you are not including the required frameworks that are used by IKImageView. Just follow the instructions that are found in the Image Kit Programming Guide, in particular the section labeled Using the Image Kit in Xcode and you should have no problems.

Resources