邱 璇洛 (ゝ∀・)

邱 璇洛 (ゝ∀・)

你好哇(*゚∀゚*)~这里是邱璇洛的博客,常常用来记录一些技术文章和小日常~(σ゚∀゚)σ
twitter
tg_channel

Write C language projects anytime on iOS.

Why? 🤔️#

Indeed, this requirement sounds interesting. Who would have the time to write code on their phone/iPad? But isn't it cool? Imagine being able to pick up your phone anytime, anywhere and start coding, and actually be able to push it.

In reality, there is a long history of coding on mobile devices. Geeks have pushed the limits of these devices, and even though it may not be very productive, it's still pretty cool 🤩!

So, if you still have a curious and adventurous spirit, keep reading and I promise you'll be able to show off in front of your friends in no time.

Step 1: Make a List 🧾#

Let's clarify our goals:

  1. Write code for real.
  2. Run code locally.
  3. Be able to push to my remote repository.

I've searched through the App Store and found some good options:

1. Code App ¥30#

IMG_1580

Code App is a completely open-source project. It has a user-friendly interface and version control, a simple command line, and supports writing and running code in over ten different languages, although most of them are web-based. Currently, it supports local running of Node.js, Python, C, C++, and PHP.

For front-end developers, it's absolutely friendly because almost all front-end frameworks can run on it. It also has good support for other languages. However, it's not very user-friendly for users without a physical keyboard, and the operation can be a bit awkward. If you have the money to buy a Magic Keyboard, then it's the perfect development tool.

But!#

Although Code is powerful, it doesn't meet our requirement of being able to tinker anytime, anywhere, and it has a lot of limitations because the terminal is not real.

2. C Code Develop ¥5#

IMG_1579

C Code Develop is developed by a Chinese developer. It allows you to write small programs anytime, anywhere, and you can even upload them to the author's small store. The author has created many interesting things, such as bringing SwiftUI into it, writing small programs, writing small widgets, getting your own IP, sending GET requests, and more.

And most importantly, the interface is really beautiful, and you can customize the background. It not only has syntax highlighting but also auto-completion!

But!#

It doesn't support Git... Not only that, it doesn't even have a command line...

ish Free#

IMG_1581

ish is a completely open-source and free Linux emulator running on iOS. You can use it to run a nearly complete Alpine Linux on your device. You might be wondering, "Isn't Apple against virtual machines on the App Store?" Well, think again! This emulator is not a virtual machine!

With ish, you can almost enjoy Linux on your iPhone or iPad, and then quickly return to the graphical interface.

There is so much to say about this software, and it is popular both domestically and internationally. You can run almost any programming language on it, such as C, Python 3, Python 2, Lua, and OCaml. Unfortunately, it doesn't support Node.js and Rust yet. I also tried .NET, but it couldn't run (by the way, if you want to run .NET on iOS/iPadOS, I think the best software is Continuous). The kernel version is still Alpine Linux 3.14, and Rust only supports Alpine Linux starting from version 3.18.

Most importantly, it supports Git (after all, it's like half a Linux system).

But!#

This software is still in its early stages of development, and the author is actively updating it. There are still many issues and many things are not perfect. However, it is currently the best option for iOS/iPadOS.

Overall, it seems that only ish can meet our requirements to some extent. And having a terminal on your phone is really cool!

Now, let's get started!

Begin! 🤩#

First, download ish and open it!

You'll find that it looks just like a terminal, but you won't find any settings.
Actually, the settings are in the bottom right corner. The image below shows the basic operations, and the circled part is the settings.

IMG_1583

Great! After personalizing it, it's time to start coding for real!

Preparations before getting started! 🎼#

We need to set up the package manager first.

The package manager's command here is apk.

Due to some well-known reasons, we need to change the source in order to download packages normally. In the terminal, enter:

sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories && apk update

Wait for the command to finish running, and then you can happily install packages!

You can also customize the source in /etc/apk/repositories. Remember to run apk update after editing!

Download! Configure! ⬇️📦⚙️📄#

We need to install some necessary things.

The software already comes with gcc and make, but you'll find that they are not actually usable when you start writing code. In this case, we need to download a "patch".

In the terminal, enter:

apk add build-base

If your software doesn't come with gcc and make, you can also download them in the same way.

apk add gcc make

Or if you prefer to use clang, you can do that too, as you like.

Now, when you write a piece of code and try to compile it, you won't encounter missing header file errors anymore!

Next, we need Git. Just add it using the same method:

apk add git

If you want, you can also download editors like vim, nvim, nano, or emacs. Just add them in the same way!

Note⚠️#

There is a small issue here: nvim is not very stable on the iPhone (or rather, it's not stable at all), and vim goes crazy after configuration. However, on the iPad, there are no such problems. I suspect it may be due to the screen size.

About Git⬆️📊#

Git is an essential tool for developers, but there are some issues in ish that prevent Git from connecting to GitHub properly. However, we can still push our code using a personal access token.

First, download Git:

apk add git

Then, do the basic configuration, such as setting up your email and username. I won't go into details here, but you can easily find instructions online if you're not familiar with it.

We need to create a new repository on GitHub and create a personal access token with a duration of 30 days or longer in the settings.

When you try to push your changes to the repository, GitHub will prompt you to log in. At this point, entering your password won't work, so you need to enter your personal access token instead to complete the push operation.

Finally#

Life never stops, keep tinkering!

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.