Skip to content

Commit e4896c0

Browse files
danil-pavlovdaugeldaugetimofey-solonin
authored
feat: privacy manifests update (#4263)
* Privacy manifests update (#4165) --------- Co-authored-by: Artem Daugel-Dauge <[email protected]> Co-authored-by: Timofey Solonin <[email protected]>
1 parent 8aa6077 commit e4896c0

File tree

1 file changed

+74
-9
lines changed

1 file changed

+74
-9
lines changed

docs/topics/native/apple-privacy-manifest.md

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,10 @@ app that fall under the [required reasons](https://developer.apple.com/documenta
2828
category.
2929

3030
Ideally, all SDKs that your app uses provide their own privacy manifest, and you don't need to worry about that.
31-
But if some of your dependencies don't do this, your App Store submission will be flagged.
32-
33-
> As of April 22, the App Store does not check API usage in dynamically linked libraries, so only static dependencies affect the check;
34-
> however, this may change in the future.
35-
>
36-
{type="note"}
31+
But if some of your dependencies don't do this, your App Store submission may be flagged.
3732

3833
## How to resolve
3934

40-
To ensure that your Kotlin Multiplatform app meets the App Store requirements, you can list all of the required reason
41-
APIs in the app's privacy manifest.
42-
4335
After you have tried to submit your app and received a detailed issue list from the App Store, you can build your manifest
4436
following the Apple documentation:
4537

@@ -51,5 +43,78 @@ The resulting file is a collection of dictionaries. For each accessed API type,
5143
from the provided list. Xcode helps edit `.xcprivacy` files by providing a visual layout and dropdown lists with
5244
valid values for each field.
5345

46+
You can use a [special tool](#find-usages-of-required-reason-apis) to find usages of required reason APIs in the dependencies
47+
of your Kotlin framework and a [separate plugin](#place-the-xcprivacy-file-in-your-kotlin-artifacts) to bundle
48+
`.xcprivacy` file with your Kotlin artifacts.
49+
5450
If a new privacy manifest doesn't help satisfy App Store requirements or you cannot figure out how to go through the steps,
5551
contact us and share your case in [this YouTrack issue](https://youtrack.jetbrains.com/issue/KT-67603).
52+
53+
## Find usages of required reason APIs
54+
55+
Kotlin code in your app or one of the dependencies may access required reason APIs from libraries such as `platform.posix`,
56+
for example, `fstat`:
57+
58+
```kotlin
59+
import platform.posix.fstat
60+
61+
fun useRequiredReasonAPI() {
62+
fstat(...)
63+
}
64+
```
65+
66+
In some cases, it may be difficult to determine which dependencies use the required reason API.
67+
To help you find them, we've built a simple tool.
68+
69+
To use it, run the following command in the directory where the Kotlin framework is declared in your project:
70+
71+
```shell
72+
/usr/bin/python3 -c "$(curl -fsSL https://github.com/JetBrains/kotlin/raw/rrf_v0.0.1/libraries/tools/required-reason-finder/required_reason_finder.py)"
73+
```
74+
75+
You may also [download this script](https://github.com/JetBrains/kotlin/blob/rrf_v0.0.1/libraries/tools/required-reason-finder/required_reason_finder.py)
76+
separately, inspect it, and run it using `python3`.
77+
78+
## Place the `.xcprivacy` file in your Kotlin artifacts
79+
80+
If you need to bundle the `PrivacyInfo.xcprivacy` file with your Kotlin artifacts, use the `apple-privacy-manifests` plugin:
81+
82+
```kotlin
83+
plugins {
84+
kotlin("multiplatform")
85+
kotlin("apple-privacy-manifests") version "1.0.0"
86+
}
87+
88+
kotlin {
89+
privacyManifest {
90+
embed(
91+
privacyManifest = layout.projectDirectory.file("PrivacyInfo.xcprivacy").asFile,
92+
)
93+
}
94+
}
95+
```
96+
97+
The plugin will copy the privacy manifest file to the [corresponding output location](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/adding_a_privacy_manifest_to_your_app_or_third-party_sdk?language=objc).
98+
99+
## Known usages
100+
101+
### Compose Multiplatform
102+
103+
Using Compose Multiplatform may result in `fstat`, `stat` and `mach_absolute_time` usages in your binary.
104+
Even though these functions are not used for tracking or fingerprinting and are not sent from the device, Apple can still
105+
flag them as APIs with missing required reasons.
106+
107+
If you must specify a reason for `stat` and `fstat` usages, use `0A2A.1`. For `mach_absolute_time`, use `35F9.1`.
108+
109+
For further updates on required reasons APIs used in Compose Multiplatform, follow [this issue](https://github.com/JetBrains/compose-multiplatform/issues/4738).
110+
111+
### Kotlin/Native runtime in versions 1.9.10 or earlier
112+
113+
The `mach_absolute_time` API is used in the `mimalloc` allocator in the Kotlin/Native runtime. This was the default
114+
allocator in Kotlin 1.9.10 and earlier versions.
115+
116+
We recommend upgrading to Kotlin 1.9.20 or later versions. If the upgrade is impossible, change the memory allocator.
117+
To do that, set the `-Xallocator=custom` compilation option in your Gradle build script for the current Kotlin allocator
118+
or `-Xallocator=std` for the system allocator.
119+
120+
For more information, see [Kotlin/Native memory management](native-memory-manager.md).

0 commit comments

Comments
 (0)