试用 iOS 示例应用
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
使用我们的 iOS 和 macOS 示例应用了解 Google 登录的运作方式,或将 Google 登录添加到现有应用。
此示例展示了如何在 Swift for iOS 中集成 Sign-In,
macOS。
对于 Objective-C,请参阅 SignInSample 示例应用(位于 Google 登录适用于 iOS 的代码库中)。
如需使用此示例,请确保您已安装最新版本的 Xcode。
获取项目
DaysUntilBirthday Swift 示例应用可在 Sign-In 中找到
代码库
CocoaPods 和
Swift Package Manager。
请按照下方针对您的首选选项的说明下载并运行示例应用:
CocoaPods
-
如果您尚未安装 CocoaPods,请按照
<ph type="x-smartling-placeholder"></ph>
CocoaPods 入门指南。
-
克隆 iOS 版 Google 登录代码库:
git clone https://github.com/google/GoogleSignIn-iOS
-
前往
DaysUntilBirthday
目录:
cd GoogleSignIn-iOS/Samples/Swift/DaysUntilBirthday
-
安装 Cocoapods 依赖项:
pod install
-
在 Xcode 中打开
DaysUntilBirthdayForPod
工作区:
open DaysUntilBirthdayForPod.xcworkspace
Swift Package Manager
-
克隆 iOS 版 Google 登录代码库:
git clone https://github.com/google/GoogleSignIn-iOS
-
打开 Swift 示例项目:
open GoogleSignIn-iOS/Samples/Swift/DaysUntilBirthday/DaysUntilBirthday.xcodeproj
当 Xcode 打开项目时,Swift Package Manager 会自动添加依赖项。
运行应用
对于 iOS,选择 DaysUntilBirthday (iOS)
目标,然后通过点击工作区的运行按钮,在设备或 iOS 模拟器上启动示例应用。
对于 macOS,选择 DaysUntilBirthday (macOS)
目标,然后开始
通过单击工作区的运行按钮来启动示例应用。
后续步骤
您的体验是否愉快?遇到了问题?
欢迎提供您的意见!
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eThis page provides a Swift sample app, \u003cem\u003eDaysUntilBirthday\u003c/em\u003e, demonstrating Google Sign-In for iOS and macOS.\u003c/p\u003e\n"],["\u003cp\u003eYou can download and run the sample using either CocoaPods or Swift Package Manager.\u003c/p\u003e\n"],["\u003cp\u003eDetailed instructions are included for cloning the repository, installing dependencies, and running the application.\u003c/p\u003e\n"],["\u003cp\u003eObjective-C users can find a corresponding sample app (\u003cem\u003eSignInSample\u003c/em\u003e) in the GitHub repository.\u003c/p\u003e\n"],["\u003cp\u003eTo integrate Sign-In into your own app, refer to the provided implementation guide or explore the complete sample code on GitHub.\u003c/p\u003e\n"]]],[],null,["# Try iOS Sample App\n\nUse our iOS and macOS sample app to see how Sign-In works, or\n[add Sign-In to your existing app](/identity/sign-in/ios/start-integrating).\n\n\nThis sample shows how to integrate Sign-In in Swift for iOS and\nmacOS.\n\n\nFor Objective-C, see the\n[*SignInSample* sample app in the Google Sign-In for iOS\nrepository](https://github.com/google/GoogleSignIn-iOS/tree/main/Samples/ObjC/SignInSample).\n\n\nTo use this sample, make sure you have a current version of\n[Xcode](//developer.apple.com/xcode/) installed.\n\nGet the project\n---------------\n\n\nThe *DaysUntilBirthday* Swift sample app is available in the Sign-In\nrepository using\n[CocoaPods](https://cocoapods.org/) and\n[Swift Package Manager](https://www.swift.org/package-manager/).\nFollow the instructions for your preferred option below to download and run the sample app:\n\n### CocoaPods\n\n1. If you don't already have CocoaPods installed, follow the steps in the [CocoaPods Getting Started](https://guides.cocoapods.org/using/getting-started.html) guide.\n2. Clone the Google Sign-In for iOS repository: \n\n ```\n git clone https://github.com/google/GoogleSignIn-iOS\n ```\n3. Navigate to the `DaysUntilBirthday` directory: \n\n ```\n cd GoogleSignIn-iOS/Samples/Swift/DaysUntilBirthday\n ```\n4. Install the Cocoapods dependencies: \n\n ```\n pod install\n ```\n5. Open the `DaysUntilBirthdayForPod` workspace in Xcode: \n\n ```\n open DaysUntilBirthdayForPod.xcworkspace\n ```\n\n### Swift Package Manager\n\n1. Clone the Sign-In for iOS repository: \n\n ```\n git clone https://github.com/google/GoogleSignIn-iOS\n ```\n2. Open the Swift sample project: \n\n ```\n open GoogleSignIn-iOS/Samples/Swift/DaysUntilBirthday/DaysUntilBirthday.xcodeproj\n ```\n\n\nSwift Package Manager will automatically add the dependencies when\nXcode opens the project.\n\nRun the application\n-------------------\n\n\nFor iOS, select the `DaysUntilBirthday (iOS)` target, then start the\nsample application on a device or in the iOS simulator by clicking the run\nbutton for the workspace.\n\n\nFor macOS, select the `DaysUntilBirthday (macOS)` target, then start\nthe sample application by clicking the run button for the workspace.\n\nNext steps\n----------\n\n\nIf you want to see how you can implement Google Sign-In in your own\napp, take a look at our implementation guide. Or, take a look at the\ncomplete sample on GitHub.\n\n\n[Add Sign-In to your app](/identity/sign-in/ios/start-integrating)\n[See the sample apps on GitHub](https://github.com/google/GoogleSignIn-iOS/tree/main/Samples)\n\nDid you have a good experience? Run into trouble?\n[Let us know!]()"]]