Bug 30954 - Can't install app to simulator from command line using xcrun if .app file was built with xbuild.
Summary: Can't install app to simulator from command line using xcrun if .app file was...
Status: VERIFIED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: MSBuild ()
Version: XI 8.10
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-06-09 17:17 UTC by Jon Goldberger [MSFT]
Modified: 2015-08-04 08:23 UTC (History)
6 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:
VERIFIED ANSWERED

Description Jon Goldberger [MSFT] 2015-06-09 17:17:19 UTC
## Description

If I build a .app file from Xamarin Studio and then deploy it to the simulator using xcrun in terminal, it works fine. However doing the same after building with build does not install the app to the simulator, but rather generates this error:

>An error was encountered processing the command (code=22):
>Failed to install the requested application
>The bundle identifier of the application could not be determined.
>Ensure that the application's Info.plist contains a value for CFBundleIdentifier.

I confirmed that the Info.plist file is in the app bundle and that a bundle identifier is set in the Info.plist file. 


## Steps to reproduce

1. Open Xamarin Studio (Mac) and create a new Unified SingleView iOS app project.

2. Open Terminal and build the solution with xbuild (of course replace /path/to/*.sln with the actual path):
>xbuild /path/to/solutionfile.sln /p:Configuration=Debug /p:Platform=iPhoneSimulator

3. After project successfully builds, deploy it to the simulator with xcrun:
>xcrun simctl install booted -v /path/to/appfile.app 

Expected result: App will be deployed to the simulator.

Actual result: App is not deployed, error noted above is generated. 

## Notes

If I build the app with Xamarin Studio, then deploying with xcrun works as expected. 

## My Environment

=== Xamarin Studio ===

Version 5.9.3 (build 1)
Installation UUID: 2dc9022f-f9a8-424f-8284-bf224cbbfde0
Runtime:
	Mono 4.0.1 ((detached/ed1d3ec)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400010044

=== Xamarin.Android ===

Version: 5.1.3.1 (Business Edition)
Android SDK: /Users/apple/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 6.3.2 (7718)
Build 6D2105

=== Xamarin.iOS ===

Version: 8.10.1.64 (Business Edition)
Hash: e6ebd18
Branch: master
Build date: 2015-05-21 21:55:09-0400

=== Xamarin.Mac ===

Version: 2.0.1.64 (Business Edition)

=== Build Information ===

Release ID: 509030001
Git revision: 5a524e1726ed103fdd4fe37e0356f2b35466ce9d
Build date: 2015-06-02 16:35:08-04
Xamarin addins: 51957cfbd06be911b212671ad05c2c6221ac90f9

=== Operating System ===

Mac OS X 10.10.3
Darwin Jons-iMac.local 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
Comment 3 Ruben Macias 2015-06-10 11:15:24 UTC
Hi I'm the original reporter of this issue.  I'd also like to add the following:

When I compile and deploy the app to the Simulator using Xamarin Studio (It must be deployed by Xamarin Studio), the resulting *.app Package is roughly about 5MB larger than when it is build by using the xbuild command line tool.  It seems like XS is adding some additional files in order for the .app Package to work on the simulator.
Comment 4 Ruben Macias 2015-06-10 11:18:41 UTC
Also, here are the relavant error logs from the Simulator.log file when the app is attempting to install:

Jun  9 12:01:02 macworkstation2000.usa.cinemark.com CoreSimulatorBridge[26858] <Warning>: LaunchServices: installing app for existing placeholder LSApplicationProxy: com.cinemark.cinemarkapp
Jun  9 12:01:02 macworkstation2000.usa.cinemark.com CoreSimulatorBridge[26858] <Warning>: LaunchServices: Not creating progress for LSApplicationProxy: com.cinemark.cinemarkapp since it is not a placeholder.
Jun  9 12:01:02 macworkstation2000.usa.cinemark.com installd[26851] <Notice>: 0xb0093000 handle_install_for_ls: Install of "/Users/rmacias/Desktop/CinemarkiOS.app" requested by CoreSimulatorBridge
Jun  9 12:01:02 macworkstation2000.usa.cinemark.com installd[26851] <Notice>: 0xb0093000 MobileInstallationInstall_Server: Installing app com.cinemark.cinemarkapp
Jun  9 12:01:02 macworkstation2000.usa.cinemark.com installd[26851] <Error>: 0xb0093000 copy_entitlements_for_path: Unable to load entitlements from "/Users/rmacias/Library/Developer/CoreSimulator/Devices/6E7E06F6-DF5F-4B3C-A47C-8380690BADCD/data//tmp/install_staging.n67DiY/CinemarkiOS.app/CinemarkiOS": No such file or directory
Jun  9 12:01:02 macworkstation2000.usa.cinemark.com installd[26851] <Error>: 0xb0093000 postflight_application_install: Could not chmod /Users/rmacias/Library/Developer/CoreSimulator/Devices/6E7E06F6-DF5F-4B3C-A47C-8380690BADCD/data/Applications/E732A6AF-2AEA-4785-AEF0-5F8B5C6CA66E/CinemarkiOS.app/CinemarkiOS: No such file or directory
Jun  9 12:01:02 macworkstation2000.usa.cinemark.com installd[26851] <Error>: 0xb0093000 Can't stat /Users/rmacias/Library/Developer/CoreSimulator/Devices/6E7E06F6-DF5F-4B3C-A47C-8380690BADCD/data/Applications/E732A6AF-2AEA-4785-AEF0-5F8B5C6CA66E/CinemarkiOS.app/CinemarkiOS: No such file or directory
Jun  9 12:01:02 macworkstation2000.usa.cinemark.com installd[26851] <Error>: 0xb0093000 stat /Users/rmacias/Library/Developer/CoreSimulator/Devices/6E7E06F6-DF5F-4B3C-A47C-8380690BADCD/data/Applications/E732A6AF-2AEA-4785-AEF0-5F8B5C6CA66E/CinemarkiOS.app uid=1985043449 gid=1900482101 p=40755
Jun  9 12:01:02 macworkstation2000.usa.cinemark.com CoreSimulatorBridge[26858] <Error>: 0xb0093000 MobileInstallationInstallForLaunchServices: failed with -1
Jun  9 12:01:02 macworkstation2000.usa.cinemark.com CoreSimulatorBridge[26858] <Warning>: ERROR: MobileInstallationInstallForLaunchServices returned nil
Jun  9 12:01:02 macworkstation2000.usa.cinemark.com installd[26851] <Error>: 0xb0093000 perform_recoverable_install: Could not postflight application install
Jun  9 12:01:02 macworkstation2000.usa.cinemark.com installd[26851] <Notice>: 0xb0093000 MobileInstallationInstall_Server: Staging: 0.16s; Waiting: 0.00s; Installation: 0.01s; LS Sync: 0.00s; Overall: 0.17s
Jun  9 12:01:02 macworkstation2000.usa.cinemark.com lsd[26864] <Warning>: LaunchServices: Currently 0 installed placeholders: (
	)
Comment 5 Rolf Bjarne Kvinge [MSFT] 2015-06-11 16:51:24 UTC
This happens when the project specifies a fat (x86+x86_64) architecture for the simulator. In this case we'll build something that's not a valid .app, but which is turned into a valid app when we launch it in the simulator.

The fix is to build an app with a single architecture - just select either x86 or x86_64 in the project's iOS Build options (on the Advanced page).
Comment 6 Ruben Macias 2015-06-11 17:12:36 UTC
Excellent Rolf!  That did the trick!  Thank you!
Comment 7 Saurabh 2015-08-04 08:23:35 UTC
As per comment#5 and comment#6, changing the status to VERIFIED.