Yep, that’s right. Now let’s clear up some questions. (By the way, I’m doing all this from Windows 7 RC). There are several other tutorials that show how to do this, but most of them were quickly written with little or no explanation. I try it explain things a little bit more here, if you have any more questions you can comment at the bottom. I suggest you read through this post (and probably the comments too) before you actually start so you know what’s ahead of you.
Do you need to be apart of the Apple Developers program?
Nope.
Do you need to pay $100 to Apple to run YOUR app on YOUR phone?
Nope.
Do you have to have a mac?
Nope.
What about hackintosh?
Nope.
Does this cost money?
Nope.
Do you have to jailbreak your iphone?
Yep.
What do I have to know to do this?
Some basic unix commands, how to ssh, how to ctrl-c ctrl-v (copy/paste), maybe some basic objective C knowledge (you can learn as you go, that’s what I’m doing), how to use google.
What do I need to do this?
An ipod touch/iphone, (jailbroken, this guide is for iphone OS 3), a wireless AP, a computer on the same network as your iphone. (actually not required, I think you could do this whole thing without a computer except the jailbreaking part).
Here’s the general idea:
1. Jailbreak iphone.
2. Install open toolchain, get headers, get various Cydia packages
3. SSH into your iphone, code an app, compile and install the app, test it!
4. There is no step 4, it’s that easy.
5. This is the 5th and final step. On this step you learn Objective C, the iphone APIs, how to code, whatever. (Just make apps!).
Ok, so what’s the catch?
There is no catch!
Ok, well maybe some minor drawbacks, but nothing too big. You can’t use .nib or .xib files created by interface builder on a mac, because the open toolchain can’t use/compile them. This is no big deal, really. It just requires a bit more coding, and some people that develop with the Apple SDK do this anyway. You’ll be fine.
The other “catch” is that you can’t submit apps to the app store. But, you can to a Cydia repo!
Ok, lets get started. But first, so we don’t have a holdup waiting for the super huge download later, go a head and download the latest Apple SDK. We will extract the headers out of this. (Or, you can find them on the internet somewhere – it is technically illegal to host them, but you can download them from Apple legally. This is what I did.)
1. Jailbreak your iphone.
Sorry, I’m not going to tell you how to do this, it’s on the internet. Use google. I assume you’ve already done this.
2. Install stuff from Cydia
Here we start getting to the good stuff. You may be wondering, “How the heck is this going to work!?” and the answer is simple: hackers!!
<rant>
That is, hackers in the intended use of the word (see this). Not the people that go around and “hack” into your computer and steal passwords. These people have extended the functionality of the iPhone, and are willing to share it with you for free.
Why? Because that’s the way the iphone should be. Your iPhone is a full blown computer, and it can and should be used that way. You should be able to get to the command line. You should be able to write your own apps. You should be able to customize the way your computer phone looks. You should be able to ssh into your phone. You should be able to write a better Stocks app, a better email app, a better SMS app, a better tethering app, a better camera app, a video camera app (period), a better browser app, a better maps app, a better settings app, and even YOUR OWN app, for free. If there’s an app, you should be able to make it, and make it better. And, for free. After all, it’s your phone. It’s not Apple’s phone, it’s not AT&T’s phone, it’s your own darn phone. Do what you want with it.
</rant>
(edit) Thanks to “ziffer” for reminding me that another package needs to be installed before the full iPhone 2.0 toolchain can be installed. It is called “fake-libgcc”, as an “official” libgcc package has not been released for 3.0, but the toolchain can still be installed on the iphone anyway. (I found this here: http://modmyi.com/forums/iphone-ipod-touch-sdk-development-discussion/655111-compiling-iphone-3-0-a.html#post4898409)
I have uploaded a mirror of the package on my site, just in case the original creator moves/removes the package from his dropbox. You can install this package by running the following commands (on the iphone, either ssh into it or use the mobile terminal, you must be logged in as root):
wget http://aaronash.com/iphone/fake-libgcc_1.0_iphoneos-arm.deb
dpkg -i fake-libgcc_1.0_iphoneos-arm.deb
If you type the first command in and it says “command not found”, then you don’t have wget installed. Search for it on Cydia. So anyway after you have installed “fake-libgcc”, open up Cydia and download the following packages:
- iPhone 2.0 Toolchain – This is the important one!!
- MobileTerminal (if you haven’t already)
- OpenSSH
Those 3 packages alone should get you going. After you install the iPhone 2.0 Toolchain package, there will be many more packages installed because the open toolchain depends on them. The Mobile Terminal is not technically needed, but it can be quite useful.
Here are some packages that are handy for development, though not necessarily required:
- Vi IMproved
- nano
- wget
- adv-cmds
- shell-cmds
- top
- Tape Archive
You should now be able to compile a basic C program, so lets check it out and make sure! (This is a fun part, but not required).
- SSH into your iphone. If you’re on Windows I recommend PuTTy. This is most easily done by going on the same WiFi network as your iphone and find it’s IP address by typing ifconfig in the Mobile Terminal (if you have that package installed) or by simply loading up SBSettings (if you don’t have it installed, I would HIGHLY recommend it, open it by sliding your finger accross the little bar on top) and looking at the WiFi ip address you see there. Also, you can find it by going to Settings > WiFi > YourSSIDName (tap the blue arrow) and that screen will show it. The first ssh might take a bit because the iphone is generating some crypto keys and it’s a tad bit on the slow side. Login as root, the default password is ‘alpine’. Change it using the passwd command.
- After you’ve ssh’d into it, type these commands:
echo ‘int main(int argc, char *argv[]) { printf(“Hello, iPhone!\n”); return 0; }’ > test.c
gcc test.c -o test
ldid -S test
./testAfter you run the “gcc test.c -o test” test part it may say something like:
test.c: In function ‘main’:
test.c:2: warning: incompatible implicit declaration of built-in function ‘printf’But this is ok, it still works for some reason. (It should, it does on mine).”
After you run ./test it should print out “Hello, iPhone!”. Congrats! This is exactly what we want. You just compiled a C program ON your iPhone. Now THAT is cool stuff.(If you had some weird problem, it may have been because you copied and pasted it. If it doesn’t work type it up by hand into the terminal and you shouldn’t have any problems).
- That’s it! You have gcc working on your iphone. Now you’re ready for a native Objective C app, or code in normal C.
Since we’re still technically on step two “Install open toolchain, get headers, get various Cydia packages” we might as well go ahead and grab the headers. This part isn’t so much fun, unless you find somewhere that they’ve already been ripped and uploaded (hint hint). Otherwise, go download the Official Apple SDK (it’s like, 2GB), and save it somewhere. Also install 7-zip. Then open it with 7-zip and keep clicking until you find where they are, check out this post if you’re going to do this manually. (Also, you can check out this).
3. SSH into your iphone, code an app, compile and install the app (this is done on the phone itself), test it!
- SSH into your phone. Also, for easy file transfer, you probably want to use something like WinSCP. It’s a great program, I’d recommend using it.
- Download our Hello World program code, here: http://aaronash.com/iphone/HelloWorld.zip
- Unzip it, (you can use 7-zip) and then drag/drop it to your iphone. I keep all my code in /var/root/Code, it’s a good place to keep everything.
- In your SSH session (or even on the mobile terminal) cd into the directory you copied the code to. “cd /var/root/Code”
- Type “make”.
- Type “make install”.
- Wait for Springboard to reboot.
- Test the app!
If it works, great! You just compiled an app on your iphone, for free. How dare you.
4. There is no step 4, it’s that easy.
Actually there is a step 4, and that is to remember everything you did, backup your work, tell someone else how to do it, and take a break.
5. This is the 5th and final step. On this step you learn Objective C, the iphone APIs, how to code, whatever. (Just make apps!).
Self explanatory, I hope you’ve made it this far and you can start coding for your iPhone. If you have any problems, just use google or post here. Good luck!
–Update: June 11 2010–
I’ve been working on getting 4.0 stuff ready with rpetrich, and I found that he has written a script that will install the SDK to the iPhone from your mac (or maybe your linux/windows computer if you set it up right). Here’s a link to it: http://rpetri.ch/toolchain
This may help out some of you guys that have been having trouble. I just installed it on my jailbroken 4.0 GM (beta 5) iPhone 3G without any problems. This is also completely legal because it doesn’t distribute headers.
Also, I often hang around in IRC on irc.saurik.com in the #iphone channel. My nick is “Charybdis”. If you want to contact me, there is probably the best place. I can’t walk you through setting up the toolchain (as that’s described here), but if you have just a few questions I might answer them.
Comments (57)
Ugh, I liked! So clear and positively.
Joker
hi, when I try to install iPhone 2.0 Toolchain from Cydia , it prompts:
>>Note: The requested modifications cannot be applied due to required
>>dependencies or conflicts that cannot be automatically found or fixed.
I chose ‘development’ when Cydia asked for the first time running.
Ah, I’m sorry, I knew I was missing something.
Libgcc has not been “officially” released for 3.0, however, there is a “fake” libgcc that gets the job done.
You can download it here: http://aaronash.com/iphone/fake-libgcc_1.0_iphoneos-arm.deb
If you want to get and install this from the terminal, you can do the following commands (assuming you have wget installed):
wget http://aaronash.com/iphone/fake-libgcc_1.0_iphoneos-arm.deb
dpkg -i fake-libgcc_1.0_iphoneos-arm.deb
I originally found this fake-libgcc package here: http://modmyi.com/forums/iphone-ipod-touch-sdk-development-discussion/655111-compiling-iphone-3-0-a.html#post4898409
The post has been modified accordingly. Thanks ziffer!
Thank you, it works!
When I try to compile my test program, it says this :
ld: library not found for -lgcc_s.10.5
collect2: ld returned 1 exit status
in addition to the error messages you mentioned (because of printf).
Therefore it just won’t compile.
Do you have an idea why I would get such a behaviour ?
Thanks
It looks like your libgcc was not installed or not installed properly. What OS version are you running? I’m running 3.0.1 and the package worked fine for me, I have not tested this on 3.1.2. Make sure you installed the fakelibgcc again, and if that doesn’t work I believe the “normal” libgcc is still available. (Just wget it). Cydia won’t allow you to install it however because it’s not totally compatible, so I would do research on that before you actually install it. If you find out anything useful, let us know.
Fake libgcc only allows installation of the toolchain, it doesn’t actually contain anything.
So I found and installed libgcc_4.2-20080410-1-6_iphoneos-arm.deb
This fixed:
ld: library not found for -lgcc_s.10.5
because it actually got installed in libgcc, but now I’m getting:
ld: library not found for -lSystem
Any ideas?
(OS 3.1.2)
Hmm, not sure. I installed fake libgcc then just installed the iphone 2.0 toolchain. I didn’t separately manually install a libgcc, in fact I just searched in Cydia and I never installed a libgcc except for the fake one. Perhaps only try the fake libgcc? If you get it working, let us know!
I got test.c compiled and running. In addition to libgcc, I also had to get a copy of libSystem.dylib and put it in /usr/lib.
I got it from:
http://aakash-bapna.blogspot.com/2007/10/iphone-non-official-sdk-aka-toolchain.html
about 4/5ths the way down.
http://rapidshare.com/files/66800884/lib.rar (14.2mb)
Password is aksblog.co.nr
The rar is actually a copy of the /usr/lib from a much earlier version of iPhoneOS.
I just checked, its not on my 3GS 3.1.2, but it *is* on my 3G 3.0 and haven’t installed any packages at all regarding compilers and gcc.
Lack of other files might explain why the other UIKit version isn’t compiling, I get a whole bunch of errors, beginning with
In file included from Classes/HelloWorldAppDelegate.m:1:
Classes/HelloWorldAppDelegate.h:5: error: cannot find protocol declaration for ‘UIApplicationDelegate’
Actually, no… same bunch of errors compiling on my 3G
Are you sure you got all of the headers in the correct place?
I was recently searching for Mobile Substrate extension info and stumbled across this handy page: http://iphonesdkdev.blogspot.com/2009/10/how-to-compile-mobilesubstrate.html
At the end of the third step there’s a link to a .tgz that has all of the “downloading/classdump/patching in one zipped tar file” and it’s quite handy. I’d recommend reading that post, that’s actually how I’m running my current setup (as of recently). Just don’t forget to fix your include folder in the HelloWorld example I posted, if you end up trying this method. (Javacom walks you through compiling backgrounder too).
Thanks a lot, will have a read now…
I was actually trying to do all this to modify an existing application (ScreenSplitr) but now I realise I need to compile via the SDK for this… So I’ve decided to get a VMWare hackintosh image of 10.5.7 and compile off that. Sigh.
Actually, I’m only getting errors. Think my fake-libgcc is getting wrong paths. Here are the list :
—:/var/mobile/src/HelloWorld root# make
arm-apple-darwin9-gcc -c -I”/var/include” -I”/usr/include” -F”/System/Library/Frameworks” -F”/System/Library/PrivateFrameworks” -DDEBUG -Wall -std=c99 -DMAC_OS_X_VERSION_MAX_ALLOWED=1050 Classes/HelloWorldAppDelegate.m -o Classes/HelloWorldAppDelegate.o
In file included from Classes/HelloWorldAppDelegate.m:1:
Classes/HelloWorldAppDelegate.h:1:24: error: UIKit/UIKit.h: No such file or directory
In file included from Classes/HelloWorldAppDelegate.m:1:
Classes/HelloWorldAppDelegate.h:5: error: cannot find interface declaration for ‘NSObject’, superclass of ‘HelloWorldAppDelegate’
Classes/HelloWorldAppDelegate.h:5: error: cannot find protocol declaration for ‘UIApplicationDelegate’
Classes/HelloWorldAppDelegate.h:6: error: expected specifier-qualifier-list before ‘UIWindow’
(…) Edited for length (…)
make: *** [Classes/HelloWorldAppDelegate.o] Error 1
Cowcow:/var/mobile/src/HelloWorld root# pwd
/var/mobile/src/HelloWorld
Cowcow:/var/mobile/src/HelloWorld root# make
arm-apple-darwin9-gcc -c -I”/var/include” -I”/usr/include” -F”/System/Library/Frameworks” -F”/System/Library/PrivateFrameworks” -DDEBUG -Wall -std=c99 -DMAC_OS_X_VERSION_MAX_ALLOWED=1050 Classes/HelloWorldAppDelegate.m -o Classes/HelloWorldAppDelegate.o
In file included from Classes/HelloWorldAppDelegate.m:1:
Classes/HelloWorldAppDelegate.h:1:24: error: UIKit/UIKit.h: No such file or directory
In file included from Classes/HelloWorldAppDelegate.m:1:
Classes/HelloWorldAppDelegate.h:5: error: cannot find interface declaration for ‘NSObject’, superclass of ‘HelloWorldAppDelegate’
Classes/HelloWorldAppDelegate.h:5: error: cannot find protocol declaration for ‘UIApplicationDelegate’
Classes/HelloWorldAppDelegate.h:6: error: expected specifier-qualifier-list before ‘UIWindow’
(…) Edited for length (…)
Classes/HelloWorldAppDelegate.m:28: error: ‘window’ undeclared (first use in this function)
Classes/HelloWorldAppDelegate.m:29: error: no super class declared in @interface for ‘HelloWorldAppDelegate’
make: *** [Classes/HelloWorldAppDelegate.o] Error 1
I’m Swiss, so excuse my english. Excuse my keyboard too, that doesn’t allow me to write “´” in Putty.
Any help ?
Cowcow: It looks like you have not grabbed the header files (.h). (error: UIKit/UIKit.h: No such file or directory).
I cannot post these because it’s illegal to, however it is legal to rip them from Apple’s SDK. They have been ripped and posted separately before however, and it’s much easier to just download them from someone that has extracted the headers for you. Search the internet for something like “iphone sdk headers” and you may be able to find a link.
I was having the same “ld: library not found for -lgcc_s.10.5″ error, and installed libgcc_4.2-20080410-1-6_iphoneos-arm.deb as the original Daniel advised. It fixed the error, but introduced another: “ld: library not found for -lSystem”. (as it did with Daniel) I copied lib.rar into the /usr/lib directory. The error still persists. I have an iTouch 3rd gen with firmware 3.1.2, using blackra1n. As a side note, everytime my itouch restarts (not respring, but actually turn off then on) it needs to be re-jailbroken by blackrain.(it shows the usb plug and an arrow to iTunes) This makes updating certain programs on Cydia tricky.
Thanks in advance!
You copied lib.rar, but did you unrar it? If you didn’t, then the files are still compressed and probably won’t be accessible. Try to unrar it in that directory, or unrar before you copy it over to the iphone.
The tethered jailbreak hopefully shouldn’t have an effect on this, but I suppose there’s a chance that it might.
Sorry, I am learning, and did not realize that I needed to unrar the rar file. I have not tested it yet, but I am confident that it will work. There is one problem though: Every time I unrar lib.rar (twice now) my itouch freezes up. After I unrar the last file, ssh is unresponsive. The only way I can get it to respond, it to restore it with iTunes. I think that it is freezing because of the low amount of space on the system partition. Is there any way to get around this? Also, would it fix the problem if I tell unrar not to replace any files, or do I need it to replace files to install the correct files?
By the way, thanks for the speedy response, admin! You answered 28 minutes after my post!
Thanks!
New package of errors :
:/var/mobile/src/HelloWorld root# make
arm-apple-darwin9-gcc -c -I”/var/include” -I”/usr/include” -F”/System/Library/Frameworks” -F”/System/Library/PrivateFrameworks” -DDEBUG -Wall -std=c99 -DMAC_OS_X_VERSION_MAX_ALLOWED=1050 Classes/HelloWorldAppDelegate.m -o Classes/HelloWorldAppDelegate.o
In file included from Classes/HelloWorldAppDelegate.m:1:
Classes/HelloWorldAppDelegate.h:5: error: cannot find protocol declaration for ‘UIApplicationDelegate’
In file included from Classes/HelloWorldAppDelegate.m:2:
Classes/MyViewController.h:3: error: cannot find interface declaration for ‘UIViewController’, superclass of ‘MyViewController’
Classes/HelloWorldAppDelegate.m: In function ‘-[HelloWorldAppDelegate applicationDidFinishLaunching:]‘:
Classes/HelloWorldAppDelegate.m:10: error: ‘UIScreen’ undeclared (first use in this function)
Classes/HelloWorldAppDelegate.m:10: error: (Each undeclared identifier is reported only once
Classes/HelloWorldAppDelegate.m:10: error: for each function it appears in.)
Classes/HelloWorldAppDelegate.m:13: warning: ‘MyViewController’ may not respond to ‘+alloc’
Classes/HelloWorldAppDelegate.m:13: warning: (Messages without a matching method signature
Classes/HelloWorldAppDelegate.m:13: warning: will be assumed to return ‘id’ and accept
Classes/HelloWorldAppDelegate.m:13: warning: ‘…’ as arguments.)
Classes/HelloWorldAppDelegate.m:15: warning: ‘MyViewController’ may not respond to ‘-release’
Classes/HelloWorldAppDelegate.m:17: warning: ‘UIApplication’ may not respond to ‘+sharedApplication’
Classes/HelloWorldAppDelegate.m:17: error: ‘UIStatusBarStyleBlackOpaque’ undeclared (first use in this function)
Classes/HelloWorldAppDelegate.m:17: warning: no ‘-setStatusBarStyle:’ method found
Classes/HelloWorldAppDelegate.m:20: warning: ‘MyViewController’ may not respond to ‘-view’
Classes/HelloWorldAppDelegate.m: In function ‘-[HelloWorldAppDelegate dealloc]‘:
Classes/HelloWorldAppDelegate.m:27: warning: ‘MyViewController’ may not respond to ‘-release’
make: *** [Classes/HelloWorldAppDelegate.o] Error 1
I put the headers in /var/include. Right ?
“good post”
Article very interesting, I will necessarily add it in the selected works and I will visit this site
I got the “Hello, iPhone!” program to work, but was unsuccessful in MAKEing the HelloWorld example. I get the error:
ld: framework not found CoreFoundation
I looked inside the Makefile, and commented out the line which included CoreFoundation. When I ran make again, it could not find Foundation, the framework on the next line of the Makefile. Does anybody know where I could find, or reinstall the frameworks?
I got this working on my 3GS 3.1.2… (I was getting the same errors as Daniel)
(I fixed this error: ld: library not found for -lgcc_s.10.5 )
The solution I used was to go and download this (mentioned earlier)
http://rapidshare.com/files/66800884/lib.rar (14.2mb)
Password is aksblog.co.nr
Then extract it locally, scp the following files to /usr/lib
libgcc_s.1
libSystem.dylib
libSystem.B.dylib
then try it again, this time GCC ran fine!
Thank u for this tutorial…
I’m in stuck…
I got HelloWorld application compiled, but got error on the link stage…
ld: framework not found CoreFoundation
My /System/Library/Frameworks/CoreFoundation.framework folder contains following files:
Info.plist en.lproj tokruleLE.data
Please help… What’s wrong ? What can I do ?
Yep! It’s Working!!!
Alexander, how did you solve the framework missing problem?
As I have the same problem.. (according to what I read, since 3.1 frameworks are not deployed in iPhone as they are with SDK…)
Does anyone compile succesfully apps with the iphone sdk with this method?
Thanks for your post.
I’ve followed your guide, step by step, even manually extract headers from SDK. But I’m still stuck with this:
ld: library not found for -lobjc
collect2: ld returned 1 exit status
make: *** [HelloWorld] Error 1
Please help. Thanks
Finally, It worked.
@Filippe You have to overwrite all files in /System/Library/Frameworks and /System/Library/PrivateFrameworks with new ones in the SDK.
You can find it here http://dl.dropbox.com/u/1666541/sys30.tgz
@Daniel – having all the same issues you described, I’m trying to compile a basic hello world program on my iphone and there are files missing
I’m following the standard instructions seen on a couple of how-to’s including this one (most of which i’m finding are a year or more old and were meant for iphone OS 2.x, I’m running jailbroken 3.1)
after installing the gcc, iphone 2.0 toolchain, fake-libgcc I tried a basic main.c that printf’s a hello world and get this error:
main.c: In function ‘main’:
main.c:1: warning: incompatible implicit declaration of built-in function ‘printf’
ld: library not found for -lSystem
collect2: ld returned 1 exit status
I found that /usr/lib/ was missing libSystem.dylib and libobjc.dylib
I downloaded an old version of those from the link above, put them in my /usr/lib and
iPhone:~/src root# gcc main.c -o main
main.c: In function ‘main’:
main.c:1: warning: incompatible implicit declaration of built-in function ‘printf’
iPhone:~/src root# ./main
Killed
does anyone here have experience with replacing the .dylib files in /usr/lib with the files from the apple’s 3.1 SDK?
should I be looking for a 2.x SDK?
You need to fake sign the binary so it will run. Try running “ldid -S main”, make sure the ldid package is installed.
great that worked
ok i’ve been able to compile a simple printf(“hello world”) app, but i’m having the same error as cowcow when compiling the HelloWorld app posted above
I’ve copied the Frameworks and PrivateFrameworks from the iPhoneOS3.1.2 sdk into /System/Library ..
copied the sdk headers into /user/include/ ..
copied the sdk libSystem.B.dylib (ln -s to libSystem.dylib) in /usr/lib
I’m using OS 3.1 on iphone 3G, followed all instructions above ..
iPhone:/var/mobile/src/HelloWorld/HelloWorld root# make
arm-apple-darwin9-gcc -c -I”/var/include” -I”/usr/include” -F”/System/Library/Frameworks” -F”/System/Library/PrivateFrameworks” -DDEBUG -Wall -std=c99 -DMAC_OS_X_VERSION_MAX_ALLOWED=1050 Classes/HelloWorldAppDelegate.m -o Classes/HelloWorldAppDelegate.o
In file included from Classes/HelloWorldAppDelegate.m:1:
Classes/HelloWorldAppDelegate.h:5: error: cannot find protocol declaration for ‘UIApplicationDelegate’
In file included from Classes/HelloWorldAppDelegate.m:2:
Classes/MyViewController.h:3: error: cannot find interface declaration for ‘UIViewController’, superclass of ‘MyViewController’
Classes/HelloWorldAppDelegate.m: In function ‘-[HelloWorldAppDelegate applicationDidFinishLaunching:]‘:
Classes/HelloWorldAppDelegate.m:10: error: ‘UIScreen’ undeclared (first use in this function)
Classes/HelloWorldAppDelegate.m:10: error: (Each undeclared identifier is reported only once
Classes/HelloWorldAppDelegate.m:10: error: for each function it appears in.)
Classes/HelloWorldAppDelegate.m:13: warning: ‘MyViewController’ may not respond to ‘+alloc’
Classes/HelloWorldAppDelegate.m:13: warning: (Messages without a matching method signature
Classes/HelloWorldAppDelegate.m:13: warning: will be assumed to return ‘id’ and accept
Classes/HelloWorldAppDelegate.m:13: warning: ‘…’ as arguments.)
Classes/HelloWorldAppDelegate.m:15: warning: ‘MyViewController’ may not respond to ‘-release’
Classes/HelloWorldAppDelegate.m:17: warning: ‘UIApplication’ may not respond to ‘+sharedApplication’
Classes/HelloWorldAppDelegate.m:17: error: ‘UIStatusBarStyleBlackOpaque’ undeclared (first use in this function)
Classes/HelloWorldAppDelegate.m:17: warning: no ‘-setStatusBarStyle:’ method found
Classes/HelloWorldAppDelegate.m:20: warning: ‘MyViewController’ may not respond to ‘-view’
Classes/HelloWorldAppDelegate.m: In function ‘-[HelloWorldAppDelegate dealloc]‘:
Classes/HelloWorldAppDelegate.m:27: warning: ‘MyViewController’ may not respond to ‘-release’
make: *** [Classes/HelloWorldAppDelegate.o] Error 1
any suggestions?
@Daniel P. Long
when i did this i did a respring and my iphone crashed and i had to restore. (OS 3.1.2) Did you respring?
@doug
i’ve the same problem,
and resolved by change the makefile ,
just comment the line:
CFLAGS = -I”/var/include”
to
//CFLAGS = -I”/var/include”
I finally got this to work as well. I’m running 3.1 on a 3gs.
However, in order to get c++ to work I had to install a few more of the dylibs. I installed both of the c++ dylib files on a hunch and then it gave me a new error, but luckily thanks to Daniel’s collection of files I had libgcc_s_v6.1.dylib that it was asking for and then my hello world compiled and ran.
Thanks for solving my headache.
Hi, thanks for this great tuto.
I can now compile a simple .c file, but i’m stuck with the Helloworld file when trying to make it. I had first the error
“ld: library not found for -lobjc
collect2: ld returned 1 exit status
make: *** [HelloWorld] Error 1″
that i solved by looking for lobjc.dylib files in the lib.rar file given by daniel, and copying it in usr/lib (where they were not)
But now i have the error:
“ld: framework not found CoreFoundation”
even though i have already replaced all files in the system/library/Frameworks and system/library/PrivateFrameworks with new ones, as told here.
Does anyone know if the specific CoreFoundation folder has to be replaced (again) and where to find a good one (I have an ipod Touch 2G (false 3G) 3.1.2
Thank you again for your help so far !
(please note that all of the posts by “Daniel (different one)” are all by the same person, me)
By the way, thanks for an amazing tutorial. The comments are also very helpful.
I have successfully compiled and run the test.c program, but I am having errors with the Hello World program. I am getting something similar to doug’s second batch of errors, but commenting out CFLAGS = -I”/var/include” did not help.
Here are my errors:
arm-apple-darwin9-gcc -c -F”/System/Library/Frameworks” -F”/System/Library/PrivateFrameworks” -DDEBUG -Wall -std=c99 -DMAC_OS_X_VERSION_MAX_ALLOWED=1050 Classes/HelloWorldAppDelegate.m -o Classes/HelloWorldAppDelegate.o
In file included from Classes/HelloWorldAppDelegate.m:1:
Classes/HelloWorldAppDelegate.h:5: error: cannot find protocol declaration for ‘UIApplicationDelegate’
In file included from Classes/HelloWorldAppDelegate.m:2:
Classes/MyViewController.h:3: error: cannot find interface declaration for ‘UIViewController’, superclass of ‘MyViewController’
Classes/HelloWorldAppDelegate.m: In function ‘-[HelloWorldAppDelegate applicationDidFinishLaunching:]‘:
Classes/HelloWorldAppDelegate.m:10: error: ‘UIScreen’ undeclared (first use in this function)
Classes/HelloWorldAppDelegate.m:10: error: (Each undeclared identifier is reported only once
Classes/HelloWorldAppDelegate.m:10: error: for each function it appears in.)
Classes/HelloWorldAppDelegate.m:13: warning: ‘MyViewController’ may not respond to ‘+alloc’
Classes/HelloWorldAppDelegate.m:13: warning: (Messages without a matching method signature
Classes/HelloWorldAppDelegate.m:13: warning: will be assumed to return ‘id’ and accept
Classes/HelloWorldAppDelegate.m:13: warning: ‘…’ as arguments.)
Classes/HelloWorldAppDelegate.m:15: warning: ‘MyViewController’ may not respond to ‘-release’
Classes/HelloWorldAppDelegate.m:17: warning: ‘UIApplication’ may not respond to ‘+sharedApplication’
Classes/HelloWorldAppDelegate.m:17: error: ‘UIStatusBarStyleBlackOpaque’ undeclared (first use in this function)
Classes/HelloWorldAppDelegate.m:17: warning: no ‘-setStatusBarStyle:’ method found
Classes/HelloWorldAppDelegate.m:20: warning: ‘MyViewController’ may not respond to ‘-view’
Classes/HelloWorldAppDelegate.m: In function ‘-[HelloWorldAppDelegate dealloc]‘:
Classes/HelloWorldAppDelegate.m:27: warning: ‘MyViewController’ may not respond to ‘-release’
make: *** [Classes/HelloWorldAppDelegate.o] Error 1
I was trying to overwrite the files in /System/Library/Frameworks and /System/Library/PrivateFrameworks as Daniel P. Long suggested, but my 500M System partition was running low on space. Last time, when I copied all the files, my ipod froze, and I had to restore it with itunes.
Is there a way I can fix the errors without copying the frameworks Daniel P. Long linked to, or can I make the System partition bigger, or remove some unnecessary files or something?
Thanks everyone!
I added the header files, (found an include.tar from my last attempt at this tutorial) any now the aren’t as many errors:
arm-apple-darwin9-gcc -arch arm -lobjc -framework CoreFoundation -framework Foundation -framework UIKit -framework QuartzCore -framework CoreGraphics -framework GraphicsServices -framework CoreSurface -L”/usr/lib” -F”/System/Library/Frameworks” -F”/System/Library/PrivateFrameworks” -bind_at_load -multiply_defined suppress -o HelloWorld Classes/HelloWorldAppDelegate.o Classes/MyView.o Classes/MyViewController.o Classes/main.o
ld: library not found for -lobjc
collect2: ld returned 1 exit status
make: *** [HelloWorld] Error 1
I was still unable to replace the /System/library/Frameworks and /System/Library/PrivateFrameworks due to lack of space on the system partition. Is this the source of the problem?
Daniel:
If you put the sys30 folder somewhere like /var/toolchain/sys30, then it will be on the user partition instead of the system partition. The iPhone is partitioned so that anything in /var is in the user partition, and anything at / is in the system partition.
Someone a few posts up stated that they were missing libobjc (-lobjc not found), you can find this (I believe?) in the iPhone SDK from Apple, or from a friend’s older iDevice, if I recall correctly libobjc.dylib came with my iPhone 3G and ipt2g by default, but not in my 3GS.
Also, @Daniel different one, your error looks like it isn’t getting access to some important header files. Make sure the directory where your headers are located is included in your makefile.
Thanks very much admin! The HelloWorld app is now working!!! (OMG AWESOME!!!) I will now start writing apps.
Very nice and interesting article. Actually, I had been planning to develop an app but I absolutely don’t want to spend for a $2000 mac plus an extra $100 to develop a small little app. And this site is actually what I was looking for. I will surely try this out with my jailbroken iphone 3G and post back here.
Thank you very much!!!
I’m running into the same problem as the Daniel was earlier. I did a fresh restore and jail break, installed per the instructions on this site and used the sys30.tgz listed above. Copied the headers and libs to the proper place along with the framework and when i run the make for HelloWorld I get the following;
Matts-iPhone:~/code/HelloWorld root# make
arm-apple-darwin9-gcc -c -I”/var/include” -I”/usr/include” -F”/System/Library/Frameworks” -F”/System/Library/PrivateFrameworks” -DDEBUG -Wall -std=c99 -DMAC_OS_X_VERSION_MAX_ALLOWED=1050 Classes/HelloWorldAppDelegate.m -o Classes/HelloWorldAppDelegate.o
In file included from Classes/HelloWorldAppDelegate.m:1:
Classes/HelloWorldAppDelegate.h:5: error: cannot find protocol declaration for ‘UIApplicationDelegate’
In file included from Classes/HelloWorldAppDelegate.m:2:
Classes/MyViewController.h:3: error: cannot find interface declaration for ‘UIViewController’, superclass of ‘MyViewController’
Classes/HelloWorldAppDelegate.m: In function ‘-[HelloWorldAppDelegate applicationDidFinishLaunching:]‘:
Classes/HelloWorldAppDelegate.m:10: error: ‘UIScreen’ undeclared (first use in this function)
Classes/HelloWorldAppDelegate.m:10: error: (Each undeclared identifier is reported only once
Classes/HelloWorldAppDelegate.m:10: error: for each function it appears in.)
Classes/HelloWorldAppDelegate.m:13: warning: ‘MyViewController’ may not respond to ‘+alloc’
Classes/HelloWorldAppDelegate.m:13: warning: (Messages without a matching method signature
Classes/HelloWorldAppDelegate.m:13: warning: will be assumed to return ‘id’ and accept
Classes/HelloWorldAppDelegate.m:13: warning: ‘…’ as arguments.)
Classes/HelloWorldAppDelegate.m:15: warning: ‘MyViewController’ may not respond to ‘-release’
Classes/HelloWorldAppDelegate.m:17: warning: ‘UIApplication’ may not respond to ‘+sharedApplication’
Classes/HelloWorldAppDelegate.m:17: error: ‘UIStatusBarStyleBlackOpaque’ undeclared (first use in this function)
Classes/HelloWorldAppDelegate.m:17: warning: no ‘-setStatusBarStyle:’ method found
Classes/HelloWorldAppDelegate.m:20: warning: ‘MyViewController’ may not respond to ‘-view’
Classes/HelloWorldAppDelegate.m: In function ‘-[HelloWorldAppDelegate dealloc]‘:
Classes/HelloWorldAppDelegate.m:27: warning: ‘MyViewController’ may not respond to ‘-release’
make: *** [Classes/HelloWorldAppDelegate.o] Error 1
So i tried a few more steps and got this to work on my 3.1.2
the difference the second time was that I copied and overwrote the files contained in the sys30.tgz to my /usr/include and /var/include
previous attempts i only wrote files that were not already present which i think caused some incompatibilities…
the lib folders i only copied files to the iphone where were not already present
everything worked fine after that
@Matt Luu
I have had the same problems as above but I have solved them now.
Now i get this problem while compiling the HelloWorld app:
[code]
iRob:~/HelloWorld root# make install
arm-apple-darwin9-gcc -arch arm -lobjc -framework CoreFoundation -framework Foundation -framework UIKit -framework QuartzCore -framework CoreGraphics -framework GraphicsServices -framework CoreSurface -L"/usr/lib" -F"/System/Library/Frameworks" -F"/System/Library/PrivateFrameworks" -bind_at_load -multiply_defined suppress -o HelloWorld Classes/HelloWorldAppDelegate.o Classes/MyView.o Classes/MyViewController.o Classes/main.o
Undefined symbols:
"_objc_setProperty", referenced from:
-[HelloWorldAppDelegate setMyViewController:] in HelloWorldAppDelegate.o
-[HelloWorldAppDelegate setWindow:] in HelloWorldAppDelegate.o
"_objc_msgSendSuper2", referenced from:
-[HelloWorldAppDelegate dealloc] in HelloWorldAppDelegate.o
-[MyViewController didReceiveMemoryWarning] in MyViewController.o
-[MyViewController dealloc] in MyViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [HelloWorld] Error 1
[/code]
Does anyone know how to solve this error?
Sorry for my english, I’m dutch.
Thank you for this very useful tutorial.
I’m getting same error as robbiedobbie and cannot solved yet.
but when I try HelloWorld program from this page, it worked, even though I get a lot of warnings.
http://antirez.com/page/iphone-gcc-guide.html
I don’t know why.I’m working on iPod touch 2G 3.1.3
@robbiedobbie
The same problem..
did you ever get it working? i have the same issue as you@LongLife
Wow… this thread has been a very useful resource, and the comments even more-so. I’ll just briefly summarize what I did to get it working on my iPod Touch 2G 3.1.3 FW.
- Followed instructions on tutorial until encountered issues with building test .c application – lgcc.. not found
- This was resolved (as noted) by downloading the lib.rar file and copying over libgcc* and libSystem* to /usr/lib
- Then when compiling the HelloWorld app, same “cannot find protocol declaration” issues as noted
- Downloaded sys30.tgz to device, killed the /System/Library/Frameworks and PrivateFrameworks directories, overwrote with the ones in sys30.tgz as well as /var/include.
- Make, and all was happy!
Now to learn obj-c…
OK, an update on my last post… I spoke too soon.
After I replaced the Framework directories and compiled HelloWorld, all looked ok in that the app compiled. However, it rebooted my itouch at that point, and it was then stuck in an infinite loop.
After restoring multiple times and banging my head, I have figured out that replacing the Framework directories is not cool (on 3.1.3 at least). As soon as I do that, launching apps like Safari and Settings show a screwed up UI, leading me to believe those directories aren’t meant to be replaced.
Anyone with 3.1.3 actually manage to replace those directories with sys30.tgz and have a working system? Why do those directories need to be replaced in the first place? Is the issue with the framework directories, or the HelloWorld app??
Hello,
I haven’t gotten test.c to compile. At first I got an error for library not found for lgcc_s.10.5 and library not found for system.
I put the libgcc.s1 and the libSystem.dylib and libSystem.B.dylib, files in /usr/lib on my phone. I got the files from my laptop I had an iPhone sdk for 10.5 and an iPhone sdk for 10.4 on my computer.
Now I get an error saying ld: warning missing required architecture arm in file /usr/lib/libSystem.dylib I also get the same warning for the file /usr/lib/libgcc_s.10.5.dylib
and then I get several undefined symbol errors, I wonder what is wrong? One thing I wondered when putting in files from the sdk, should I use 10.4 files or 10.5? And is it ok to have some 10.4 files in /usr/lib on my iPhone? Btw I have a 3gs running fw 3.1.3. Thanks in advance.
@jdhar:
see here
http://ihackmyi.com/iphone/index.php/topic,20231.0.html
@Jamesapp
Hello,
I got test.c to compile. I am working on the HelloWorld app, I am getting a bunch of errors similar to some errors on the comments. Ok I have a 2.0 ver of the sdk on my laptop. So I ran a script from the first link in the tutorial where it talks about copying the headers to the iPhone. I ran the script and it ran a couple of aliases couldn’t be copied because they were broken. But most headers were copied.
I have a 3gs running fw 3.1.3 and like I said I am using the 2.0 sdk. I am wondering is there additional steps I should take after running the copySDKHeader2.sh script? I believe a lot of files got copied to /var/sdk/include. I haven’t done anything with /usr/include on my iPhone. Am I supposed to?
I read about fixing the include section of the HelloWorld app, but I don’t know what this means. I tried editing the makefile by changing
CFLAGS = -I”/var/include”
to
CFLAGS = -I”/var/sdk/include”
but that caused more errors. And I heard atleast one person say that 3.1.3 gave him problems when replacing the framework files. I don’t know if I overwrite the framework files or not when I ran the script. But I wondered if it is safe to do this on 3.1.3, I don’t want to have to restore, if I don’t have to. Any help would be appreciated.
Hello,
I edited my makefile to point to the include directories where I put the headers from the iPhone SDK I am using 2.0 SDK. And I got rid of a bunch of errors.
Now I am getting an error that my iPhone can’t find the CoreFoundation framework. I heard where someone had a similar problem and they commented out the line in the makefile that dealt with foundation CoreFoundation. Then that person recompiled and there device couldn’t find the next framework in the list on the makefile. I am pointing my device in the makefile to “/System/Library/Frameworks”.
I have also read that people solved this by overwriting the folder structure of there device with one that they downloaded from the links in the tutorial. My question know is can I overwrite these files if I am on 3.1.3? Can anyone confirm one way or the other if overwriting files is ok on 3.1.3? Thanks in advance.
Hi, thanks for the tutorial! I’ve successfull compiled HelloWorld & some other projects, but instead of using sdk40’s headers and library I need to use the sys30 in previous comments. The sdk40 produces much syntax error in compiling. I’m not sure is that means Apple’s Official SDK not compatible with 2.0’s toolchain?
I have everything extracted from iPhoneSDK 4.0.1 extracted in Ubuntu Linux 10.04 (Lucid).
How would I go about setting it up so this script works on my 4.0 device?
Thanks
Is the Toolchain installation script (http://rpetri.ch/toolchain) still up to date for my jailbroken iPhone 4 using iOS 4.0.1?
Trackbacks/Pingbacks (3)
[...] See more here: How to Make iPhone apps on any OS, on the iPhone itself, for free … [...]
[...] Here is the original post: How to Make iPhone apps on any OS, on the iPhone itself, for free … [...]
[...] ということでググるとエラーで困っている同志発見、しかも解決方法まで!How to Make iPhone apps on any OS, on the iPhone itself, for free [...]