{"schemaVersion":1,"title":"Swift setup","url":"https://appgram.dev/docs/guides/sdks/swift","markdownUrl":"https://appgram.dev/docs/format-md/guides/sdks/swift.md","jsonUrl":"https://appgram.dev/docs/agent/pages/guides/sdks/swift.json","version":"current","locale":"en","markdown":"# Swift setup\n\nAdd the tagged Swift package, configure it, and show native feedback.\n\nUse the native SwiftUI SDK for iOS 17+ and macOS 14+. The package uses Swift tools 5.9 or newer.\n\n## Add the package\n\nAdd the public package with Swift Package Manager. Version 1.0.1 is a tagged release:\n\n```swift\n.package(url: \"https://github.com/AppGram/apple-sdk.git\", from: \"1.0.1\")\n```\n\nAdd the `AppGramSDK` library product to your application target. The imported module is `AppGramSDK`, with that capitalization.\n\n## Configure and open feedback\n\nConfigure the singleton on the main actor before requesting a view. Replace the project ID:\n\n```swift\nimport SwiftUI\nimport AppGramSDK\n\n@main\n@MainActor\nstruct FeedbackApp: App {\n    init() {\n        AppGramSDK.shared.configure(projectId: \"YOUR_PROJECT_ID\")\n    }\n\n    var body: some Scene {\n        WindowGroup {\n            NavigationStack {\n                if let feedback = try? AppGramSDK.shared.feedbackView() {\n                    feedback\n                } else {\n                    Text(\"Configure AppGram before opening feedback.\")\n                }\n            }\n        }\n    }\n}\n```\n\nThe view factory throws when the SDK is not configured. The example handles that failure instead of force-unwrapping the result.\n\nBefore testing the view, create and approve the sample request in [Getting started](/guides/getting-started). Confirm it appears, cast a vote, and refresh the same request in the dashboard to check the saved count. An empty successful response can mean the project has no approved feedback.\n\n> Client configuration uses a public project ID\n>\n> Leave the optional `apiKey` argument unset in a distributed application. A management API key belongs on your server. Some older generated reference examples include that argument; it is not required for this client setup.\n\n## Identify the current customer\n\nAfter sign-in, you can supply customer context:\n\n```swift\nAppGramSDK.shared.setUser(\n    userId: \"customer-123\",\n    email: \"customer@example.com\",\n    name: \"Alex\"\n)\n\n// When the customer signs out:\nAppGramSDK.shared.clearUser()\n```\n\nCustomer context associates feedback and support activity; it does not grant management permissions. Send only the fields your application needs.\n\n## Other views and configuration\n\nThe [Swift reference](/ios-sdk) documents the available view factories, services, configuration types, and models. For releases and announcements, consult `AnnouncementConfiguration` and its organization and project slugs. `baseURL` accepts the API origin and defaults to `https://api.appgram.dev`.\n\n[Public package source](https://github.com/AppGram/apple-sdk) · [Troubleshooting](/guides/troubleshooting)\n\n","contentLocale":"en","isFallback":false,"authorship":{"authors":[],"contributors":[],"reviewedBy":[]}}