Adding a login screen

When you launch the LetsEat app, you'll immediately see the Explore screen. There is no way for the user to sign in. Due to this, you will need to implement a Sign In screen to allow the user to sign in. Initially, this Sign In screen will just display a button to allow the user to sign in in Guest mode, but you will add the Sign in with Apple button later. Follow these steps to do so:

  1. Open the LetsEat project and build and run the app to make sure that it's working.
  2. Go to Xcode | Preferences | Accounts and make sure that you have entered the Apple ID credentials for a paid Apple Developer account.
  3. Click the LetsEat project in the Project navigator and click on Signing and Capabilities. Ensure the Team pop-up menu has been set for a paid Apple Developer account. If you get a Failed to register bundle identifier error, try changing the Bundle Identifier by adding some random characters to it, for example, com.12345.myname.LetsEat, and click the Try Again button:


  1. Click on the + button:


  1. The Object library will appear. Type sign into the filter field. You should see Sign in with Apple in the list of results. Double-click it.
  1. Sign in with Apple has been added to the Signing and Capabilities screen:


  1. If you see any errors appear, fix them before continuing by clicking on the appropriate buttons:


  1. Click on Main.storyboard in the Project navigator and click the + button to display the Object library:


  1. Type viewcon into the filter field. You will see a View Controller object as one of the results.
  2. Drag it into the storyboard to the left of the Tab Bar Controlleras shown in the following screenshot:


  1. Move the arrow indicating the initial View Controller from the Tab Bar Controller to the newly added View Controller:


  1. Click the + button to display the Object Library. Type button into the filter field. You will see a Button object as one of the results.
  1. Drag it into the view of the newly added View Controller:


  1. Change the button text to Guest Mode:

  1. Ctrl + Drag from the Guest Mode button to the Tab Bar Controller. Choose Present Modally from the pop-up menu:

  1. A segue will be created between the View Controller and the Tab Bar ControllerClick the segue to select it:


  1. In the Attributes inspector, set the Identifier to signin, set Presentation to Full Screen, and set Transition to Cross Dissolve:


  1. Select the View of the View Controller in the document outline. In the Attributes inspector, set Background to Lets Eat Dark Grey:


  1. Select the Guest Mode button in the document outline. In the Attributes inspector, set the Font to System Black 24.0:


  1. Set the button's Text Color to System Red Color:


  1. With the button selected, click the Add New Constraints button and add the following constraints:
  • Left: 30
  • Right: 30
  • Bottom: 300
  1. Build and run the app. Tap on the Guest Mode button:

  1. The Explore screen will be displayed.

Now that you've implemented the Sign In screen, you have a place to display the Sign in with Apple button. You will implement a view controller for the Sign In screen with the necessary code to display the Sign in with Apple button in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.106.100