App not working as expected

I am working on IOS Fountations Swift UI Mod 5 Lesson 9.

We are making a learning app which is pretty complicated. We set up a home view with links to lessons and tests. We have completed implementation of the lessons including videos and descriptions. Now we are working on setting up the views for the tests that go with the lessons.

Here’s the problem. When I run my app it does not run properly in the simulator. I downloaded the demo version that Chris created, and his doesn’t run properly either, so it’s not a code issue. Although we have set up a partial view for the test screen, nothing shows up, and when you click on ‘Learn Swift’ you go to the lesson, but rebound back to the home page.

Below is a screen shot of what Chris’ test view looks like in the M5 L9 video. After the screen shot is a video showing what’s happening when I run the apps. You’ll also notice in the video that Chris’ app does not have all the elements in proper alignment.

I have tried restarting Xcode, restarting my MacBook, cleaning caches, and cleaning build folder.

Any ideas on how to fix this, would be appreciated. BTW preview is not working, but that usually doesn’t pose a problem with the simulator.

Hi Diane,

Yes, nearly everyone with Xcode 12.5 or 12.5.1 (iOS 14.5) are experiencing this annoying bug that has reared its ugly head. Hopefully when Xcode 13 is released and we also move to iOS 15 it will be resolved.

In the meantime there is a workaround to solve the issue with the App “bouncing” back from the ContentView.

See this thread:
https://codecrew.codewithchris.com/t/module-5-lesson-9/12857

Thanks, Chris. I was afraid something weird was happening in my computer! Or maybe my particular download of Xcode! You are always so kind to answer my questions!

Edit: I clicked the link but it said it doesn’t exist or is private.

You a member of CWC+ so you should have access to the Student section. Can you send an email to care@codewithchris.com and advise that you do not have access to the Student section on the code crew forum.

This was the response in the thread you can’t see which explains the workaround.

Hi Jim,

Yeah this is a bug affecting the NavigationLink where there are only two active links. (It is a very weird problem). The fix is to add the following code between the two NavigationLinks in HomeView.

NavigationLink(destination: EmptyView()) { }

I have no idea when Apple will fix this but chances are that when Xcode 13 is released, along with iOS 15, it may be resolved. Apple do know about it. The issue was raised back in October 2020 in the Swift Forums.

In Lesson 14 you will be adding a Network call to add SwiftUI Content and associated Tests. When you do you will be able to remove that temporary code since there will be 4 active NavigationLinks where the problem does not occur. Like I said, it’s a very weird bug.

Thanks, Chris.

I added the code and sent the email. The both the lesson and test views navigate properly now. However, as shown above I get no view when I navigate to the Test View. I have added a background color to see what would happen but the view is still white with no text. This also happens when I run Chris’ version of the app.

It must be another bug, but I don’t know what to do. I have searched for an answer, but couldn’t find anything relevant. Again, caches and build folder have been cleaned and all breakpoints deleted. I am still continuing to build the project per the lesson hoping something will fix this.

Any ideas are appreciated.

Diane,

What version of Xcode do you have at the moment?

I have Xcode 12

Is it just Xcode 12.0 or is it 12.1 or 12.2 or 12.3 or 12.4 or 12.5 or the latest 12.5.1?

Oh, sorry. it’s Xcode 12.5.1

If you go back to the Lesson 9 video now and watch it again you will see that it has been updated to address the bugs that everyone is experiencing. Chris has spliced in an explanation of how to fix the bouncing NavigationLink using the code I suggested above and also addresses the issue of nothing being visible in the TestView() after navigating to it.

The position in the video where this edit has been added in could cause a little confusion as after that edit the code does not reflect that alteration so everyone just has to keep in mind that the bug fix code applies even though in later videos that does not appear for obvious reasons.

I fixed the bugs, but still have the compiler error. There is too much going on here to create a new app. What should I do? Even when I paste in Chris Ching’s code the complier error persists.