-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update: header file descriptions #4489
base: master
Are you sure you want to change the base?
Conversation
c212cf5
to
157b4c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great improvement 🚀 - I left some notes, please let me know what you think! 👍
@@ -1,371 +1,346 @@ | |||
[//]: # (title: Kotlin/Native as an Apple framework – tutorial) | |||
|
|||
> The Objective-C libraries import is [Experimental](components-stability.md#stability-levels-explained). | |||
> All Kotlin declarations generated by the `cinterop` tool from Objective-C libraries | |||
> All Kotlin declarations generated by the cinterop tool from Objective-C libraries | |||
> should have the `@ExperimentalForeignApi` annotation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm 🤔 is there a reason why we are saying should here?
Could we rephrase it like:
"When generating Kotlin declarations from Objective-C libraries with the cinterop tool, add the @ExperimentalForeignApi
annotation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This a common note for several pages that was approved by the dev team and changing it is not a part of this PR.
The IDE makes a suggestion in this case, so you don't actually add this annotation manually
There is also the [Kotlin/Native as a Dynamic Library](native-dynamic-libraries.md) | ||
tutorial for more information. | ||
Kotlin/Native provides bidirectional interoperability with Objective-C/Swift. You can both use Objective-C frameworks | ||
and libraries in Kotlin code, and Kotlin modules in Swift/Objective-C code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and libraries in Kotlin code, and Kotlin modules in Swift/Objective-C code. | |
and libraries in Kotlin code, and Kotlin modules in Objective-C/Swift code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to keep it consistent (Objective-C/Swift )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed everywhere to Swift/Objective-C to keep it consistent with the main interop page
|
||
<tabs group="build-script"> | ||
<tab title="Kotlin" group-key="kotlin"> | ||
While it's possible to use the command line to create a Kotlin framework, either directly or by combining it with a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Optional - Suggestion)
This sentence feels a bit long, could we break it into two?
You can create a Kotlin framework using the command line, either directly or with a script file, such as a .sh
or .bat
file. However, this approach....
|
||
Use the following `build.gradle(.kts)` Gradle build file: | ||
* [Create a Kotlin library and compile it to a framework](#create-a-kotlin-library) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this bullet point we use the "compile to a framework" but in the section below we use "produce/build a framework"
While I think all terms are correct I think produce/build is slightly more accurate as the compilation is only part of it if I understand correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's different. Here, we're talking about doing smth with a library, and not a separate action of building a framework
options like "produce/build library to a framework" just don't work
<tab title="Kotlin" group-key="kotlin"> | ||
While it's possible to use the command line to create a Kotlin framework, either directly or by combining it with a | ||
script file (such as `.sh` or `.bat` file), this approach doesn't scale well for big projects that have hundreds of files | ||
and libraries. Therefore, it's better to compile using a build system, as it helps to download and cache the Kotlin/Native |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again as above - perhaps we could avoid referring to the compilation (unless we want to highlight it specifically)
Suggestion - does this retain the same meaning? :
"Therefore, using a build system simplifies the process by downloading and caching the Kotlin/Native compiler binaries and the libraries with transitive dependencies, as well as running the compiler and tests."
easier to use with Swift. Convert the previous Objective-C example | ||
into Swift. As a result, you'll have the following code in `main.swift`: | ||
The framework you compiled has helper attributes to make it easier to use with Swift. Let's convert the previous | ||
Objective-C example into Swift. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if someone is only reading the swift part here - could we include a link to the Objective-C example?
e.g.:
the previous Objective-C example
only one instance. The `Object.shared` syntax is used to access this single instance. | ||
|
||
Methods and property names are translated as is. Kotlin's `String` is turned into Swift's `String`. Swift | ||
hides `NSNumber*` boxing too. You can also pass a Swift closure to Kotlin and call a Kotlin lambda function from Swift. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we include some clarification why this is good? - like:
Swift hides NSNumber*
boxing too, making it seamless to work with Kotlin number types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not trying to sell this point, just describing the code above
There are some small differences between the original Kotlin code and its Swift version. In Kotlin, any `object` has | ||
only one instance. The `Object.shared` syntax is used to access this single instance. | ||
|
||
Methods and property names are translated as is. Kotlin's `String` is turned into Swift's `String`. Swift |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As before is there a way to avoid saying method here if it relates to Kotlin? 🤔
|
||
## Connect the framework to iOS project | ||
|
||
Now you can connect the generated framework to the iOS project as a dependency. There are multiple ways to set it up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you can connect the generated framework to the iOS project as a dependency. There are multiple ways to set it up | |
Now you can connect the generated framework to your iOS project as a dependency. There are multiple ways to set it up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this work like this?
|
||
You can find more information about type mapping in [Interoperability with Swift/Objective-C](native-objc-interop.md#mappings). | ||
|
||
## Connect the framework to iOS project |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Connect the framework to iOS project | |
## Connect the framework to your iOS project |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this work like this?
No description provided.