Cant drag a button from library to canvas - help please!

I have been working on the “Your First IOS and SwiiftUI from Scratch tutorial”, on the challenge where you add a second button, I cant drag a button on the other canvas…I can drag it into code but not the canvas. I fact I cant drag anything onto the canvas where I could before. What am I missing? I must of clicked on something…

I have narrowed this down to the code that they suggest to put in due to a depreciated bit of code in IOS 15 and later (in the sorry to interrupt part of the video…)

instead of this:

.alert(isPresented: $alertIsVisible, content: {
              return Alert(title: Text("Hello there!"), message: Text("This is my first pop-up"), dismissButton: .default(Text("Awesome!")))
            })

they say to put this in:

            .alert("Hello There!!", isPresented: $alertIsVisible) { Button("Awesome!") {}
            } message: {
                Text("This is my first popup")
            }

Both work, both compile…

but with the newer code, I then can’t drag and drop any more object from the library to the canvas…it is like the canvas becomes read only…

Please advise

I also notice a blue border around the outline of the iPhone on the canvas… and when I click the “selectable” icon at the bottom, I can even click on the buttons or text to look at the attributes like say the button name. It is as if the canvas is frozen…

@ jessycatterwaul just tagging you as you authored the IOS 15 change in this tutorial, I am trying to get this solved…

@jessycatterwaul please see above

@robertomachorro curious if you paste that code into a blank new app if you can duplicate it?

Hey folks, since I first started this thread, XCode updated from I believe v14.0 to 14.2 and IOS 16.2. Something about that update fixed it. I believe there was a bug in Xcode that was causing it. Nothing else changed on my end. SO, I hope this helps any of you that had the issue. I would be curious to see if anyone can duplicate it prior to XCode 14.2

Thank you all!

1 Like

Welcome to the mysteries of Xcode :wink:

1 Like

lol @robertomachorro is this type of thing common with Xcode? I come from a C#/.net/Visual Studio world…So I am not really sure. I do not remember many Visual Studio issues short of things that were my end…this is why I ask :smiley:

Xcode in its current iteration is a much younger tool, in addition to rapidly evolving in its toolset (From Interface Builder to Canvas, Objective-C to Swift, many new instrumentations, etc). Visual Studio in form and function hasn’t changed that much since 2010 (I’m also a C#/C++/C developer). Their level of maturity isn’t an apples to apples comparison.

To answer your question. Xcode is stable, but has been known to come with some annoying issues from time to time, the good news is that Apple is fast to fix. As a matter of fact, there is a new release as I type, feel free to download.

@robertomachorro yes I believe I have the newest one which seems to have fixed the issue, I am on Version 14.2 (14C18). Greetings to you as a fellow C# developer. I started with Basic back in the Commodore 64 days, then I jumped to C, then C++ then Delphi (Object Pascal), then C#… I just now started the Swift world here at Kodeco, but I did write an app for an in-house use at a company I worked for with Xamarin for IOS and Android and also Mac. So far I am loving how easy Swift is, at least so far!

1 Like