New Idea: Swift Playgrounds Mode for Processing

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) in Chinese. I have planned to write more posts in English.

My Resume: resume.data2art.com

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

Best Regards
Xinyu You

2 Likes

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/

Core Graphics Framework Link: https://developer.apple.com/documentation/coregraphics

1 Like

@XinyuYou Did you check this link 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

1 Like

@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 :slight_smile:

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

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

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

I hope this information is useful!

3 Likes

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

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.

@XinyuYou Your experience with iOS development and the Core Graphics Framework seem like a great fit for this project. You still have time 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, 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.

1 Like

Take a look at those example projects. The Kotlin Native iOS Framework output directory is set here and then read within the copyFramework task here.

If you open the XCode project 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.

@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 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?

@Andres thats correct, you can import OkHttp into the Android target of the multiplatform library (or any other existing Android dependency) since that target compiles to the JVM.

Hi there.
I have just created a project that is available on GitHub 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!

4 Likes