XCODE4: Fail to build for iOS 4.0, 4.1

To begin, I'm running Xcode 4.0.2, Build 4A2002a

Nothing goes wrong when compiling my project for iOS 4.2/4.3. However, when using it to compile using iOS 4.0/4.1, I get lots of the following errors;

uint8_t not defined, uint16_t not defined, uintptr_t not defined, etc...

or

cc1plus: error: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/usr/include/c++/4.2.1/arm-apple-darwin10/v7: not a directory

or

ld: warning: ignoring file /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/usr/lib/libSystem.dylib, file was built for unsupported file format which is not the architecture being linked (armv6)
ld: warning: symbol dyld_stub_binder not found, normally in libSystem.dylib
Undefined symbols for architecture armv6:




I believe all of these errors has to do with a faulty installation... For some reason, while installing xcode 4.0.2, it either forgets to set up the file-links properly, or maybe apple purposely left it out to drive developers to use the new OSs... either way, it caused about an hour of headache.



The solution for item #1, is to open up stdint.h... notice that the file contains no more than couple lines of crap... something along the lines of:

XSym
0027
88c0b7e54f82f10929bdfc91ac2dbefd
gcc/darwin/default/stdint.h

Where default obviously refers to GCC version... but the linkage went wrong somewhere, and so stdint.h was never included, thereby causing all your headache. The solution is to (1) manually include the stdint.h in your project, or (2) copy and paste the content into the file with the mumbo-jumbo above.


The solution for item #2 is to fix the symbolic links that somehow got corrupted. Any references to v6 and v7 are supposed to map to the following directories:

ln -s /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.#.sdk/usr/include/c++/4.2.1/armv6-apple-darwin10 v6
ln -s /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.#.sdk/usr/include/c++/4.2.1/armv6-apple-darwin10 v7


Obviously, don't forget to replace out the # sign in the commands above... or else, good luck with that command :P


The solution for item #3 is yet another failed symbolic link (ARGH!). libSystem.dylib is supposed to be a symbolic link to libSystem.B.dylib. But NO! Something happened and now it's just a file taking up space. Fix this symbolic link and you're back in business. At least, I am.

ln -s /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.#.sdk/usr/lib/libSystem.B.dylib libSystem.dylib

Again, don't forget about the # sign.

XCODE4: Stuck on Attaching to 'Appname'

CTRL+R usually runs the application on the Simulator automatically, but today it stopped suddenly. Instead, I just kept seeing "Attaching to Appname' message in the status window.

After some heavy googling, turns out it's scheme setting. To fix:

1. Goto Product > Run...

2. On the left hand side, select Run appname.app

3. Select the info tab on the right

4. Select Launch --> Automatically

For some reason, neither Automatically nor 'wait for appname.app to launch were selected.

---

If your simulator screen is already stuck in darkness (black screen of death),

1. Stop your running demo (hit the STOP button)

2. Goto menubar > iOS Simulator > Reset content and settings...

3. Re-run following the steps above