# New Idea: Swift Playgrounds Mode for Processing

**URL:** <https://discourse.processing.org/t/new-idea-swift-playgrounds-mode-for-processing/10021>\
**Category:** Summer of Code\
**Created:** [April 6, 2019, 2:11am UTC](https://discourse.processing.org/t/new-idea-swift-playgrounds-mode-for-processing/10021 "2019-04-06T02:11:22Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![XinyuYou](https://avatars.discourse-cdn.com/v4/letter/x/2acd7d/32.png) [@XinyuYou](https://discourse.processing.org/u/XinyuYou)\
**Post date:** [April 6, 2019, 2:11am UTC](https://discourse.processing.org/t/new-idea-swift-playgrounds-mode-for-processing/10021/1 "2019-04-06T02:11:22Z")

</div>

Hello everyone, My name is Xinyu You, a second-year postgraduate student of the National University of Defense Technology (NUDT), China.

After Play with Processing, I find that I really love this! It’s one of the best cross-application of art and Computer Science！

So, I have an idea for Swift Playground Mode for Processing.  
The benefits to do so:

1. The Swift programming language is easy, fast and safe. It has a very active community and development community.

2. There is an Android Version for Processing. But there is no iOS Version which also has a large user community, for Processing.

3. The Swift Playgrounds (Both on Mac and iPad) can help people learn and create in an interactive environment designed for touch. People can write Processing code in the left half and see real-time art effects in the right half.  

4. Swift Playgrounds’s Processing on the iPad is not only suitable for the artist but also good for children to learn and play with Processing to create artwork.

In general, doing this is very beneficial for Processing or the iOS community.

So, If this proposal is acceptable, I would like to discuss:

1. Whether it can participate in GSoC 2019 and is there any mentor who can guide me through the process?
2. If this proposal can participate, I would like to discuss the feasibility with everyone, such as whether to use the JVM like other languages or to use native Swift (for example, for image processing, there is Core Graphics Framework).

More About Me:  
I have a strong Computer Science background and experience in iOS development. I have great communication ability. I write a blog ([data2art.com](http://data2art.com)) in Chinese. I have planned to write more posts in English.

My Resume: [resume.data2art.com](http://resume.data2art.com)

Thanks for your browsing and I am looking forward to your suggestions and opinions.

Best Regards  
Xinyu You

---

<div class="post-metadata">

**Author:** ![XinyuYou](https://avatars.discourse-cdn.com/v4/letter/x/2acd7d/32.png) [@XinyuYou](https://discourse.processing.org/u/XinyuYou)\
**Post date:** [April 6, 2019, 2:12am UTC](https://discourse.processing.org/t/new-idea-swift-playgrounds-mode-for-processing/10021/2 "2019-04-06T02:12:34Z")

</div>

I am a new user, so I can only put 2 links in that post. There I want to add More:

The Image is from [https://www.apple.com/swift/playgrounds/](https://www.apple.com/swift/playgrounds/)

Core Graphics Framework Link: [https://developer.apple.com/documentation/coregraphics](https://developer.apple.com/documentation/coregraphics)

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [April 8, 2019, 1:57am UTC](https://discourse.processing.org/t/new-idea-swift-playgrounds-mode-for-processing/10021/3 "2019-04-08T01:57:06Z")

</div>

@XinyuYou Did you check this [link](https://github.com/processing/processing/wiki/Project-List#processing-for-ios) before? Would Kotlin Native be an option for you? I cannot comment on iOS in Processing as it is not my domain. Pinging @Andres as he might be able to provide you more details.

Kf

---

<div class="post-metadata">

**Author:** ![Andres](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/andres/32/18007_2.png) [@Andres](https://discourse.processing.org/u/Andres)\
**Post date:** [April 8, 2019, 2:45am UTC](https://discourse.processing.org/t/new-idea-swift-playgrounds-mode-for-processing/10021/4 "2019-04-08T02:45:06Z")

</div>

@XinyuYou sorry I missed your first post, @kfrajer thanks for the heads up.

So, yes, this is a very exciting project idea we only posted a few days ago in the wiki. We think that the possibility of using the Kotlin Native to run Processing sketches on both iOS and Android is really promising. Even though your original interest is in Swift, this project is very related to your aim of creating a tool that is useful to the Processing and iOS communities. Also, Kotlin is considered the equivalent of [Swift of Android](https://dev.to/sciencesoft/kotlin-vs-swift-are-android-and-ios-moving-towards-creating-a-universal-language) 🙂

Sarah Lansing, who came up with this idea, put together a couple of project templates as starting points, which are available in the wiki section mentioned before, as well as some general references. I’m copying them below:

Kotlin multi-platform project (MPP) tutorial: [https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html](https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html)

Kotlin MPP Processing app template: [https://github.com/sarahlensing/kotlin-mpp-processing-app](https://github.com/sarahlensing/kotlin-mpp-processing-app)

Kotlin MPP Processing library template: [https://github.com/sarahlensing/kotlin-mpp-processing-lib](https://github.com/sarahlensing/kotlin-mpp-processing-lib)

I hope this information is useful!

---

<div class="post-metadata">

**Author:** ![XinyuYou](https://avatars.discourse-cdn.com/v4/letter/x/2acd7d/32.png) [@XinyuYou](https://discourse.processing.org/u/XinyuYou)\
**Post date:** [April 8, 2019, 12:16pm UTC](https://discourse.processing.org/t/new-idea-swift-playgrounds-mode-for-processing/10021/5 "2019-04-08T12:16:35Z")

</div>

@kfrajer Thank you for your replay. You really help me.

---

<div class="post-metadata">

**Author:** ![XinyuYou](https://avatars.discourse-cdn.com/v4/letter/x/2acd7d/32.png) [@XinyuYou](https://discourse.processing.org/u/XinyuYou)\
**Post date:** [April 8, 2019, 12:28pm UTC](https://discourse.processing.org/t/new-idea-swift-playgrounds-mode-for-processing/10021/6 "2019-04-08T12:28:15Z")

</div>

Hi @Andres, Thank you for your detailed information. I am so happy that there is a project in Processing, aimed at iOS and Android Platform. I hope I can contribute to it and work with you.

Thank you for your assistance again.

---

<div class="post-metadata">

**Author:** ![sarahlensing](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sarahlensing/32/4391_2.png) [@sarahlensing](https://discourse.processing.org/u/sarahlensing)\
**Post date:** [April 9, 2019, 12:41am UTC](https://discourse.processing.org/t/new-idea-swift-playgrounds-mode-for-processing/10021/7 "2019-04-09T00:41:46Z")

</div>

@XinyuYou Your experience with iOS development and the Core Graphics Framework seem like a great fit for this project. You still [have time](https://developers.google.com/open-source/gsoc/timeline) to submit a proposal for GSOC! Just get something in by tomorrow, April 9. As mentioned above, we are interested in adding an iOS mode via Kotlin Native. Since Kotlin Native has a library for [Core Graphics](https://github.com/JetBrains/kotlin-native/tree/master/platformLibs/src/platform/ios), we could write the iOS Processing library implementation in Kotlin and use Kotlin Native to compile it into an iOS Framework. With that iOS framework, a developer could use Swift Playgrounds for Processing or develop a complex iOS application. So, your idea for Swift Playground support is definitely in line with the future we are envisioning.

---

<div class="post-metadata">

**Author:** ![sarahlensing](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sarahlensing/32/4391_2.png) [@sarahlensing](https://discourse.processing.org/u/sarahlensing)\
**Post date:** [April 9, 2019, 12:42am UTC](https://discourse.processing.org/t/new-idea-swift-playgrounds-mode-for-processing/10021/8 "2019-04-09T00:42:31Z")

</div>

Take a look at those example projects. The Kotlin Native iOS Framework output directory is set [here](https://github.com/sarahlensing/kotlin-mpp-processing-app/blob/master/gradle.properties#L3) and then read within the copyFramework task [here](https://github.com/sarahlensing/kotlin-mpp-processing-app/blob/master/app/build.gradle#L93).

---

<div class="post-metadata">

**Author:** ![sarahlensing](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sarahlensing/32/4391_2.png) [@sarahlensing](https://discourse.processing.org/u/sarahlensing)\
**Post date:** [April 9, 2019, 12:43am UTC](https://discourse.processing.org/t/new-idea-swift-playgrounds-mode-for-processing/10021/9 "2019-04-09T00:43:12Z")

</div>

If you open the [XCode project](https://github.com/sarahlensing/kotlin-mpp-processing-app/tree/master/iosApp/iosApp.xcodeproj) you will see how the generated framework is linked to in the the consuming application.

You seem like you’re on the right track so just be sure to submit a proposal before the deadline.

---

<div class="post-metadata">

**Author:** ![Andres](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/andres/32/18007_2.png) [@Andres](https://discourse.processing.org/u/Andres)\
**Post date:** [April 9, 2019, 3:38pm UTC](https://discourse.processing.org/t/new-idea-swift-playgrounds-mode-for-processing/10021/10 "2019-04-09T15:38:26Z")

</div>

@sarahlensing can you import Android libraries written in Java into a Kotlin multiplatform project? My guess would be that you can’t, but the conclusion in [this tutorial](https://proandroiddev.com/write-and-deploy-a-kotlin-library-compatible-with-android-and-ios-48415b49ebed) about Kotlin MPP seems to suggest that is is possible to import Android libraries such as okHttp… but perhaps that would work only in the Android module, right?

---

<div class="post-metadata">

**Author:** ![sarahlensing](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sarahlensing/32/4391_2.png) [@sarahlensing](https://discourse.processing.org/u/sarahlensing)\
**Post date:** [April 10, 2019, 1:19am UTC](https://discourse.processing.org/t/new-idea-swift-playgrounds-mode-for-processing/10021/11 "2019-04-10T01:19:17Z")

</div>

@Andres thats correct, you can import OkHttp into the Android target of the multiplatform library (or any other existing Android [dependency](https://github.com/florent37/Multiplatform-LiveData/blob/master/multiplatform-livedata-android/build.gradle#L16)) since that target compiles to the JVM.

---

<div class="post-metadata">

**Author:** ![alladinian](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/alladinian/32/10146_2.png) [@alladinian](https://discourse.processing.org/u/alladinian)\
**Post date:** [August 2, 2020, 9:37am UTC](https://discourse.processing.org/t/new-idea-swift-playgrounds-mode-for-processing/10021/12 "2020-08-02T09:37:22Z")

</div>

Hi there.  
I have just created a project that is [available on GitHub](https://github.com/alladinian/SwiftProcessing) that aims to port Processing’s functions for Swift on iOS & macOS.  
It doesn’t cover everything yet but it’s a good starting point. It’s also structured in a way that streamlines the workflow as much as possible (you can include it in a Playground on Xcode12+ or you can write and launch a sketch outside of Xcode for example).

Any contributions would be welcome of course!
