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:
- Open the LetsEat project and build and run the app to make sure that it's working.
- Go to Xcode | Preferences | Accounts and make sure that you have entered the Apple ID credentials for a paid Apple Developer account.
- 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:
- Click on the + button:
- 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.
- Sign in with Apple has been added to the Signing and Capabilities screen:
- If you see any errors appear, fix them before continuing by clicking on the appropriate buttons:
- Click on Main.storyboard in the Project navigator and click the + button to display the Object library:
- Type viewcon into the filter field. You will see a View Controller object as one of the results.
- Drag it into the storyboard to the left of the Tab Bar Controller, as shown in the following screenshot:
- Move the arrow indicating the initial View Controller from the Tab Bar Controller to the newly added View Controller:
- 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.
- Drag it into the view of the newly added View Controller:
- Change the button text to Guest Mode:
- Ctrl + Drag from the Guest Mode button to the Tab Bar Controller. Choose Present Modally from the pop-up menu:
- A segue will be created between the View Controller and the Tab Bar Controller. Click the segue to select it:
- In the Attributes inspector, set the Identifier to signin, set Presentation to Full Screen, and set Transition to Cross Dissolve:
- Select the View of the View Controller in the document outline. In the Attributes inspector, set Background to Lets Eat Dark Grey:
- Select the Guest Mode button in the document outline. In the Attributes inspector, set the Font to System Black 24.0:
- Set the button's Text Color to System Red Color:
- With the button selected, click the Add New Constraints button and add the following constraints:
- Left: 30
- Right: 30
- Bottom: 300
- Build and run the app. Tap on the Guest Mode button:
- 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.