Jump to content
Tuts 4 You

Iphone IOS hello world


JMC31337

Recommended Posts

JMC31337

IOS 14.2 (using 13.3. SDK)

having ran around for a few hours trying to figure out how to write some code on the iPhone I decided to quickly sum up a few snafus I ran into on various message boards

Yes theos works and if you follow the theos install tutorial on their dev site there shouldn't be problems with theos except your Makefile should contain

if using the below referenced private iOS 13 SDK (I had unzipped the SDK-master into theos sdks folder then unzipped the iPhone13.3.sdk) so the below sysroot line is different than what you may decide to do

ARCH = arm64
SDKVERSION = 13.3
SYSROOT = /var/opt/theos/sdks/iOS13-Private-SDK-master/sdks/iPhoneOS13.3.sdk
TARGET := iphone:clang:latest:13.3:13.3

The cydia repo for clang (llvm64) can be found on BigBoss's repo (apt search llvm) designed by coolstar

Once you have the iostoolchains and the llvm make ldid etc etc from coolstar installed you're ready

The sdk for iOS 13.3 I used can be found at https://github.com/SniperGER/iOS13-Private-SDK

--Note the git holder of that states in his README to copy various files into theos include directory (we don't need to do this for on device compiling some -libc code)

Once you have that sdk in a folder and the toolchains and llvm compiler installed on your iPhone (I chose /var/opt for the ios13-private sdk) you're ready

create a tiny hello world test.c file and build it with the following params:

"clang++ -isysroot/var/opt/theos/sdks/iOS13-Private-SDK-master/sdks/iPhoneOS13.3.sdk test.c -o test"

NOTE!! You're gonna run into several errors about tons of TBD files in that sdk... the trick there is to edit the particular framework tbd file and remove all the "arm64e" out of the tbd files that the compiler errors show you (yes there are a lot) and I used nano and removed the "arm64e" references by hand

After that's done, compile again and you'll have a c coded binary called test

NOTE!!! the problem I saw on various IOS boards was "Killed: 9" when trying to run the binary file 

the proper entitlements plist:

 

ent.plist

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>platform-application</key>
    <true/>
    <key>com.apple.private.security.container-required</key>
    <false/>
</dict>
</plist>

sign the test binary with: 

ldid -Sent.plist test

the below code tags show output on my iPhone (its noted I bypassed activation on the device and use it without problems with Sliver Bypass Tool by AppleTech752) nonetheless my uname info and print out of the test.c source code

iphone:/var/opt/theos/sdks/iOS13-Private-SDK-master/sdks/iPhoneOS13.3.sdk root# uname -a
Darwin iphone 20.2.0 Darwin Kernel Version 20.2.0: Fri Nov 13 01:00:11 PST 2020; root:xnu-7195.62.1~4/RELEASE_ARM64_S8000 iPhone8,1 arm64 N71AP Darwin
iphone:/var/opt/theos/sdks/iOS13-Private-SDK-master/sdks/iPhoneOS13.3.sdk root#
iphone:/var/opt/theos/sdks/iOS13-Private-SDK-master/sdks/iPhoneOS13.3.sdk root# cat test.c
#include <stdio.h>
int main()
{
printf("\n\nHelloworld!\n\n");

return 0;
}
iphone:/var/opt/theos/sdks/iOS13-Private-SDK-master/sdks/iPhoneOS13.3.sdk root#

 

and after ldid signing and running the file we'll see

iphone:/var/opt/theos/sdks/iOS13-Private-SDK-master/sdks/iPhoneOS13.3.sdk root# ./test


Helloworld!

iphone:/var/opt/theos/sdks/iOS13-Private-SDK-master/sdks/iPhoneOS13.3.sdk root#

sure I could have step by step showed ya how to get here, but if you're jailbreaking theos'ng command line compiling you'll know how to get to the points where I NOTED several people having issues

 

Edited by JMC31337 (see edit history)
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...