Armv7 + Arm64 fat build is incompatible with iPhone 4s - iphone

My Unified API Xamarin app can be built in both Armv7 and Armv7+Arm64 thin and fat build architectures.
When I build it in Armv7 architecture I can deploy and run it on an iPhone4s. When I build it in Armv7+Arm64 architecture(s) I can deploy and run it on iPhone5 and above.
Why can't I deploy Armv7+Arm64 build to iPhone 4s?
This is the error I get:
Installing application bundle
writeDictToFile:1258 ==== Successfully wrote Manifest cache to /var/folders/9y/yvyksjvd38g_gnkndcw4y_100000gn/T/Xamarin.iOS_InstallShadowPath/d2d4e62f663137bab4687ec28f35467b/aead04c30517c7b5a662da00c34e58e38ac78222/ManifestCache.plist
error MT1006: Could not install the application '/Users/noammeirofek/RoX/bin/RumbleTouch.app' on the device Adi’s iPhone: AMDeviceSecureInstallApplicationBundle returned: 0xe8000087 (kAMDIncorrectArchitectureError).
The application was terminated by a signal: SIGHUP

I got the same error (which led me to your question), but under different circumstances - so I'm sorry but I cannot explain why ARMv7+ARM64 did not work for you when just ARMv7 did.
Are you sure you were deploying to an iPhone4s and not an iPhone5?
I am deploying to an iPad 3 and my architecture settings were ARMv7s + ARM64. I got the same error in your writeup. When I chose instead ARMv7 + ARM64, the app deployed.
Per Xamarin Studio (options, iOS Build, Advanced):
ARMv7s is the latest architecture supported only by the new A6 processor included in the iPhone5
You might want to choose ARMv7 + ARMv7s + ARM64 in the dropdown option called Supported architectureson the Advanced tab
According to this list of iOS devices, your original selection should have worked, because the iPhone4s has an ARMv7
I experimented with my app on an iPhone4 (I don't have an iPhone4s) and the deploy worked with ARMv7+ARM64 (your original setting), and did not work for ARMv7s+ARM64 (as expected) and did work with the all-inclusive ARMv7+ARMv7s+ARM64
I am also using a Unified 64bit API, Xamarin Studio, XCode 7 and my iPad has iOS 9.0 installed.

Related

Xcode 5 and iOS 7: Architecture and Valid architectures

I'm starting new project in Xcode 5. I want to develop application using iOS SDK 7 but with deployment target iOS 5.0. As soon as I create new project in Xcode and try to change deployment target to 5.0, I've got this message:
Applications including an arm64 slice are not compatible with versions of iOS
prior to 6.0
Adjust your Architectures build setting to not include arm64 in order to deploy
to releases prior to iOS 6.0.
So changed architectures to Standard (no 64bit). I compiles, runs but I do not really understand what just happend.What's the difference between Architectures and Valid architectures settings in Xcode project Build Settings?If I set Architectures to exclude 64-bit what happens when I run my app on 64-bit iPhone or iOS Simulator (I know it works, I'm just curious what hapens underneath)?Can you explain big mess with new 64-bit architecture?
Set the architecture in build setting to Standard architectures(armv7,armv7s)
iPhone 5S is powered by A7 64bit processor. From apple docs
Xcode can build your app with both 32-bit and 64-bit binaries included. This combined binary requires a minimum deployment target of iOS 7 or later.
Note: A future version of Xcode will let you create a single app that supports the 32-bit runtime on iOS 6 and later, and that supports the 64-bit runtime on iOS 7.
From the documentation what i understood is
Xcode can create both 64bit 32bit binaries for a single app but the
deployment target should be iOS7. They are saying in future it will
be iOS 6.0
32 bit binary will work fine in iPhone 5S(64 bit processor).
Update (Xcode 5.0.1)
In Xcode 5.0.1 they added the support to create 64 bit binary for iOS 5.1.1 onwards.
Xcode 5.0.1 can build your app with both 32-bit and 64-bit binaries included. This combined binary requires a minimum deployment target of iOS 5.1.1 or later. The 64-bit binary runs only on 64-bit devices running iOS 7.0.3 and later.
Update (Xcode 5.1)
Xcode 5.1 made significant change in the architecture section. This answer will be a followup for you.
Check this
My understanding from Apple Docs.
What is Architectures (ARCHS) into Xcode build-settings?
Specifies architecture/s to which the binary is TARGETED. When specified more that one architecture, the generated binary may contain object code for each of the specified architecture.
What is Valid Architectures (VALID_ARCHS) into Xcode build-settings?
Specifies architecture/s for which the binary may be BUILT.
During build process, this list is intersected with ARCHS and the resulting list specifies the architectures the binary can run on.
Example :- One iOS project has following build-settings into Xcode.
ARCHS = armv7 armv7s
VALID_ARCHS = armv7 armv7s arm64
In this case, binary will be built for armv7 armv7s arm64 architectures. But the same binary will run on ONLY ARCHS = armv7 armv7s.
When you set 64-bit the resulting binary is a "Fat" binary, which contains all three Mach-O images bundled with a thin fat header. You can see that using otool or jtool. You can check out some fat binaries included as part of the iOS 7.0 SDK, for example the AVFoundation Framework, like so:
% cd /Developer/Platforms/iPhoneOS.platform/DeviceSupport/7.0\ \(11A465\)/Symbols/System/Library/Frameworks/AVFoundation.framework/
%otool -V -f AVFoundation 9:36
Fat headers
fat_magic FAT_MAGIC
nfat_arch 3
architecture arm64 # The 64-bit version (A7)
cputype CPU_TYPE_ARM64
cpusubtype CPU_SUBTYPE_ARM64_ALL
capabilities 0x0
offset 16384
size 2329888
align 2^14 (16384)
architecture armv7 # A5X - packaged after the arm64version
cputype CPU_TYPE_ARM
cpusubtype CPU_SUBTYPE_ARM_V7
capabilities 0x0
offset 2359296
size 2046336
align 2^14 (16384)
architecture armv7s # A6 - packaged after the armv7 version
cputype CPU_TYPE_ARM
cpusubtype CPU_SUBTYPE_ARM_V7S
capabilities 0x0
offset 4407296
size 2046176
align 2^14 (16384)
As for the binary itself, it uses the ARM64 bit instruction set, which is (mostly compatible with 32-bit, but) a totally different instruction set. This is especially important for graphics program (using NEON instructions and registers). Likewise, the CPU has more registers, which makes quite an impact on program speed. There's an interesting discussion in http://blogs.barrons.com/techtraderdaily/2013/09/19/apple-the-64-bit-question/?mod=yahoobarrons on whether or not this makes a difference; benchmarking tests have so far clearly indicated that it does.
Using otool -tV will dump the assembly (if you have XCode 5 and later), and then you can see the instruction set differences for yourself. Most (but not all) developers will remain agnostic to the changes, as for the most part they do not directly affect Obj-C (CG* APIs notwithstanding), and have to do more with low level pointer handling. The compiler will work its magic and optimizations.
You do not need to limit your compiler to only armv7 and armv7s by removing arm64 setting from supported architectures.
You just need to set Deployment target setting to 5.1.1
Important note: you cannot set Deployment target to 5.1.1 in Build Settings section because it is drop-down only with fixed values. But you can easily set it to 5.1.1 in General section of application settings by just typing the value in text field.
Simple fix:
Targets -> Build Settings -> Build Options -> Enable Bitcode -> No
Works on device with iOS 9.3.3
None of the answers worked and then I was forgetting to set minimum deployment target which can be found in Project -> General -> Deployment Info -> Deployment Target -> 8.0

Can't debug on iOS 4.x devices

Whenever I try to debug on devices with iOS 4.x (iPhone 4 and 3GS) I get the following error:
error: failed to launch '/XXX/Library/Developer/Xcode/DerivedData/XXX-fytptbaixvmoweacfsniqxtvjkst/Build/Products/Debug-iphoneos/XXX.app/XXX'
-- Bad CPU type in executable
On devices with iOS 5.x it works.
I am using xCode 4.3.3 and my configurations are:
Architectures: Standard (armv7) (also tried armv6,armv7 to no avail)
Base SDK: Latest iOS (iOS 5.1)
Valid Architectures: armv6, armv7
Deployment Target: iOS 4.0
What do you think?
In your Xcode preferences, go to downloads tab and install "iOS 4.0 - 4.1 Device Debugging Support".
This package includes information and symbols that Xcode needs for
debugging your app on iOS devices running versions of iOS prior to iOS
4.2. If you intend to debug your app on a device running one of these versions of iOS you should install this package.

facebook ios sdk build fails on device, works on simulator

I am trying to build an app (with ARC) that uses the facebook_ios_sdk (the latest version on github).
As recommended by Facebook, I used the build script to create a static library and then added it to the project.
Now when I build the project for an iPhone 5.1 Simulator, it works fine. However, on running it for an actual device (which is running 5.1), it gives the following build error -
ld: in ../facebook-ios-sdk/libfacebook_ios_sdk.a, file is universal but does not contain a(n) armv7 slice for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any suggestions on how to resolve this?
You could modify the build script for static library (which was too complicated for me), or just skip the library approach:
add the Facebook sources from SDK to your project
if using ARC, go to "target->build phases->compile sources" and mark all the Facbook source files with the--fno-objc-arc flag
That's it, works for me.
One work around that worked was to change the Valid Architectures from"armv6 armv7" to just armv6

Can't deploy to iPhone(1st Generation) after updating from Xcode 4.1 to 4.2.1

After updating from 4.1 to 4.2.1, I was not able to deploy to my 1st generation iPhone. I received a message that a debugger for version 3.0 - 3.2 needs to be downloaded. I downloaded it.
After downloading the debugger, now Xcode displays the messages:
"Build succeeded" and "Finished running....".
But the application doesn't even launch!
There haven't been any code changes.
The only other change is that Xcode suggested I update the build settings to use the llvm 3.0 compiler (all I did was click OK).
Now It won't deploy to my first gen iPhone.! :C
It seems to deploy to my 4th generation iPod touch (iOS 5.01 (9A405)) without problem though.
Is there some kind of code change or setting change I need to make?
The last version of Xcode where I could deploy was 4.1 . After that I updated to 4.2.1
EDIT: I followed rckoenes advice below, and I added armv6 & armv7 to the architectures (and removed the variable that was already there). Now the application launches on my device, but almost immediately into the launch, the following error appears :
dyld: Symbol not found: __NSConcreteStackBlock
Referenced from: /var/mobile/Applications/921C1E7F-449D-4EA1-AEAA-70A1AF60C351/ProjectX.app/ProjectX
Expected in: /usr/lib/libSystem.B.dylib
I have tried the following:
under "Build Phases" for the targets, I have added libSystem.B.dylib under "Link Binary With Libraries".
But the error message still appears.
EDIT: Marking the library as optional in "Link Binary With Libraries" makes the error go away".
You probably need to add the armv6 to you Architectures list: http://triplesoftware.nl/2011/12/running-ios-5-build-apps-on-the-orignal-iphone-ipod-touch-and-iphone-3g/

Malformed metadata record for architecture i386

I just upgraded from Xcode 4 to Xcode 4.2 and now I'm getting the following error when building for the Simulator:
ld: in /Users/rstaicut/Library/Developer/Xcode/DerivedData/iphone/Build/Intermediates/iphone.build/QA Server-iphonesimulator/Project iPhone Debug.build/Objects-normal/i386/CartController.o, could not parse object file
/Users/rstaicut/Library/Developer/Xcode/DerivedData/iphone/Build/Intermediates/iphone.build/QA Server-iphonesimulator/Project iPhone Debug.build/Objects-normal/i386/CartController.o:
**Malformed metadata record for architecture i386**
**Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1**
One thing to note is that I've changed the compiler to LLVM GCC 4.2 for this upgrade and I'm using armv6 and armv7 for the architectures. I'm only getting this error for the Simulator, the build finishes for the device.
Any ideas what malformed metadata record could mean?
Got the simulator to finally work. These are the things I changed:
Under Project > Build Settings > Architectures > Valid Architectures I took out i386 and left only armv6 and armv7. Under architectures I only have armv6 and armv7
I changed the Compiler from LLVM GCC 4.2 to Apple LLVM compiler 3.0 (Under Project > Build Settings > Build Options > Compiler for C/C++/Objective-C
Changed the iOS Deployment target from iOS 3.1 to iOS 4.0
The last step was to press on "Validate settings" (the button in the middle on the bottom). It's going to ask you to change some settings for the compiler from LLVM GCC to Apple LLVM Compiler 3.0. Hit OK.
My simulator started magically working after that. No errors, though plenty of warnings due to the change in compiler.
Hope this helps anyone else who runs into this issue.