You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-46Lines changed: 46 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,18 @@
4
4
5
5
# LinksKit
6
6
7
-
Apple requires that every app must link to their privacy policy and additionally to the terms of use (if it has in-app purchases) as part of their guidelines. Most apps solve this by adding a "Links" section somewhere in their apps settings. And while at it, they also add some more links like to rate the app, to their FAQ or to get support. This package comes with all these common things built-in so you can save a lot of time while setting up these kinds of screens. And it even supports the most common place on macOS as well: the help menu!
7
+
Every app on the App Store must provide essential links like a privacy policy and, if applicable, terms of use (for in-app purchases) to comply with Apple's guidelines. Many apps handle this by adding a "Links" section in their settings, including additional helpful links like app ratings, FAQs, and support options.
8
+
9
+
That's where LinksKit comes in: it offers **a simple, ready-to-use solution to handle all these common links**, saving you a ton of time. Whether it's legal, help, or app promotion links, LinksKit covers it. And for macOS, it even supports adding these links right into the **Help** menu!
10
+
8
11
9
12
## Usage
10
13
11
-
Basically, you just need to `import LinksKit` and place a `LinksView()`somewhere inside a `List` or `Form` view. It will automatically create all the sections you need. But for the `LinksView` to know what links to present, you need to do some setup first:
14
+
Getting started with LinksKit is easy. After adding the package to your project, simply `import LinksKit` and place a `LinksView()` inside a `List` or `Form` view. But before doing that, you'll need to configure the links you want to include.
12
15
13
16
### Minimal Setup
14
17
15
-
For the minimal variant which contains only the legal links and the app rating & contact email, you can add this code to your app entry point:
18
+
For a basic setup, which includes legal links (like privacy policy and terms of use), app rating, and a contact email, you can configure LinksKit like this:
16
19
17
20
```swift
18
21
importSwiftUI
@@ -37,19 +40,19 @@ struct YourApp: App {
37
40
}
38
41
```
39
42
40
-
> Tip: The `providerToken` is the `pt` query parameter in the campaign link of your app (e.g. ` https://apps.apple.com/app/apple-store/id123456789?**pt=123456**&ct=test1234&mt=8`). If you are new to campaign links, make sure to learn about them [here](https://developer.apple.com/help/app-store-connect/view-app-analytics/manage-campaigns) – they basically help you understand where people have discovered your app. Note that you don't have to create campaign links using App Store Connect over and over again – the `providerToken` is the same for all your apps and you can change the `campaignToken` (`ct` query parameter) to anything you like. LinksKit sends your apps Bundle ID as the campaign token by default, that's why you don't need to set it up.
43
+
> **Tip:** The `providerToken` is part of your app's campaign link (look for the `pt` query parameter). Campaign links are a great way to track where users are finding your app. Learn more about them [here](https://developer.apple.com/help/app-store-connect/view-app-analytics/manage-campaigns). LinksKit automatically uses your app's Bundle ID as the campaign token, so no extra setup is needed.
41
44
42
-
> Note: LinksKit automatically adds the link to Apples terms of use for apps with in-app purchasesto the `.legalLinks` section – no action needed. It just works. 🚀
45
+
> **Note:** LinksKit will automatically add Apple's terms of use link to `.legalLinks`for apps with in-app purchases. No need to configure it yourself – it just works! 🚀
43
46
44
47
### Optional Extras
45
48
46
-
LinksKit is fully customizable but comes also with built-in extras for your convenience:
49
+
LinksKit goes beyond the basics, offering more customization to fit your needs. You can:
47
50
48
-
*`.helpLinks` also accepts an optional`faqURL`parameter if you have a link for common questions
49
-
*`.socialMenus(appLinks:developerLinks:)` is for linking to your and/or your apps socials
50
-
*`.appMenus(ownAppLinks:friendsAppLinks:)` is for linking to your other apps and/or some friends apps
51
+
*Add an FAQ link with`faqURL`passed to `.helpLinks`
52
+
*Link to your app's or developer's social media with `.socialMenus(appLinks:developerLinks:)`
53
+
*Promote your other apps or apps from friends using `.appMenus(ownAppLinks:friendsAppLinks:)`
51
54
52
-
A real-world example from my app [TranslateKit](https://apps.apple.com/app/apple-store/id6476773066?pt=549314&ct=github.com&mt=8) that makes use of all these extras looks like this:
55
+
Here’s a real-world example from my app [TranslateKit](https://apps.apple.com/app/apple-store/id6476773066?pt=549314&ct=github.com&mt=8), showcasing all of these features:
53
56
54
57
```swift
55
58
init() {
@@ -111,35 +114,11 @@ func configureLinksKit() {
111
114
}
112
115
```
113
116
114
-
> Note: The reason `.ownApp` and `.friendsApp` are named differently is because LinksKit will automatically add your `providerToken` to your own apps while you need to pass your friends `publisherToken` using the optional parameter in case you know it.
115
-
116
-
### Custom Links & Menus
117
-
118
-
On top of the built-in convenience helpers `.helpLinks`, `.socialMenus`, `.appMenus`, and `.legalLinks`, you can also create own complete custom `LinkSection` instances and pass your own links. You can even nest them! For example, `.appMenus` is just a convenience for this equivalent `LinkSection`:
The `entries` parameter accepts one of `.menu(LinkMenu)` or `.link(Link)` and you can nest as many levels as SwiftUI supports (`.menu` becomes a `Menu` view, `.link` a `Button`).
117
+
> **Note:** The `.ownApp` and `.friendsApp` helpers behave differently for a reason. LinksKit will automatically append your `providerToken` for your own apps, while you'll need to manually include a `publisherToken` for your friends’ apps if you know it.
139
118
140
119
### View Setup
141
120
142
-
For all platforms except macOS, it's common to have a settings screen with a `Form` or `List`. Just add `LinksView()` inside it like so:
121
+
To add LinksKit to your app’s settings screen, typically structured as a `Form` or `List`, just insert a `LinksView()` like so:
143
122
144
123
```swift
145
124
importSwiftUI
@@ -157,14 +136,11 @@ struct SettingsView: View {
157
136
}
158
137
```
159
138
160
-
That's it – really! You can even remove the `#if !os(macOS)` check if your app doesn't natively support macOS.
161
-
162
-
The result on non-Mac platforms should look like this:
139
+
And that’s it! If you’re not targeting macOS, the result should look like this:
When targeting macOS, it's more common to put links into the `Help` menu bar instead of the Settings screen. To do this just add `LinksView()` to your commands menu like so:
143
+
For macOS apps, the best place for these links is often in the Help menu. You can easily add a `LinksView()` to the menu bar:
168
144
169
145
```swift
170
146
importSwiftUI
@@ -185,17 +161,41 @@ struct YourApp: App {
185
161
}
186
162
```
187
163
188
-
You need to pass `.labelStyle(.titleAndIcon)` to see the icons here, because by default, the menu entries use the `.titleOnly` label style.
If the default helpers like `.helpLinks` or `.appMenus` don't fit your exact use case, you can create fully custom `LinkSection` instances and add your own links. You can even nest them! For example, `.appMenus` is just a convenience for this equivalent `LinkSection`:
The `entries` parameter accepts one of `.menu(LinkMenu)` or `.link(Link)` and you can nest as many levels as SwiftUI supports (`.menu` is rendered as a `Menu` view, `.link` as a `Button`).
192
+
194
193
### Localization
195
194
196
-
All texts that are built-in to LinksKit are pre-localized to all [the same ~40 languages supported by iOS](https://www.apple.com/ios/feature-availability/#system-language-system-language). No action needed. If you need more languages, please open an issue on GitHub – I'm happy to add more.
195
+
All of LinksKit's built-in strings are already localized in around 40 languages, covering all the languages supported by iOS. No setup is needed. If you require additional languages, feel free to open an issue on GitHub – I’m happy to add them!
196
+
197
+
If you need to localize the names of your apps or any other passed text, you can use `String(localized:)` as usual in your app.
197
198
198
-
If you want to localize any other text you pass to LinksKit APIs such as the names of your apps, just use `String(localized: "your-text")` and localize the text in your apps String Catalog as usual.
0 commit comments