Bug 34092 - Deploying existing app to iPhone 4 stopped working with error: kAMDIncorrectArchitectureError
Summary: Deploying existing app to iPhone 4 stopped working with error: kAMDIncorrectA...
Status: RESOLVED NORESPONSE
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2015-09-19 22:00 UTC by Tim Penhey
Modified: 2016-07-11 21:48 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NORESPONSE

Description Tim Penhey 2015-09-19 22:00:19 UTC
Similar to bug 26867, but this is an existing Xamarin.Forms project targeting both Android and iOS. This worked before, but started getting this problem when I tried over the weekend.

Error in Visual Studio 2015 says:

Error  Failed to deploy application on the target device. Please try to rebuild the solution and try again.

Full error from the mtbserver.log on the MacBook says:

[20-Sep-2015 13:41:24] stderr: error MT1006: Could not install the application '/Users/kawaw-002/Library/Caches/Xamarin/mtbs/builds/KawawiOS/9f4065f81eb8209676d949a1d276ebbe/bin/iPhone/Debug/FormsTemplateiOS.app' on the device Test iPhone: AMDeviceSecureInstallApplicationBundle returned: 0xe8000087 (kAMDIncorrectArchitectureError).


Tried the following:

New iOS app from XCode deploys fine.
New iOS app from Xamarin Studio on MacBook deploys fine.
New Forms app from Visual Studio on Windows (same machine) works fine - with same "ARMv7 + ARM64" targets.

However existing Forms app with same target gets the deployment error above.

Changing the Supported architectures to ARMv7 alone allows the app to be deployed, however this is not a viable solution.

Device is iPhone 4 with iOS 7.1.2
Comment 1 Tim Penhey 2015-09-19 22:08:07 UTC
From the MacBook Xamarin build logs:

[20-Sep-2015 13:37:19] MTouch Task
[20-Sep-2015 13:37:19]   AppBundleDir: bin/iPhone/Debug/FormsTemplateiOS.app
[20-Sep-2015 13:37:19]   AppExtensionReferences:
[20-Sep-2015 13:37:19]   AppManifest: bin/iPhone/Debug/FormsTemplateiOS.app/Info.plist
[20-Sep-2015 13:37:19]   Architectures: ARMv7, ARM64
[20-Sep-2015 13:37:19]   CompiledEntitlements: obj/iPhone/Debug/Entitlements.xcent
[20-Sep-2015 13:37:19]   Debug: True

The architectures are being passed through at least.
Comment 2 Tim Penhey 2015-09-20 22:58:01 UTC
I'm fairly sure that the only thing that changed between when it worked and when it stopped working was the MacBook updating XCode to 7.0.

Based on the observation that a new Forms app targeting both "ARMv7 + ARM64" does deploy fine, and the current app doesn't, the difference there is the number of dependencies that the app brings in.

Could it be the XCode 7 linker screwing things up so the iPhone 4 can't determine that there is a valid binary?
Comment 3 Rolf Bjarne Kvinge [MSFT] 2015-09-21 09:06:37 UTC
(In reply to comment #2)
> I'm fairly sure that the only thing that changed between when it worked and
> when it stopped working was the MacBook updating XCode to 7.0.

You can test this hypothesis by downloading Xcode 6.4 (or the previous version you had installed) to your Mac and try again.

However this looks identical to bug #26867, which we never really figured out what happened, although it seemed to be a device-specific issue. Do you have another device you can try and see if it works there?
Comment 4 Tim Penhey 2015-09-22 04:43:00 UTC
Well... I'm trying to get the code working with Xcode 6.4.

I downgraded the Xcode on the mac to 6.4.

I went back to the last known version of the app that was working, which still had Xamarin.Forms 1.4.2.6359.

However my Visual Studio has the new Xamarin plugin.

When attempting to build the iOS app, initially it complained about the SDK 9.0 not being available. I went into the settings to change it back to 8.4 (ended up with default).

Trying to compile gives me this error list:

1>------ Build started: Project: Kawaw.iOS, Configuration: Debug iPhone ------
1>  Generated session id: 9f4065f81eb8209676d949a1d276ebbe
1>  Generated build app name: KawawiOS
1>  Kawaw.iOS -> C:\Users\tim\src\kawaw-app\Kawaw\Kawaw.iOS\bin\iPhone\Debug\FormsTemplateiOS.exe
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(654,3): error : Your application is using the 'Contacts' framework, which isn't included in the iOS SDK you're using to build your app (this framework was introduced in iOS 9.0, while you're building with the iOS 8.4 SDK.) This configuration is only supported with the legacy registrar (pass --registrar:legacy as an additional mtouch argument in your project's iOS Build option to select). Alternatively select a newer SDK in your app's iOS Build options.
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(654,3): error : Your application is using the 'GameplayKit' framework, which isn't included in the iOS SDK you're using to build your app (this framework was introduced in iOS 9.0, while you're building with the iOS 8.4 SDK.) This configuration is only supported with the legacy registrar (pass --registrar:legacy as an additional mtouch argument in your project's iOS Build option to select). Alternatively select a newer SDK in your app's iOS Build options.
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(654,3): error : Your application is using the 'MetalKit' framework, which isn't included in the iOS SDK you're using to build your app (this framework was introduced in iOS 9.0, while you're building with the iOS 8.4 SDK.) This configuration is only supported with the legacy registrar (pass --registrar:legacy as an additional mtouch argument in your project's iOS Build option to select). Alternatively select a newer SDK in your app's iOS Build options.
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(654,3): error : Your application is using the 'ModelIO' framework, which isn't included in the iOS SDK you're using to build your app (this framework was introduced in iOS 9.0, while you're building with the iOS 8.4 SDK.) This configuration is only supported with the legacy registrar (pass --registrar:legacy as an additional mtouch argument in your project's iOS Build option to select). Alternatively select a newer SDK in your app's iOS Build options.
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(654,3): error : Your application is using the 'MetalPerformanceShaders' framework, which isn't included in the iOS SDK you're using to build your app (this framework was introduced in iOS 9.0, while you're building with the iOS 8.4 SDK.) This configuration is only supported with the legacy registrar (pass --registrar:legacy as an additional mtouch argument in your project's iOS Build option to select). Alternatively select a newer SDK in your app's iOS Build options.
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(654,3): error : Your application is using the 'CoreSpotlight' framework, which isn't included in the iOS SDK you're using to build your app (this framework was introduced in iOS 9.0, while you're building with the iOS 8.4 SDK.) This configuration is only supported with the legacy registrar (pass --registrar:legacy as an additional mtouch argument in your project's iOS Build option to select). Alternatively select a newer SDK in your app's iOS Build options.
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(654,3): error : Your application is using the 'ContactsUI' framework, which isn't included in the iOS SDK you're using to build your app (this framework was introduced in iOS 9.0, while you're building with the iOS 8.4 SDK.) This configuration is only supported with the legacy registrar (pass --registrar:legacy as an additional mtouch argument in your project's iOS Build option to select). Alternatively select a newer SDK in your app's iOS Build options.
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(654,3): error : Your application is using the 'ReplayKit' framework, which isn't included in the iOS SDK you're using to build your app (this framework was introduced in iOS 9.0, while you're building with the iOS 8.4 SDK.) This configuration is only supported with the legacy registrar (pass --registrar:legacy as an additional mtouch argument in your project's iOS Build option to select). Alternatively select a newer SDK in your app's iOS Build options.
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(654,3): error : Your application is using the 'WatchConnectivity' framework, which isn't included in the iOS SDK you're using to build your app (this framework was introduced in iOS 9.0, while you're building with the iOS 8.4 SDK.) This configuration is only supported with the legacy registrar (pass --registrar:legacy as an additional mtouch argument in your project's iOS Build option to select). Alternatively select a newer SDK in your app's iOS Build options.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========



When I try to add the flag it asks for I get this:

1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(654,3): error : The legacy registrars (--registrar:legacy|legacystatic|legacydynamic) are not supported with the Unified API.


So I am somewhat stuck trying to compile with Xcode 6.4. Any ideas?
Comment 5 Rolf Bjarne Kvinge [MSFT] 2015-09-22 04:46:32 UTC
You can downgrade your VS plugin as well; this can be done here: https://kb.xamarin.com/customer/portal/articles/1699777-how-do-i-downgrade-to-an-older-version-

Alternatively you can enable managed linking (set it to "Link SDK assemblies" in the project's iOS Build options.
Comment 6 Tim Penhey 2015-09-23 05:00:59 UTC
Used Link SDK and did a clean build.

App deployed and started running. Hit a bug that I have been told is fixed in Forms 1.4.3. But the deploy did work.

Xcode 7 definitely seems to blame here.

So now what?
Comment 7 Rolf Bjarne Kvinge [MSFT] 2015-09-23 05:36:38 UTC
Do you have another device to check if it's something specific to this device?

However the simplest solution is to build ARMv7 only when testing on this device (it'll also make your builds significant faster).
Comment 8 Tim Penhey 2015-09-23 18:40:37 UTC
No, not really.

However I don't believe it is specific to this device. Other people have the same problem, and trying to say "it is device specific" is very dismissive.

A new Forms app compiling with Xcode 7.0 targeting both ARMv7 and ARM64 compiles and deploys fine to the phone.

For my application that has more dependencies, Xcode 7.0 is unable to create a binary that the phone understands.

Xcode 6.4 can create a binary that the phone understands.

Clearly it is the interaction of the libraries, Xamarin, and Xcode 7.

I am not blocked in my current development or testing of my app, but going forwards for me, and for other users, this is clearly a problem that needs to be addressed.

How do we escalate this?
Comment 9 Rolf Bjarne Kvinge [MSFT] 2015-09-24 06:57:09 UTC
@Tim, can you zip up this directory on your Mac and share it with us (you won't be able to attach it here, it's too big, so please use a file-sharing service like Dropbox): /Users/kawaw-002/Library/Caches/Xamarin/mtbs/builds/KawawiOS/9f4065f81eb8209676d949a1d276ebbe/bin/iPhone/Debug/FormsTemplateiOS.app? I'll try and see if I can install the exact same binary on my devices and see if I can reproduce the problem.
Comment 10 Tim Penhey 2015-09-24 19:10:20 UTC
Given that this is now using Xcode 6.4 to make that, I think this would be a little pointless as what I have there now does in fact install. And I'd rather keep my machine using Xcode 6.4 so I'm no longer blocked.

I'd be happy to make my app code available to you - even though it is proprietary, it is nothing special, and has no secrets.
Comment 11 Rolf Bjarne Kvinge [MSFT] 2015-09-25 04:52:20 UTC
(In reply to comment #10)
> Given that this is now using Xcode 6.4 to make that, I think this would be a
> little pointless as what I have there now does in fact install. And I'd rather
> keep my machine using Xcode 6.4 so I'm no longer blocked.

Just FYI (no need to do it now): you can have multiple Xcodes installed at the same time (you can download additional ones from Apple's Developer Center, and just put them anywhere on your machine, and then in Xamarin Studio's preferences you can select which ones you want used).

> 
> I'd be happy to make my app code available to you - even though it is
> proprietary, it is nothing special, and has no secrets.

OK, I can try on the devices I have and see if I can reproduce if you make your project available.
Comment 12 Dani 2015-10-06 10:16:31 UTC
We have the same issue with an iPhone 4 (none S).
changing to ARMV7 only resolves the problem, but isnt a solution.

i can not share the project code but be happy to assist in other forms if possible
Comment 13 Rolf Bjarne Kvinge [MSFT] 2015-10-07 08:26:55 UTC
@Dani, which iOS version does you device have?
Comment 14 Dani 2015-10-07 08:57:09 UTC
Version 7.1.2 (11D257)
Model MC605FD/A
Comment 15 Rolf Bjarne Kvinge [MSFT] 2015-10-07 09:03:02 UTC
@Dani, you zip up your .app (or create an .ipa) and share that with us?
Comment 16 Tim Penhey 2015-10-17 21:23:19 UTC
@Rolf, sorry for the slowness in getting back, but work got in the way.

I've pushed the app to https://github.com/howbazaar/kawaw-app

This worked for me on the Xcode 6.4 and my test iPhone 4, but failed with Xcode 7 and the same device.

I didn't know you could have multiple versions of Xcode on a mac, and I'd love to have both the old and new so I can move to Xcode 7 when this issue is fixed.

I'm assuming that if I just use the apple upgrade process, it will move Xcode 6.4 to 7, but how do I install a copy of 6.4 along side?  I already have the .dmg downloaded.
Comment 17 Rolf Bjarne Kvinge [MSFT] 2015-10-19 04:39:17 UTC
@Tim, just open the .dmg in Finder, and move the Xcode.app anywhere on your machine. Once it's on your machine, you can rename it and move it into /Applications if you wish (but don't rename/move it after you've opened Xcode once, since Xcode can become confused and strange things start happening).

Then you can select which Xcode version you want to use in Xamarin Studio's preferences.
Comment 18 Rolf Bjarne Kvinge [MSFT] 2015-10-19 05:34:34 UTC
I tried with my iPhone 6s (iOS 9), and the project worked just fine.

@Alex, do you have an iPhone with iOS 7.1.2 you can try and see if you can reproduce this bug?
Comment 19 Alex Soto [MSFT] 2015-10-20 21:01:03 UTC
@Rolf I was able to deploy to an iPhone 4 with iOS 7.1.2 just fine [1][2]

[1]: https://www.dropbox.com/s/zup6gu91wkpay0j/Bug34092_1.jpg
[2]: https://www.dropbox.com/s/mb9a53sgr6rpm68/Bug34092_2.jpg
Comment 20 Rolf Bjarne Kvinge [MSFT] 2015-10-21 08:18:48 UTC
@Tim, this is turning out somewhat complicated unfortunately, since we're not able to reproduce the problem.

I have a few ideas you can try out though:

* Can you try changing the deployment target (MinimumOSVersion) in your Info.plist to 7.0 (or 7.1) and see if that changes anything? I know Apple's toolchain have different behavior depending on the deployment target, so this might be the reason.
* You mentioned a new Xamarin.Forms project works fine; this is good, because it allows you to figure out exactly what's different between the working and the non-working project. Unfortunately this is a painful process, because you'll have to modify each project to look more like the other one to figure out which difference is the significant one. I believe there's something in the project settings (not the code itself) that's causing problems with Xcode 7 + your device, so you might be narrow it down significantly by removing all the code from the app except the Main function/file, and see if that works.
Comment 21 Rolf Bjarne Kvinge [MSFT] 2016-06-07 08:13:11 UTC
We have not received the requested information. If you are still 
experiencing this issue please provide all the requested information 
and re-open the bug report. Thanks!
Comment 22 Tim Penhey 2016-07-11 21:48:16 UTC
Sorry for not getting back. It appears it was an XCode issue. The next time I tried things after updating XCode it all worked again.