ebook img

Beginning Visual Studio for Mac: Build Cross-Platform Apps with Xamarin and .NET Core PDF

350 Pages·2017·15.22 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Beginning Visual Studio for Mac: Build Cross-Platform Apps with Xamarin and .NET Core

Beginning Visual Studio for Mac Build Cross-Platform Apps with Xamarin and .NET Core — Alessandro Del Sole Beginning Visual Studio for Mac Build Cross-Platform Apps with Xamarin and .NET Core Alessandro Del Sole Beginning Visual Studio for Mac Alessandro Del Sole Cremona, Italy ISBN-13 (pbk): 978-1-4842-3032-9 ISBN-13 (electronic): 978-1-4842-3033-6 https://doi.org/10.1007/978-1-4842-3033-6 Library of Congress Control Number: 2017957992 Copyright © 2017 by Alessandro Del Sole This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Cover image by Freepik (www.freepik.com). Managing Director: Welmoed Spahr Editorial Director: Todd Green Acquisitions Editor: Joan Murray Development Editor: Laura Berendson Technical Reviewer: Jordan Matthiesen and Mathieu Clerici Coordinating Editor: Jill Balzano Copy Editor: Kim Wimpsett Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit www.apress.com/ rights-permissions. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book’s product page, located at www.apress.com/9781484230329. For more detailed information, please visit www.apress.com/source-code. Printed on acid-free paper To my father, the brave, strong man I always hope to be like. To Angelica, who brings the sunshine into my life every day. To my mother, I can feel you’re still around. Contents at a Glance About the Author �����������������������������������������������������������������������������������������������������xv About the Technical Reviewers �����������������������������������������������������������������������������xvii Acknowledgments ��������������������������������������������������������������������������������������������������xix Introduction ������������������������������������������������������������������������������������������������������������xxi ■ Part I: Preparing for Development ������������������������������������������������������1 ■ Chapter 1: Configuring the Mac Development Machine ����������������������������������������3 ■ Chapter 2: Getting Started with the IDE and with Projects ���������������������������������15 ■ Chapter 3: Debugging Applications ���������������������������������������������������������������������87 ■ Part II: Building Mobile Apps with Xamarin �����������������������������������103 ■ Chapter 4: Introducing Xamarin ������������������������������������������������������������������������105 ■ Chapter 5: Building Android Applications ���������������������������������������������������������111 ■ Chapter 6: Building iOS Applications �����������������������������������������������������������������143 ■ Chapter 7: Building Cross-Platform Apps with Xamarin�Forms ������������������������171 ■ Chapter 8: Platform-Specific Code in Xamarin�Forms ���������������������������������������209 ■ Part III: Building Cross-platform Applications with �NET Core �������227 ■ Chapter 9: Introducing �NET Core ����������������������������������������������������������������������229 ■ Chapter 10: Creating ASP�NET Core Web Applications ���������������������������������������235 ■ Chapter 11: Creating RESTful Web API Services������������������������������������������������261 v ■ Contents at a GlanCe ■ Part IV: Collaboration and Productivity ������������������������������������������283 ■ Chapter 12: Team Collaboration: Version Control with Git ��������������������������������285 ■ Chapter 13: A Deeper Look at the IDE ����������������������������������������������������������������305 Index ���������������������������������������������������������������������������������������������������������������������341 vi Contents About the Author �����������������������������������������������������������������������������������������������������xv About the Technical Reviewers �����������������������������������������������������������������������������xvii Acknowledgments ��������������������������������������������������������������������������������������������������xix Introduction ������������������������������������������������������������������������������������������������������������xxi ■ Part I: Preparing for Development ������������������������������������������������������1 ■ Chapter 1: Configuring the Mac Development Machine ����������������������������������������3 Getting an Apple ID �����������������������������������������������������������������������������������������������������������3 Upgrading macOS ������������������������������������������������������������������������������������������������������������4 Creating a Developer Account ������������������������������������������������������������������������������������������4 Installing and Configuring Xcode �������������������������������������������������������������������������������������5 Installing Xcode ��������������������������������������������������������������������������������������������������������������������������������������5 Configuring the Developer Profile �����������������������������������������������������������������������������������������������������������6 Installing and Configuring Visual Studio for Mac��������������������������������������������������������������9 Summary ������������������������������������������������������������������������������������������������������������������������13 ■ Chapter 2: Getting Started with the IDE and with Projects ���������������������������������15 Taking a Step Back in History: Xamarin Studio ��������������������������������������������������������������15 Looking at the Welcome Page ����������������������������������������������������������������������������������������16 The Get Started Area �����������������������������������������������������������������������������������������������������������������������������17 The Recent Area �����������������������������������������������������������������������������������������������������������������������������������17 The News Area ��������������������������������������������������������������������������������������������������������������������������������������17 Understanding Runtimes and SDKs �������������������������������������������������������������������������������17 vii ■ Contents Working with Projects ����������������������������������������������������������������������������������������������������18 Creating Projects ����������������������������������������������������������������������������������������������������������������������������������18 Creating Your First C# Project ���������������������������������������������������������������������������������������������������������������28 Building and Running an Application ����������������������������������������������������������������������������������������������������31 Adding and Managing Dependencies ���������������������������������������������������������������������������������������������������33 Configuring Project Options ������������������������������������������������������������������������������������������������������������������39 Adding, Removing, and Renaming Items ����������������������������������������������������������������������������������������������49 Working with Pads ���������������������������������������������������������������������������������������������������������51 Docking, Hiding, and Rearranging Pads ������������������������������������������������������������������������������������������������51 The Classes Pad �����������������������������������������������������������������������������������������������������������������������������������53 The Errors Pad ��������������������������������������������������������������������������������������������������������������������������������������56 The Properties Pad �������������������������������������������������������������������������������������������������������������������������������58 The Tasks Pad ���������������������������������������������������������������������������������������������������������������������������������������59 The Package Console Pad ��������������������������������������������������������������������������������������������������������������������63 Working with the Code Editor �����������������������������������������������������������������������������������������63 Using Syntax Colorization ���������������������������������������������������������������������������������������������������������������������63 Using the Edit Menu �����������������������������������������������������������������������������������������������������������������������������63 Zooming the Code Editor ����������������������������������������������������������������������������������������������������������������������63 Fast Coding with IntelliSense ���������������������������������������������������������������������������������������������������������������63 Detecting and Fixing Code Issues As You Type �������������������������������������������������������������������������������������66 Refactoring Your Code ��������������������������������������������������������������������������������������������������������������������������69 Navigating Your Code ����������������������������������������������������������������������������������������������������������������������������73 Generating Types on the Fly������������������������������������������������������������������������������������������������������������������79 Enabling Multicursors ���������������������������������������������������������������������������������������������������������������������������80 Applying Themes ������������������������������������������������������������������������������������������������������������81 Using the Navigate To Tool ����������������������������������������������������������������������������������������������83 Browsing Help and Documentation ��������������������������������������������������������������������������������84 The Help Pad ����������������������������������������������������������������������������������������������������������������������������������������84 The Help Menu ��������������������������������������������������������������������������������������������������������������������������������������84 Summary ������������������������������������������������������������������������������������������������������������������������85 viii ■ Contents ■ Chapter 3: Debugging Applications ���������������������������������������������������������������������87 Meeting the Debuggers ��������������������������������������������������������������������������������������������������87 Preparing an Example ����������������������������������������������������������������������������������������������������87 Debugging an Application ����������������������������������������������������������������������������������������������88 Using Breakpoints and Data Visualizers �������������������������������������������������������������������������89 Configuring Breakpoints with Settings and Actions �����������������������������������������������������������������������������91 Investigating Runtime Errors ������������������������������������������������������������������������������������������94 Debugging Instrumentation ��������������������������������������������������������������������������������������������96 Debugging in Steps ������������������������������������������������������������������������������������������������������������������������������96 Debugging Pads ������������������������������������������������������������������������������������������������������������������������������������97 Debugging in Code �������������������������������������������������������������������������������������������������������100 Summary ����������������������������������������������������������������������������������������������������������������������101 ■ Part II: Building Mobile Apps with Xamarin �����������������������������������103 ■ Chapter 4: Introducing Xamarin ������������������������������������������������������������������������105 Considerations About Cross-Platform App Development ���������������������������������������������105 Understanding Xamarin and Its Objectives ������������������������������������������������������������������106 The Xamarin Platform �������������������������������������������������������������������������������������������������������������������������107 The Visual Studio Mobile Center ���������������������������������������������������������������������������������������������������������107 The Xamarin University �����������������������������������������������������������������������������������������������������������������������109 Summary ����������������������������������������������������������������������������������������������������������������������110 ■ Chapter 5: Building Android Applications ���������������������������������������������������������111 Preparing a Device for Development ����������������������������������������������������������������������������111 Creating an Android App with Xamarin ������������������������������������������������������������������������111 Understanding Fundamental Concepts About Xamarin�Android Solutions �����������������������������������������115 Understanding References and NuGet Packages �������������������������������������������������������������������������������116 Using Components ������������������������������������������������������������������������������������������������������������������������������116 Designing the User Interface ��������������������������������������������������������������������������������������������������������������117 Accessing the Android APIs in C# �������������������������������������������������������������������������������������������������������123 Setting App Properties with the Android Manifest ������������������������������������������������������������������������������128 ix ■ Contents Building and Debugging Apps �������������������������������������������������������������������������������������������������������������130 Managing Emulators and SDKs ����������������������������������������������������������������������������������������������������������136 Preparing Apps for Publishing ��������������������������������������������������������������������������������������140 Summary ����������������������������������������������������������������������������������������������������������������������142 ■ Chapter 6: Building iOS Applications �����������������������������������������������������������������143 Creating an iOS App with Xamarin �������������������������������������������������������������������������������143 Understanding Fundamental Concepts About Xamarin�iOS Solutions ������������������������������������������������146 Understanding References and NuGet Packages �������������������������������������������������������������������������������147 Using Components ������������������������������������������������������������������������������������������������������������������������������147 Designing the User Interface ��������������������������������������������������������������������������������������������������������������148 Accessing the Apple APIs in C# ����������������������������������������������������������������������������������������������������������153 Setting App Properties and Permissions ��������������������������������������������������������������������������������������������157 Building and Debugging Apps �������������������������������������������������������������������������������������������������������������161 Preparing Apps for Publishing ��������������������������������������������������������������������������������������166 Hints on macOS and tvOS Development ����������������������������������������������������������������������168 Summary ����������������������������������������������������������������������������������������������������������������������169 ■ Chapter 7: Building Cross-Platform Apps with Xamarin�Forms ������������������������171 Introducing Xamarin�Forms ������������������������������������������������������������������������������������������171 Creating and Understanding Xamarin�Forms Solutions �����������������������������������������������172 Understanding the Structure of Xamarin�Forms Solutions �����������������������������������������������������������������175 Understanding the Architecture of the Sample Application ����������������������������������������������������������������175 Managing the Application Life Cycle ��������������������������������������������������������������������������������������������������176 Designing the User Interface with XAML ��������������������������������������������������������������������������������������������176 Accessing Shared APIs in C# ��������������������������������������������������������������������������������������������������������������185 Building and Debugging Applications ���������������������������������������������������������������������������198 XAML Compilation ������������������������������������������������������������������������������������������������������������������������������200 Configuring PCL Project Options ���������������������������������������������������������������������������������������������������������200 Moving from PCLs to �NET Standard Libraries ������������������������������������������������������������������������������������202 Analyzing Applications with Instrumentation �������������������������������������������������������������������������������������203 Summary ����������������������������������������������������������������������������������������������������������������������207 x

Description:
Quickly learn how to get the most out of the Visual Studio for Mac integrated development environment (IDE). Microsoft has invested heavily to deliver their very best development tools and platforms to other operating systems. Visual Studio for Mac is a powerful developer tool that reinforces Micros
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.