Is it possible to build an Axway Appcelerator Android app with Product Flavors? - appcelerator

From my tiapp.xml file:
<ti:app xmlns:ti="http://ti.appcelerator.org">
<sdk-version>7.0.1.GA</sdk-version>
<id>com.example.app</id>
This will create and install an app with id com.example.app. But now I need to have installed, side-by-side a beta version. In theory I can change the id and do:
<id>com.example.app.beta</id>
And rebuild.
But I'm wondering if there's some kind of config, like we have with Gradle in Android so I can do:
android {
defaultConfig {
applicationId "com.example.app"
}
productFlavors {
beta {
applicationIdSuffix ".beta"
}
}
Any ideas? Thanks!

Have a look at this repo: https://github.com/yomybaby/dev.tiapp
It is an hook to change things in tiapp.xml
Also search for hook in the Appcelerator documentation to get more information about CLI-Hooks

Related

Unable to Resolve Deprecation of UIWebView warning while uploading Xamarin application

I Have followed the blog https://devblogs.microsoft.com/xamarin/uiwebview-deprecation-xamarin-forms/ to remove the UIWebView dependency in my project.
According to the document
1)xamarin.forms version is 4.6
2)xamarin.ios version is 13.20
3)I added the command in mtouch Arguments and linker is link All
I still got warning while upoading build to test flight
I then followed this document https://learn.microsoft.com/en-us/xamarin/ios/release-notes/13/13.16#help-with-uiwebview-deprecation where we can find out whether UIWebView is still being used in our application.I am getting below in the build output.
MTOUCH : warning MT1502: One or more reference(s) to type 'UIKit.UIWebView' already exists inside 'Xamarin.Forms.Platform.iOS, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' before linking
I am not sure why there is reference in Xamarin.Forms.Platform.iOS as xamarin package is updated to 4.6 as per the blog.
Can anyone please help me to get rid of this warning?
Please follow this link
simply go to your iOS project, open the project properties and add this flag in the
'additional mtouch arguments field: --optimize=experimental-xforms-product-type' in your
Use WKWebView instead of UIWebView. UIWebView has been deprecated and Now The App Store will no longer accept new apps using UIWebView as of April 2020.
using System.IO;
using CustomRenderer;
using CustomRenderer.iOS;
using Foundation;
using UIKit;
using WebKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(CustomWebView), typeof(WebViewRender_iOS))]
namespace CustomRenderer.iOS
{
public class WebViewRender_iOS : WkWebViewRenderer
{
WKUserContentController userController;
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.OldElement != null)
{
userController.RemoveAllUserScripts();
userController.RemoveScriptMessageHandler("invokeAction");
CustomWebView hybridWebView = e.OldElement as CustomWebView;
hybridWebView.Cleanup();
}
if (e.NewElement != null)
{
CustomWebView hybridWebView = e.NewElement as CustomWebView;
LoadRequest(new NSUrlRequest(new NSUrl(hybridWebView._WebURI)));
}
}
}
}
There are a few different changes that need to be made for the deprecation warning to go away.
The build configuration used to upload to the store (Release|iPhone, App Store|iPhone, etc.) in iOS Build section needs the following additional mtouch arguments --optimize=experimental-xforms-product-type
The app needs to use Xamarin.Forms version >= 4.5 or >= 4.6 if using Material Visual
It also needs to be using Xamarin.iOS 13.10.0.17 or higher, which is included with Visual Studio for Mac 8.4.1 and Visual Studio 16.4.3.
Remove all references to UIWebView in the codebase
More info is included in the docs and if that doesn't resolve the issue the app may be using a third-party library with a reference to UIWebView that either needs updating to a version without it or removed altogether from the app.
Thank you all for your suggestions. Below is what worked for me.
Follow the 3 steps mentioned in
https://devblogs.microsoft.com/xamarin/uiwebview-deprecation-xamarin-forms/
Run grep -r UIWebview . on repository level. It will show the list of references in .sln and third party packages
Remove or update third party libraries. Igore bin and obj folders
For Me, I had to
1.Remove deprecated scanbot.xamarin.ios SDK and add scanbot.xamarin pkg
2.Remove hockey app SDK as it was deprecated and didn’t have any updates
3.Remove googleanalytics SDK as it wasn’t being used in the project

Xamarin.Forms targeting macOS

I am using Visual Studio for Mac 7.6.6 to create a Xamarin.Forms app targeting macOS (to be shared with something running on Windows). I create a new Project and select
Multiplatform App | Blank Forms App. Click Next
Configure your Blank Forms App. There are target platforms: Android and iOS.
(There is nothing for macOS). Since I have not installed the build toolkits for either iOS and android, both of these checkboxes are disabled. Therefore the Next button on this wizard page is disabled.
How do I proceed? I assume there is no way to use the New Project wizard for this.
I came across an old post for starting with a Xamarin Cocoa app and using NuGet to put the Xamarin Forms functionality but don't understand the code
LoadApplication(new App()); // <-- don't know what App is
I suspect the VS Mac and Xamarin.Forms are out of sync being on the bleeding edge. Has anyone gotten this to work?
I would suggest following SushiHangover's suggestion since that is simpler which is what you have done already:
Add a new CocoaApp project to your solution.
Install Xamarin.Forms NuGet package into your CocoaApp.
Reference the shared project or .NET Standard project from your CocoaApp project.
Edit info.plist and remove the source entry (NSMainStoryboardFile).
Change the AppDelegate to derive from Xamarin.Forms.Platform.MacOS.FormsApplicationDelegate.
Update Main.cs to initialize the AppDelegate
In the AppDelegate's DidFinishLaunching add the code to initialize Xamarin.Forms.
Create a new NSWindow which should be returned from the MainWindow property in the AppDelegate.
Main.cs:
static class MainClass
{
static void Main(string[] args)
{
NSApplication.Init();
NSApplication.SharedApplication.Delegate = new AppDelegate();
NSApplication.Main(args);
}
}
AppDelegate.cs:
[Register("AppDelegate")]
public class AppDelegate : Xamarin.Forms.Platform.MacOS.FormsApplicationDelegate
{
NSWindow window;
public AppDelegate()
{
var style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;
var rect = new CoreGraphics.CGRect(200, 1000, 1024, 768);
window = new NSWindow(rect, style, NSBackingStore.Buffered, false);
window.Title = "Xamarin.Forms on Mac!";
window.TitleVisibility = NSWindowTitleVisibility.Hidden;
}
public override NSWindow MainWindow
{
get { return window; }
}
public override void DidFinishLaunching(NSNotification notification)
{
Xamarin.Forms.Forms.Init();
LoadApplication(new App());
base.DidFinishLaunching(notification);
}
public override void WillTerminate(NSNotification notification)
{
// Insert code here to tear down your application
}
}
However Visual Studio for Mac does include a Mac project with the Xamarin.Forms project templates. However it does not expose this in the New Project dialog currently. You can create a Mac Forms project from this template but it is a bit more work than what SushiHangover suggested and you have used.
Install the Xamarin.Forms project template into the .NET Core project templates
dotnet new --install "/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/AddIns/Xamarin.Forms.Addin/Templates/Xamarin.Templates.Multiplatform.0.0.1.nupkg"
Create a new Forms project including the Mac project (you may want to review and set other template parameters - the following creates a blank Forms app with Android, iOS, Mac, UWP and a Shared project).
dotnet new forms-app --CreateMacProject -k blank
Create a new blank solution (Other - Miscellaneous - Blank Solution) in the parent directory of the projects you just created.
Add all those projects created to the solution.
Then you can build and run the Mac project which includes Xamarin.Forms.
Note you may want to remove the Xamarin.Forms project template from the .NET Core project templates which you can do by running the following:
dotnet new --debug:reinit
In addition to the approved answer, which is incomplete with recent updates, now you have to do one more step.
Link the delagate in the Mac project main class
main.cs:
static class MainClass
{
static void Main(string[] args)
{
NSApplication.Init();
NSApplication.SharedApplication.Delegate = new AppDelegate();
NSApplication.Main(args);
}
}
nota. My edit was refused and I'm not allowed to add comments. So I added a complementary answer to help those looking for help now.

In which package can I find Xamarin IDevice

I am writing a Xamarin Forms PCL application (both iOS and Android)
I have to pick an image from phone gallery.
I have read some documentation about this plugin:
Labs.Platform.Services.Media.MediaPicker
In my Common project, i have to put this code:
var device = Resolver.Resolve<IDevice>();
picker = DependencyService.Get<IMediaPicker>() ?? device.MediaPicker;
But I have an error on the first line: IDevice and Resolver Objects are not know. I think I am missing a reference or a using clause.
Thanks
You need to install the following Nuget package in all of your projects in the solution (i.e. PCL core project, iOS project, and the Android Project, and UWP project if using it):
https://www.nuget.org/packages/XLabs.Forms/
And you will need to add the following using statements:
using XLabs.Ioc;
using XLabs.Platform.Device;
using XLabs.Platform.Services.Media;

Separate package names for iOS and Android

I currently have a native app published to the App Store and Google Play and both have different package names. I was wanting to know if there is there a way to tell NativeScript to use a one package name for iOS and a different one for Android? Thank you.
Yep, you can absolutely do that. For iOS, include a CFBundleIdentifier flag in your app/App_Resources/iOS/Info.plist file.
<key>CFBundleIdentifier</key>
<string>com.mycompany.myapp</string>
And for Android, update the android.defaultConfig.applicationId in your app/App_Resources/Android/app.gradle file. See https://github.com/NativeScript/template-hello-world/blob/90b81bcb772ab21a06f06bd502be2043e6afc9ee/App_Resources/Android/app.gradle#L11.
For those looking for a solution in 2021, there is an easy way to set it up.
Open your nativescript.config.ts and add different id properties inside android and ios:
import { NativeScriptConfig } from '#nativescript/core';
export default {
appPath: 'src',
appResourcesPath: 'App_Resources',
android: {
v8Flags: '--expose_gc',
markingMode: 'none',
id: 'com.yourapp.android'
},
ios: {
id: 'com.yourapp.ios'
}
} as NativeScriptConfig;

Adding PCL project to VSIX not working

I´m trying to create a multi-project-solution-template with VSIX for my Xamarin solutions but I just can´t get the template to work when I add a PCL to it.
I´m using this Git project (see How to create a multi project template) as a boiler plate and I can easily add ordinary projects (e.g class libraries) to it and get them to work just fine.
I´m guessing it is not working because I probably need to add some Dependencies in the vsixmanifest file to e.g ASP.NET Core 1.0 or more of the stuff the PCL is referring to.
But I have not been able to find out what to add to get it to work.. and of course this could be something totally different...
I just tried to change the PCL to the new .net Standard by using this guide ".NET Standard Library with Xamarin Forms" and it works like a charm. But with Xamarin.Forms 2.3.1.114 I needed to go for netstandard 1.4.
So my project.json file looks like this
{
"supports": {},
"dependencies": {
"Xamarin.Forms": "2.3.1.114",
"NETStandard.Library": "1.6.0",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1"
},
"frameworks": {
"netstandard1.4": {
"imports": [
"portable-net45+win8+wpa81+wp8"
]
}
}
}
This ".NET Standard with Xamarin Forms Gotchas" might also help you as it did me.

Resources