Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is a another way as gcc-4.2 still supports armv6, which won't require you to close Xcode 4.5 an open a previous version (for compilation, but not for running app on a 4.2 device) :</p> <ul> <li>Add armv6 to both valid archs and archs :</li> </ul> <p>Archs : $(ARCHS_STANDARD_32_BIT) armv6</p> <p>Valid Architectures : armv6 armv7 armv7s</p> <ul> <li>Vim (or TextEdit) your project.pbxproj file to replace IPHONEOS_DEPLOYMENT_TARGET to 4.0 - 4.1 - 4.2 as you need, Xcode 4.5 won't let you get below 4.3.</li> </ul> <p>Then, if you build your project, you will see warnings :</p> <pre> warning: no rule to process file '$(PROJECT_DIR)/App/AppDelegate.m' of type sourcecode.c.objc for architecture armv6 warning: no rule to process file '$(PROJECT_DIR)/App/SomeFile.c' of type sourcecode.c.c for architecture armv6 </pre> <ul> <li>Add a <code>Build Rule</code> for source files with names matching : <code>*.[mc]</code> that will use <code>LLVM GCC 4.2</code></li> </ul> <p>It works for static libraries, but not for apps :</p> <pre> ld: file is universal (4 slices) but does not contain a(n) armv6 slice: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o for architecture armv6 </pre> <ul> <li>For making it works for apps, we need to add the armv6 slice to this object file (which comes with the 5.1 SDK) :</li> </ul> <pre> lipo /path/to-4.4/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/crt1.3.1.o -extract armv6 -output /tmp/crt1.3.1-armv6.o lipo /Applications/Xcode.app/Contents//Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o /tmp/crt1.3.1-armv6.o -create -output /tmp/crt1.3.1-armv677s.o mv /Applications/Xcode.app/Contents//Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o /Applications/Xcode.app/Contents//Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o.bkp mv /tmp/crt1.3.1-armv677s.o /Applications/Xcode.app/Contents//Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o </pre> <p>Compile your project and check that your app contains all archs :</p> <pre> $ file DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp: Mach-O universal binary with 3 architectures DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp (for architecture armv6): Mach-O executable arm DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp (for architecture armv7): Mach-O executable arm DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp (for architecture cputype (12) cpusubtype (11)): Mach-O executable arm </pre> <p>Note that the dSYM file also contains all archs (useful for crash report symbolification) :</p> <pre> $ file DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app.dSYM/Contents/Resources/DWARF/TestApp DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app.dSYM/Contents/Resources/DWARF/TestApp: Mach-O universal binary with 3 architectures DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app.dSYM/Contents/Resources/DWARF/TestApp (for architecture armv6): Mach-O dSYM companion file arm DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app.dSYM/Contents/Resources/DWARF/TestApp (for architecture armv7): Mach-O dSYM companion file arm DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app.dSYM/Contents/Resources/DWARF/TestApp (for architecture cputype (12) cpusubtype (11)): Mach-O dSYM companion file arm </pre> <p>I've sucessfully installed and launched the app on an iOS 4.2 2gen iPod touch by opening xcode 4.4.1, then <code>Product</code> -> <code>Run without building</code>.</p> <ul> <li>When you <strong>Archive</strong> your product, you may experience again the Apple Mach-O Linker error, this time involving other files, such as <code>libarclite_iphoneos.a</code> or <code>libclang_rt.ios.a</code>:</li> </ul> <pre> ld: file is universal (2 slices) but does not contain a(n) armv6 slice: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a for architecture armv6 </pre> <pre> ld: file is universal (2 slices) but does not contain a(n) armv6 slice: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/4.1/libclang_rt.ios.a for architecture armv6 </pre> <p>The procedure used for crt1.3.1.o applies to these files too, and will fix the error allowing Xcode to successfully archive your project: you can use the path printed by <em>ld</em> to find the file and join the armv6 slice with <em>lipo</em>; just keep in mind that libclang_rt.ios.a in the previous versions of Xcode isn't located in <code>Xcode.app/[...]/usr/lib/clang/4.1</code> but in <code>Xcode.app/[...]/usr/lib/clang/4.0</code>.</p> <p>I've successfully archived the file, deployed it with an ad-hoc distribution profile, and tested on iPhone 3G (4.2.1) and iPhone 3GS (6.0).</p> <ul> <li>Last issue : we can't launch app. In the <code>Organizer</code>, there is the message : <strong>Devices of type “iPhone 3G” are not supported by this version of Xcode.</strong></li> </ul> <p>But an <code>ls</code> in the <code>DeviceSupport</code> shows :</p> <pre> ls /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/ 4.2 4.3 5.0 5.1 6.0 (10A403) </pre> <p>With no diffs in the 4.2 directory from Xcode 4.4.1.</p> <p>The question is now : how Xcode detect is device is supported or not ?</p> <p>Opening <code>/Applications/Xcode.app/Contents/Developer//Platforms/iPhoneOS.platform/Developer//Library/PrivateFrameworks/DTDeviceKitBase.framework/DTDeviceKitBase</code> with <code>Hex Fiend</code> (or another hex editor), and replacing ascii <code>4.3</code> with <code>4.2</code> make the error message disappear, and app installed on the device are listed (but device bullet in the device list is still red).</p> <p>Then we need to edit <code>/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks//DTDeviceKit.framework/Versions/Current/DTDeviceKit</code> and replace :</p> <p><code>Expired.deviceArchitecture.iPhone1,1.iPhone1,2.iPod1,1.iPod2,1.iPod2,2.armv6</code> </p> <p>to :</p> <p><code>Expired.deviceArchitecture.iPhone0,1.iPhone0,2.iPod0,1.iPod0,1.iPod0,2.armv5</code></p> <p>Then we have an orange bullet in the Organizer (Xcode 4.5.1) :</p> <pre> The version of iOS on “iPhone” is too old for use with this version of the iOS SDK. Please restore the device to a version of the OS listed below. OS Installed on iPhone 4.2.1 (8C148) Xcode Supported iOS Versions 6.0 (10A403) 5.1 5.0 4.3 </pre> <p>The question is now : where Xcode Supported iOS Versions are defined ?</p> <p>As there is a <code>4.2</code> directory in <code>/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/</code>, it should already be supported...</p> <p>Tried to copy <code>iPhoneOS4.2.sdk</code> from Xcode 4.4.1 to <code>/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/</code>, but it don't make device supported.</p> <p>So haven't found how to add 4.2 device support in Xcode 4.5. Any ideas ?</p> <p>Conclusion : compiling for armv6/7/7s within Xcode 4.5 is possible. But it is not possible to start an app on a 4.2 armv6 device without starting Xcode 4.4.</p> <p><strong>Big update : it works with Xcode 4.5.2 !</strong></p> <p>Now the bullet is green in Xcode 4.5.2 :-) The device appear in the drop down list near the Run button. But when trying to run the app, got the message : </p> <pre> Xcode cannot run using the selected device. Choose a destination with a supported architecture in order to run on this device. </pre> <p>Simply add armv6 to the valid architectures :-)</p> <p>Other note : the <code>Build Rule</code> for source files with names matching : <code>*.[mc]</code> can use <code>LLVM GCC 4.2</code> or <code>Apple LLVM compiler 4.1</code>, or <code>Default compiler</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload