Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

danil-pavlov
Copy link
Contributor

No description provided.

@danil-pavlov danil-pavlov marked this pull request as ready for review October 17, 2024 11:49
@danil-pavlov danil-pavlov requested a review from a team as a code owner October 17, 2024 11:49
docs/topics/native/apple-framework.md Outdated Show resolved Hide resolved
docs/topics/native/apple-framework.md Outdated Show resolved Hide resolved
docs/topics/native/apple-framework.md Outdated Show resolved Hide resolved
docs/topics/native/apple-framework.md Outdated Show resolved Hide resolved
docs/topics/native/apple-framework.md Outdated Show resolved Hide resolved
docs/topics/native/apple-framework.md Outdated Show resolved Hide resolved
docs/topics/native/apple-framework.md Show resolved Hide resolved
docs/topics/native/apple-framework.md Outdated Show resolved Hide resolved
docs/topics/native/apple-framework.md Outdated Show resolved Hide resolved
docs/topics/native/apple-framework.md Outdated Show resolved Hide resolved
docs/topics/native/apple-framework.md Outdated Show resolved Hide resolved
docs/topics/native/apple-framework.md Outdated Show resolved Hide resolved
docs/topics/native/apple-framework.md Outdated Show resolved Hide resolved
Copy link
Contributor

@daniCsorbaJB daniCsorbaJB left a 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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor

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 )

Copy link
Contributor Author

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
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor Author

@danil-pavlov danil-pavlov Dec 2, 2024

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
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Connect the framework to iOS project
## Connect the framework to your iOS project

Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants