Hi Alex here from rebeloper.com and welcome to ASD - App Store Domination
and today we are going to talk about warnings and errors and what's the
difference between them. So let's get to work!
Okay! Most of you when you just open up an Xcode project don't really get any
warnings or errors. But if you just start typing in or maybe it's an old project
then probably errors or warnings will come and I want to clarify in this video
what is the difference between warnings and errors. The major difference
between errors and warning is that with warnings your code will compile and will
build and you have a valid app. It runs but if you have errors in your code that
it will not compile. It will not run. It will simply crash. Of course you have
hidden crashes but that is not what I'm talking about today. We are going to talk
about what the Xcode interface really shows you and let me just go into some
simple examples. Let's go into ViewController and let's create here a
constant... and let's hit command+B to build it. As you can see we have a
reference to member 'purple' cannot be resolved without contextual type.
This is an error, so we need to add here UIColor.purple. Okay, and this
should fix it but now we are having a warning and that is with this yellow
triangle. Not the red circle. We have a yellow triangle and it says
initialization of immutable value backgroundColor was never
used. Well it basically says that we have created constant and we are never using it.
Let us just use it here and silence that warning. Okay! If we didn't
do that we can also go back and use the suggestion and that is if
you click on here and the let's fix it. We just simply replace it with an
underscore. As you can see if we try to build... let's just go back here and we
still have this error... let's build and run. Okay we need to
select simulator iPhoneX. This way our project
will built and it will run eventually. Let's just go ahead and here we have
our red background. If we have an error in it let's build and run again. Build has
failed so we cannot run our project. Let's go back here and I really like
this backgroundColor so I will just replace this .red. Let's build and run
one last time to see it in action and here we have our purple background.
Good stuff! Now you know what is the difference between warnings and errors.
Of course if you... just let me just go back and have that warning here...
here we have it! Let's build it with command + B and it says here that we have
one warning and it says Swift Compiler Warning and you have all of these
warnings and when you open an older project you have these warnings. Yeah,
most of first starters they think 'oh this is a very huge
problem'. Well it is you should always take care of your warnings but it's not
a big deal. Of course don't come writing to me 'oh I have a lot of errors'.
Well these are not errors. Your project will compile but these are warnings and
sometimes these warnings come in third-party libraries with Cocoapods.
We need to let the creators of those Cocoapods deal with those
warnings. Don't go inside the Cocoapod and fix those were things. You just have
to wait and then update your Cocoapods. Well that
is a story for a whole nother video and we will get into Cocoapods real soon.
If you did like this video go ahead and make sure you know now that what is
the difference between a warning and an error. I'm sure by now you do know
because I have hit the nails so hard in the head in this video. If you like
this video go ahead and check out my other product here in The Tribe.Aand if
you are an Indie go ahead and send us a message just simply click on Contact us
and ask for a huge discount. Of course you need to be an indie developer or an
indie studio. Go ahead and ask for discount for The Tribe.
This is The Tribe and I think I will finish this video of with this message. Go ahead and
take a look at The Tribe and I will see you tomorrow in the next one! Good stuff!
Now if you want to see more of this videos and want to boost your app
business go ahead and take a look at my 30 Days Challenge App Store Domination.
Go ahead and click the link down below and I will see you inside
ASD - App Store Domination! Let's get to work!