Páginas

Mostrando las entradas con la etiqueta xamarin. Mostrar todas las entradas
Mostrando las entradas con la etiqueta xamarin. Mostrar todas las entradas

fastlane snapshots and xamarin

As you all know, fastlane is the easiest way to automate beta deployments and releases for your iOS and Android apps. It handles all tedious tasks, like generating screenshots, dealing with code signing, and releasing your application.You can use fastlane snapshots  to automate the process of capturing screenshots of your app. It allows you to:
  • Capture hundreds of screenshots in multiple languages on all simulators
  • Take screenshots in multiple device simulators concurrently to cut down execution time (Xcode 9 only)
  • Do something else while the computer takes the screenshots for you
  • Configure it once, and store the configuration so anyone on the team can run it
  • Generate a beautiful web page showing all screenshots on all devices. This is perfect to send to Q&A, marketing, or translators for verification
  • Avoid having loading indicators in your App Store screenshots by intelligently waiting for network requests to be finished
  • Get a summary of how your app looks like across all supported devices and languages
Here https://docs.fastlane.tools/getting-started/ios/screenshots/  you have all the necessary information to take the best screenshots you need.

Unfortunately for Xamarin users, snapshots uses UITests, which require an Xcode project so, Is there anything we can do to use snapshots with our Xamarin projects? 

The answer is short, YES YOU CAN!!!

Setting up you XCUITest project

UITest  does not use the project code to test, it exists outside the app. UITest instead looks at what is available in the simulator and returns to us instances of XCUIElement based on what it finds, XCUIElement and XCUIApplication are the proxies that are used for this.

So you only need to open XCode, go to FILE --> NEW --> PROJECT and select SINGLE VIEW APP, click the NEXT button and on the next screen, the most important thing, is that you check "INCLUDE UI TEST".
 

Now you have almost ready, just follow this information https://docs.fastlane.tools/getting-started/ios/screenshots/ to configure your project.

Xamarin app? How?

As explained here https://medium.com/xcblog/hands-on-xcuitest-features-with-xcode-9-eb4d00be2781 now XCUIApplication() has initialiser which takes bundleIdentifier so that we can pass bundleID of our app and has new activate() method to activate app from background. 

As you can see, you can interact with any app within Simulator or device as long as we know bundle identifier. This is huge improvement in UI testing of iOS apps. 

Guess what? You can interact with you Xamarin app as far as it's deployed in the simulator! You can install your Xamarin in the simulator as normal, I mean, just hitting the PLAY / DEBUG button on your Visual Studio for macOS.

Automate everything

But what if you can automate you Xamarin iOs deployment? I also have the answer! 

To install an iOs app from the command line you can use this command: xcrun simctl install

Where
  1. device can be the device UUID, its name, or booted which means the currently booted device
  2. path is the path of your .app. 

Get simulator device UUID

To get all your devices UUID, execute this command: xcrun instruments -s devices

For more information please visit https://developer.xamarin.com/guides/testcloud/calabash/working-with/identifying-ios-devices-and-simulators/ 

Get the path of your .app

It's in your build folder pathToYourAppSourceCode/bin/iPhoneSimulator/Debug/device-builds/iphone[build ios version]/appName.app. In case of my hypstr app, the location is here

Tying everything up

Create a bash script to automate app deploy to all your selected simulators (https://www.macobserver.com/tmo/article/os-x-how-to-convert-a-terminal-command-into-a-double-clickable-desktop-file)

eg:

#!/bin/bash

echo booting iphone 6 simulator
xcrun simctl boot E26FC3E7-DF91-49DF-AE9D-3A7443B849AD

echo deploying app
xcrun simctl install E26FC3E7-DF91-49DF-AE9D-3A7443B849AD pathToYourAppSourceCode/bin/iPhoneSimulator/Debug/device-builds/iphone[build ios version]/hypstr.UI.iOs.app

echo shutdown simulator
xcrun simctl shutdown E26FC3E7-DF91-49DF-AE9D-3A7443B849AD


More info on ios simulator commands https://medium.com/xcblog/simctl-control-ios-simulators-from-command-line-78b9006a20dc

As only these screens are needed for iPhone when submitting to App Store, just create the script to deploy to this four simulator:
  1. iPhone 7 Plus (5.5-Inch)
  2. iPhone 7 (4.7-Inch)
  3. iPhone 5 (4-Inch)
  4. iPhone X
Those simulators are the ones you need to specify in you Snapfile (snapshots config file)

Magic, magic, magic! 

Following this approach, I manage to take my screeshots for my Xamarin app called hypstr published in the App Store https://itunes.apple.com/us/app/hypstr/id650216315 using fastlane snapshots as you can see in the following image


Enjoy!

More info about fastlane, snapshots and XCUITest:




Native iOS & Android Development for the C# Developer with Xamarin

En este curso de 4 días se intentará dar un pantallazo general sobre el mundo mobile, su distribución a nivel mundial, tips sobre que hace especial a esta plataforma y una introducción a Xamarin para el desarrollo de aplicaciones nativas tanto en Android como iOs.

El objetivo del curso, es que quienes participen sean capaces de entender todo lo que engloba al desarrollo mobile, y aquello que va más allá de la pantalla del mobile device.

Me quedan subir varios links con los videos y los archivos con  los materiales, ya los ire subiendo pero mientras tanto acá tiene las presentaciones

Xamarin iOS - apply gradient background to status bar and navigation bar

Here you have a running sample on  how to apply gradient background to status bar and navigation bar to Xamarin iOS https://github.com/vackup/StatusBarGradientBackground/



Info used:
How can I create a horizontal gradient background for my iOS nav bar?
http://stackoverflow.com/a/31901915/580229

Using Background Image in Navigation Bar
https://www.appcoda.com/customize-navigation-status-bar-ios-7/

How to programmatically get iOS status bar height
http://stackoverflow.com/a/16598350/580229

Configure Xamarin.iOs build on TFS


Build agent

First of all, you need to install the cross platform build and release agent for Team Services and Team Foundation Server 2015 and beyond on a mac.

I think the easiest way to do that is to you MacInACloud service (https://support.macincloud.com/support/solutions/articles/8000016614-getting-started-with-the-macincloud-vsts-build-agent-plan) but if you don't want to pay for the service and have a Mac, you must install it there.

Install Prequisites

First, ensure you have the necessary OSX (macOs) system prequisites (https://github.com/Microsoft/vsts-agent/blob/master/docs/start/envosx.md) - basically OpenSSL, Git and other stuff. You will need BREW (http://brew.sh/), so visit Brew website for install instructions

Installing OpenSLL, if the following lines doesn't work, check the installed version and use it instead of 1.0.0

ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib

Deploy an agent on OSX

After installing all prequisites, you need to install the agent.


You must configure it and run it (don't forget to run it LOL), pretty straightforward.

If everything is OK you shoul see you Build Agent is green, if it is red, then something went wrong

image

Creating the build

Now you have go to your TFS and create a new Xamarin.iOS. To create it follow these instructions https://www.visualstudio.com/docs/build/apps/mobile/xamarin

Troubleshooting

If you have any issues, visit these url for troubleshooting info:

Can't connect to TFS when configuring the agent

User permissions

If you face issues with user permissions:
  1. Creation issues: To create the agent, the user must be part of "Agent Queue Administrator"
  2. Execution issues "Tfs2015 Build agent error: Access denied: xxxxx\yyyyy needs Listen permissions for pool zzzzz to perform the action": To run the agent, the user must be part of "Agent Queue Users" and not "Agent Queue Administrator". This is the (http://www.codewrecks.com/blog/index.php/2015/05/09/tfs2015-build-agent-error-access-denied-xxxxxyyyyy-needs-listen-permissions-for-pool-zzzzz-to-perform-the-action/)
  3. Can't select a build queue during build definition - TFS 2015 Build’s Queue is Empty: your user doesn't have permissions to execute the queue and needs to be part of "Agent Queue Users" (https://lajak.wordpress.com/2016/03/24/fix-tfs-2015-builds-queue-is-empty/)
  4. I use Team Foundation Server on-premises and I don't see some of these features. Why not? Some of these features are available only on Visual Studio Team Services and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS. Check the available features on each version here https://www.visualstudio.com/de-de/docs/build/define/build (eg: at the time of writting this post "Xamarin component restore" is only available on Team Services)

iOS Backgrounding and Updating an Application in the Background


iOS Backgrounding with Tasks

Run tasks that don't have to die when app enters background
  • Creating Background-Safe Task: You can use this pattern anywhere in your application where you don't want a task being interrupted should the user put the app into the background. A great candidate for this pattern would be tasks such as sending a new user's registration information to your server, or verifying login information. 
https://developer.xamarin.com/guides/ios/application_fundamentals/backgrounding/part_3_ios_backgrounding_techniques/ios_backgrounding_with_tasks/#background_tasks_in_ios7

Updating an Application in the Background

Update the app at regular intervals
  • Region Monitoring and Significant Location Changes Service 
  • Background Fetch 
https://developer.xamarin.com/guides/ios/application_fundamentals/backgrounding/part_3_ios_backgrounding_techniques/updating_an_application_in_the_background/#background_fetch

iOS Backgrounding Guidance

Refer to the following diagram to choose a backgrounding technique
https://developer.xamarin.com/guides/ios/application_fundamentals/backgrounding/part_5_ios_backgrounding_guidance/

iOs7


Multi Platform implementation (Xamarin.Form)

Using Messanger
http://arteksoftware.com/backgrounding-with-xamarin-forms/ 

Xamarin.iOs Unified API - Methods missing in NSUrlConnectionDelegate

I had the same problem as described here http://forums.xamarin.com/discussion/31355/methods-missing-in-nsurlconnectiondelegate, I was in the middle of migrating my app hypstr (www.hypstrapp.com) to the Unified API.

The problem occurs with the NSUrlRequest, which requires an instance of INSUrlConnectionDelegate, where prior to the Unified API I was using NSUrlConnectionDelegate.

Udating my library to Unified API a couple of methods I was using before are missing. Namely ReceivedData(NSUrlConnection, NSData) and FinishedLoading(NSUrlConnection).

The solution is here  https://github.com/Cheesebaron/Cheesebaron.MvxPlugins/commit/8e57a7cb53f8ec575ad9c48e478e7ab44bcb93a0#diff-d0b47785af23a5a11abceed2acd46b00R131, you should now inherite form NSUrlConnectionDataDelegate instead of NSUrlConnectionDelegate

And that's all :)

ENJOY

Consuming OData Service with Xamarin Android

I'll show you a simple way of consuming OData Service with Xamarin Android

For those who don't know, OData is a standardized protocol for creating and consuming data APIs. OData builds on core protocols like HTTP and commonly accepted methodologies like REST. The result is a uniform way to expose full-featured data APIs.

We will use Simple.OData.Client. Simple.OData.Client is a multiplatform OData client library supporting .NET 4.x, Silverlight 5, Windows Phone 8, Android and iOS. The adapter provides a great alternative to WCF Data Services client. It does not require generation of context or entity classes and fits RESTful nature of OData services. The adapter has a NuGet package that can be installed from NuGet site.

Open Visual Studio and go to FILE --> NEW --> PROJECT and choose "Android Application"


This will open a new Android Application template.

As the "Getting started with Simple.OData.Client" article says, the easiest way to start using Simple.OData.Client is to install it’s Nuget package.

Now open the default activity file (Activity1.cs) and copy this code (NOTE that we have changed the inheritance activity from Activity to ListActivity).

What we are doing here is:
  1. On the OnCreate mehod, we just have initialized the ODataClient (client = new ODataClient("http://packages.nuget.org/v1/FeedService.svc/");)
  2. Then we have started an async task, so we dont block the UI, with method StartRestRequestAsync
  3. Last, we query the service client.FindEntries("Packages?$filter=Title eq 'Simple.OData.Client'"); iterate their result and add it to the ListAdapter
You can download a sample from https://bitbucket.org/hzaldivar/odataandroid