holzschu / ios_system

Drop-in replacement for system() in iOS programs
BSD 3-Clause "New" or "Revised" License
894 stars 146 forks source link

Request for kubectl #85

Open yisiqi opened 5 years ago

yisiqi commented 5 years ago

Support for kubectl will make Kubernetes cluster operations easier. O&M engineers need this feature very much.

holzschu commented 5 years ago

Hi, I'll see what I can do. After a quick research, I was unable to find the source code for this command, only precompiled binaries.

holzschu commented 5 years ago

For my own future reference: https://github.com/kubernetes/kubectl

yisiqi commented 5 years ago

yes, that is the official source repo. And it's a golang program.

For my own future reference: https://github.com/kubernetes/kubectl

yisiqi commented 4 years ago

I tried compiling a simple hello world with go build. Everything goes well. But when I download the executable file into the blink shell, It's not working, caused by command not found.

Here is the screenshot: image

holzschu commented 4 years ago

Hi, I have many questions here.

yisiqi commented 4 years ago

I used the following command to compile my test program.

CC=/usr/local/go/misc/ios/clangwrap.sh GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build

Then use ldid to sign the binary. I'm not sure if that works.

Your question has brought me some tips. But I don't know how to link the binary with ios_system.framework.

holzschu commented 4 years ago

ldid works for signing, but for iOS to accept a binary it has be both signed and placed in the right location. The only way to access this location is at install time, so you will have to compile your own version of Blink (It's free as long as you accept recompiling every 7 days).

To have your command recognized by iOS, you need to add the binary to the list of embedded binaries in the XCode project, and to commandDictionary.plist. Once you've done that, you should be able to start your command. The output might be on the XCode console.

The big difficulty is making sure your command runs multiple times: often, memory de-allocation is not treated as the command exits (because when a command exits, it releases all of its memory). This is not true with iOS, and so you need to reset all variables and release all memory on exit.