Showing posts with label Xamarin. Show all posts
Showing posts with label Xamarin. Show all posts

Wednesday, December 16, 2015

Error ITMS-90047: Disallowed paths ("iTunesArtwork,"iTunesMetadata.plist") found at: App Name

Problem:

I upgraded to dev environment to the latest versions of XCode 7.2 and Xamarin iOS 9.2.  
I have been unable to build a production ipa file in Visual Studio or Xamarin Studio.  

I am focusing on getting the Xamarin Studio solution to work before proceeding to Visual Studio.   

XS will build in simulator or deploy to local phone.  It will compile and build the ipa for release but when I go to the application loader.  The ipa fails to load to the store.


Build Case to get the error:
  1. XS right-click and build on iPhone project.
  2. Dig the ipa out of the bin directory.
  3. Launch Application Loader
  4. Load ipa into loader
  5. Click Send    

Solution:

What I have been able to do successfully is to follow the directions provided by Xamarin here Xamarin Studio: http://developer.xamarin.com/releases/studio/xamarin.studio_5.9/xamarin.studio_5.9/#Publishing_Workflow

The publish to archive option will build an ipa file which the application loader will accept.  This is a workaround until I can determine what is going on.

Source:
  1. https://forums.xamarin.com/discussion/comment/123046#Comment_123046
  2. https://forums.xamarin.com/discussion/40388/disallowed-paths-itunesmetadata-plist-found-at-when-submitting-to-app-store/p1
  3. http://forums.xamarin.com/discussion/50979/error-itms-90475-invalid-bundle-ipad-multitasking-support-requires-launch-story-board-in-bundle
  4. https://forums.xamarin.com/discussion/40338/ios-archive-submissions-failed-with-errors-disallowed-paths-itunesmetadata-plist

Kill a running iPhone App

Problem:

We had a situation in an app where the user should not be able to proceed without accepting a condition.  We had the view prompt them when they chose to exit.  The method called Thread.Abort() which lead to an error report.

Solution:

Using the System library, call the CloseMainWindow().  This will gracefully kill the app and return control back to the base OS.

system.diagnostics.process.getcurrentprocess().CloseMainWindow()

Source:

http://forums.xamarin.com/discussion/12026/close-an-application-programmatically
http://stackoverflow.com/questions/3622120/monotouch-reuse-uialertview

Friday, August 28, 2015

Android SDK Tools (rev. 24.3.4) breaks Xamarin.Designer downgrade for Visual Studio

Problem:


Google has released a new version of Android SDK Tools (rev. 24.3.4). This version breaks the Xamarin.Android designer.

How to downgrade?

Downgrade steps

  1. Close ALL instances of Visual Studio and/or Xamarin Studio
  2. Locate the tools directory in the Android SDK path. One way to find the right directory is to open "Tools -> Open Android SDK Manager" in Xamarin Studio or "Tools -> Android -> Android SDK Manager" in Visual Studio. The tools subdirectory can be found within the "SDK Path" that is displayed at the top of the SDK Manager window.
  3. Delete the tools directory.
  4. Unzip the tools_r24.3.3*.zip file into the "SDK Path", creating a directory named "tools". Be careful not to create an extra outer "tools" directory when unzipping this file: the top-level "SDK path" should contain tools/android*, not tools/tools/android*.

Downgrade links

Windows
Mac
Source:
http://forums.xamarin.com/discussion/48408/warning-android-sdk-tools-rev-v24-3-4#latest

Monday, August 17, 2015

MVVMCross Core solution throws error - Unhandled managed exception

Problem:

I just completed the Windows Phone UI project for an MVVMCross solution.  The core project is used by iPhone and Windows Phone UI.  Upon completion of testing for WP, I decided to run a few tests against iPhone which I had completed earlier.  I was immediately confronted with an error -

"An Unhandled exception occurred"

The Xamarin log shows the error occurring at load time.  The compiler built out the bits.  The attempt to run in debug did reveal some more interesting leads. 

[3641:134567] Unhandled managed exception: Could not load file or assembly 'Windows' or one of its dependencies.  The system cannot find the file specified.  (System.IO.FileNotFoundException)

I continued to play around with the changes I had made to the Core PCL.  Then I found the issue.

Solution:

In the course of building the Windows Phone project I used the LongListSelector. This Windows Phone control has several dependcies which are specific to Windows Phone.  The Core PCL included some code which depended on the library Microsoft.Phone.dll.  This reference is not compatible with the Monotouch framework.  My code worked fine when I compiled to Windows Phone but as soon as I tried to run the exe to Monotouch I raised the error. 

My solution was to surround the code with conditional compilation commands

#if USE_MVVMCROSS_WP8

....

#endif

Source:
http://typecastexception.com/post/2012/08/18/Visual-Studio-Use-Conditional-Compilation-to-Control-Runtime-Settings-for-Different-Deployment-Scenarios.aspx

Thursday, July 16, 2015

ERROR: ERROR ITMS-90047: "Disallowed paths ( "iTunesMetadata.plist" ) found at: MyNewTool.app"

Solution:

For command line or IDE builds with XamarinVS
  1. Ensure "Project Properties -> iOS IPA Options -> Include Artwork in IPA" is not checked. (Or manually set the BuildIpa and IpaIncludeArtwork properties as mentioned above.)
    image
  2. Build the app.
  3. Submit the .ipa file using Application Loader.
or

<Target Name="_CompileITunesMetadata" DependsOnTargets="_DetectSdkLocations;_DetectAppManifest;_GenerateBundleName;_CompileAppManifest">
  <Message Text="Skipping CompileITunesMetadata task to prevent inclusion of iTunesMetadata.plist in the IPA" />
</Target>


Source:
  1. https://forums.xamarin.com/discussion/40388/disallowed-paths-itunesmetadata-plist-found-at-when-submitting-to-app-store/p1
  2. https://discussions.apple.com/thread/6997898?start=0&tstart=0
  3. https://bugzilla.xamarin.com/show_bug.cgi?id=29180#c0

Friday, June 26, 2015

How to add strikeout/strikethrough to an UITextView

Problem
Had a number of UITextView controls on my Xamarin/C# screen.  Customer asked for one of them to be underlined.  I was unsure of how to accomplish this.

Solution
Fortunately, Guillermo over at Xamarin Forums had a similar solution for UILabel.  Here is my reworked solution.

UITextView aboutTextView = new UITextView(new RectangleF(30,225,280,80));
aboutTextView.TextColor = UIColor.Black;
var attrString = new NSAttributedString("The Text", underlineStyle: NSUnderlineStyle.Single);
aboutTextView.AttributedText = attrString;
aboutTextView.Font = UIFont.SystemFontOfSize(14.0f);
Add(aboutTextView);



Source:
http://forums.xamarin.com/discussion/11584/how-to-add-strikeout-strikethrough-to-an-uilabel

Thursday, May 7, 2015

How to Wrap Text in a Monotouch/Xamarin UILabel

Doing some UI work on our iPhone app and still trying to remember what the UI supports.
I had an issue with how to wrap text in a UILabel field.  Fortunately, Xamarin forums has some great recipes.

What I needed was (UILineBreakMode.WordWrap)

Solution

var descriptionField = new UILabel(new RectangleF(10, 45, 300, 140));
descriptionField.LineBreakMode = UILineBreakMode.WordWrap;
descriptionField.Lines = 10;
descriptionField.BackgroundColor = UIColor.Gray;
Add(descriptionField);


Source:
http://developer.xamarin.com/recipes/ios/standard_controls/labels/uilabel-truncate-wrap-text/

Tuesday, April 21, 2015

Navigation Bar customization iOS (NavigationItem.SetRightBarButtonItems)

Working an issue on a project.  We needed to modify the navigation bar in iOS.
I was not sure how to do this but turns out we can use the NavigationItem class in the MonoTouch library. 

var btnEmail = new UIBarButtonItem(UIImage.FromFile("image/mail.png"),UIBarButtonItemStyle.Plain, (s,e) => {});
NavigationItem.SetRightBarButtonItems(new UIBarButtonItem[] { btnEmail}, true);


Source:
  1. http://forums.xamarin.com/discussion/16413/navigation-uibarbuttonitem-creation

Friday, March 13, 2015

MVVMCross iOS: How to trigger RowSelected Table View?

I was struggling with how to raise an MVVM event on a click within a tableview.
Fortunately, Stuart Lodge has come through with a great demo of how this all works.
His N+17 video about 47 minutes in gives the details for iOS.  He also has a demo
in his MVVM samples library.  I lifted the pertinent code out of the repo.  The key is to bind
your MVVM command to the SelectionChangeCommand which is a property of the TableView
row item.

Sample:

ModelView:

new Cirrious.MvvmCross.ViewModels.MvxCommand<DilbertItem>((dilbertItem) =>
{   
// note that we can only pass an id here - do *not* serialiase the whole dilbertItem ShowViewModel<DilbertDetailViewModel>(new { id = dilbertItem.Id });
});


View:

// binding
set.Bind(source) .For(s => s.SelectionChangedCommand) .To(s => s.ShowDetailCommand);



Source:
N=17 https://www.youtube.com/watch?v=h0Eww89c9DM&feature=youtu.be&t=47m30s

http://stackoverflow.com/questions/17712589/mvvmcross-ios-how-to-trigger-rowselected-on-a-custom-tableviewsource-using-crea

Wednesday, December 10, 2014

Invalid IL code in system.xml.linq.xdocument:Parse (string): method body is empty

Working on getting a iPhone application off the ground.  We are using Xamarin/Monotouch and MVVMcross to build a cross platform solution.  The PCL does not support File.IO namespace so using some excellent posts about IoC.

Problem:

An issue cropped up in my attempts to get my example working.  I have the xml file being rendered in the iOS project of the solution.  The Interface is stored in the PCL and it compiles and runs.  But when I hit the line in the iOS project

doc = XDocument.Parse(DefaultData);

I got the runtime error:
Invalid IL code in system.xml.linq.xdocument:Parse (string): method body is empty

Solution:

The iOS project is using the Monotouch namespace which includes its own copies of the common
.Net dlls.  It appears that the namespaces for the non mono projects were included as references for the iOS project.  This meant that the source code would compile without errors.  The dll in question was System.XML.dll.  I dropped the reference to this dll and added in the correct mono dll and that removed the IL error.


Wrong System.XML.dll file

Program Files(x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.XML.dll

vs.


Correct System.XML.dll

Program Files(x86)\Reference Assemblies\Microsoft\Framework\MonoTouch\v1.0\System.XML.dll

Friday, October 17, 2014

Randomize boolean method in C#

I just saw this slick little trick in a Xamarin class.  Instructor needed to have a sample class randomly return a true or false. 

This is so simple:

public bool IsTrue()
{
return new Random().Next() % 2 == 0;
}

Monday, September 29, 2014

Xamarin Error:No valid iOS code signing keys found in keychain

Problem:

I got this lovely error when trying to do my hello world program.  I just managed to complete the configuration of our development network and needed to test the iPhone compilation within Visual Studio.

When I went to build I got this error: No valid iOS code signing keys found in keychain

After some research, I found the Xamarin forums quite helpful and located this guide:
http://docs.xamarin.com/guides/ios/getting_started/device_provisioning/

The issue is the compiler on the Mac Host is trying to build out the final package for deployment to an iPhone device.  You need to register with as an Apple developer to do that.  Forunately or Unfortuantely, we are not ready to do that just yet with our App.

My issue was why can't I run the emulator in Visual Studio?

Solution:
  1. Right-click the Standard toolbar (the one which has the current configuration drop-down saying Debug, Release etc) and choose Customize… from the menu:
    [ ]
  2. Switch to the Commands tab.
  3. Select the Toolbar radio button
  4. Select the Standard toolbar in the list to the right of the radio button
  5. Scroll down the Controls widget till you see the Solution Configurations widget and select it
  6. Click the Add command... button:
    [ ]
  7. Choose the Build category
  8. Choose the Solution Platforms command and click OK :
    [ ]
  9. Click Close




Source:
http://developer.xamarin.com/guides/ios/getting_started/installation/windows/



Friday, September 26, 2014

Xamarin Error 429 - clocks not synced

I am building out a disconnected network for our VS/Xamarin iOS build environment. 

Problem:
I have successfully paired the Mac and Windows boxes on our local network.  I noted that there is a discrepancy in the clocks between the two machines.  How to fix this problem.

Solution:
Make your Mac the time server

  1. Unload the current npd daemon.
    • sudo launchctl unload /System/Library/LaunchDaemons/org.ntp.ntpd.plist 
  2. Edit the ntp-restrict.conf
    • /etc/ntp-restrict.conf
    • Remove the “noquery” from the 1st two restrict lines:
  3. Now load the npd file again
    • sudo launchctl load /System/Library/LaunchDaemons/org.ntp.ntpd.plist
  4. Test npd to ensure it is running
    • sudo ntpdate -u localhost
On your Windows PC
  1. Open Date and Time Dialog
  2. Select the Internet time tab
  3. Change Settings
  4. Select Synchronize with and Internet time server.
  5. Place the IP Address of the Mac you are using as the time server (192.168.0.100) in the Server block
  6. Update Now
  7. OK
Now
  1. Open up command window as admin
  2. type in command: w32tm /config /manualpeerlist:192.168.0.100 /syncfromflags:MANUAL
 Now the windows box will sync its time with the Mac box and should not have the 429 errors any longer.


Source
http://macmule.com/2013/12/15/how-to-use-osx-server-as-a-time-server/

The remote server returned an error: 429 (Xamarin Visual Studio iOS error 429)

Problem:
VS not working (The remote server returned an error: 429)

Solution:
My clocks were off by one hour inspite of showing the same time.  The windows box had an incorrect setting for the timezone UTC+1.  It had been manually advanced by one hour.  This meant that the times between the Windows box running VS and the Mac Host had a difference of 1 hour.
Anything over 3 minutes will throw an error in the compiler.






http://forums.xamarin.com/discussion/17062/vs-not-working-the-remote-server-returned-an-error-429

Tuesday, September 23, 2014

Installing Xamarin.iOS on Windows

Xamarin site has great how to guides for installing their product for use with Visual Studio.
We are writing our first iPhone app using C#, Xamarin and Mvvmcross.




How to install:

http://developer.xamarin.com/guides/ios/getting_started/installation/windows/#Connecting_to_the_Mac_Build_Host

Wednesday, September 10, 2014

iPhone development in C#

Starting a project to develop an iPhone application.  We are going to pursue a cross platform solution using Xamarin software.  This should allow us to write the core processes in C# and deploy UIs specific to the platform we are targeting.  In order to get the most out of the design, we are going to use the MVVM pattern.  MVVMCross is a github project which used in concert with Xamarin software will allow us to write C# for both back end and UI.

This promises to be an exciting project.  We currently have 2 versions of the application written (WP8, Android).  These were done without the benefit of this approach and will at some point be migrated to this pattern. 

Wednesday, September 3, 2014

MVVMCross - Could not install package 'MvvmCross.PortableSupport 3.1.1'.

MVVM Cross nuget package 3.1.1 with VS 2012 SP2 not working

Error:

Could not install package 'MvvmCross.PortableSupport 3.1.1'. You are trying to install this package into a project that targets 'portable-net45+sl40+wp+win', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Explanation:

The problem is that MvvmCross.PortableSupport 3.1.1 has a portable class library that targets:
portable-win+net45+sl50+wp8+MonoAndroid+MonoTouch
Whilst your portable class library project is targeting:
portable-win+net45+sl40+wp71
The MonoAndroid and MonoTouch frameworks are optional and will not be used in the comparison if you are using NuGet 2.7.2 or above. Your project is targeting Silverlight 4.0 and Windows Phone 7.1 whilst MvvmCross.Portable is targeting Silverlight 5.0 and Windows Phone 8. So it is not compatible. You cannot install a portable class library into a portable class library project that targets older framework versions. You will need to change the profile for your portable class library project so that it targets these frameworks.


Solution:


Option 1:

Target Frameworks
.Net 4.5, Silverlight 5, Windows Phone 8, Windows Store apps (Windows 8)


Option 2:

The workaround mentioned on a comment on Stuart's blog (at http://slodge.blogspot.co.uk/2013/04/n0-first-mvvmcross-application-n1-days.html) worked for me:
Remove Mono for Android, MonoTouch, VS MonoTouch and Windows Phone from the Target Frameworks in the Core project properties. Install MvvmCross NuGet package. Add the Target Frameworks back in.

Wednesday, July 23, 2014

Xamarin and Sole Source justification

Great post by Tim Anderson and Andy Dent about Xamarin vs. other competitors

- Xamarin (+ MVVMCross) ideal cross product solution. https://github.com/MvvmCross/MvvmCross

- The purpose of PhoneGap is to allow HTML-based web applications to be deployed and installed as native applications

- The goal of Titanium Mobile is to provide a high level, cross-platform JavaScript runtime and API for mobile development (today we support iOS, Android, and the browser, with BlackBerry 10 and Windows Phone coming soon and eventually, respectively).


Source:

http://stackoverflow.com/questions/17249500/xamarin-2-0-vs-appcelerator-titanium-vs-phonegap