Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/topics/native/native-binary-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ kotlinc-native main.kt -Xbinary=enableSafepointSignposts=true
<td>Description</td>
<td width="110">Status</td>
</tr>
<tr>
<td><a href="native-objc-interop.md#explicit-parameter-names-in-objective-c-block-types"><code>objcExportBlockExplicitParameterNames</code></a></td>
<td>
<list>
<li><code>true (default)</code></li>
<li><code>false</code></li>
</list>
</td>
<td>Adds explicit parameter names to function types for exported Objective-C headers.</td>
<td>Default since 2.3.0</td>
</tr>
<tr>
<td><a href="whatsnew2220.md#smaller-binary-size-for-release-binaries"><code>smallBinary</code></a></td>
<td>
Expand Down
23 changes: 13 additions & 10 deletions docs/topics/native/native-objc-interop.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,8 @@ foo {

#### Explicit parameter names in Objective-C block types

You can add explicit parameter names to Kotlin's function types for exported Objective-C headers. Without them,
Xcode's autocompletion suggests calling Objective-C functions with no parameter names in the Objective-C block,
and the generated block triggers Clang warnings.

To enable explicit parameter names, add the following [binary option](native-binary-options.md) to your `gradle.properties` file:

```none
kotlin.native.binary.objcExportBlockExplicitParameterNames=true
```
Kotlin adds explicit parameter names to function types for exported Objective-C headers.
Xcode's autocompletion then suggests them when calling Objective-C functions in the Objective-C block.

For example, for the following Kotlin code:

Expand All @@ -531,7 +524,8 @@ For example, for the following Kotlin code:
fun greetUser(block: (name: String) -> Unit) = block("John")
```

Kotlin forwards the parameter names from Kotlin function types to Objective-C block types, allowing Xcode to use them in suggestions:
Kotlin forwards the parameter names from Kotlin function types to Objective-C block types, allowing Xcode to use them in
suggestions:

```objc
// Objective-C:
Expand All @@ -545,6 +539,15 @@ greetUserBlock:^(NSString *name) {
>
{style="note"}

In case you run into issues, you can disable explicit parameter names with the following [binary option](native-binary-options.md)
in your `gradle.properties` file:

```none
kotlin.native.binary.objcExportBlockExplicitParameterNames=false
```

Please report such problems in our issue tracker, [YouTrack](https://kotl.in/issue).

### Generics

Objective-C supports "lightweight generics" defined in classes, with a relatively limited feature set. Swift can import
Expand Down