Xamarin Forms - prevent iOS storyboard from loading - xamarin.forms

I'm using Visual Studio for Windows to test a Xamarin Forms app on Android. Now I want to test it on an iPhone as well, which is possible by connecting the iPhone to my Windows system and using Xamarin Hot Restart.
The app is deployed on the iPhone, but when I tap on the icon it starts for a brief moment and then it closes (like it crashes). Looking at the link sent here earlier, in the Limitations section, the cause of this issue might be described there:
"Storyboard and XIB files are not supported and the app may crash if it attempts to load these at runtime. Use the HOTRESTART preprocessor symbol to prevent this code from executing."
I do have a Storyboard and I think an XIB file, but I have no idea how to prevent it from loading. The storyboard is called in info.plist only and the XIB extension is called in the .storyboard file.
LaunchScreen.storyboard
Info.plist
The usage of the preprocessor symbol HOTRESTART is only for C# I believe. My question thus is: how can I use the processor symbol HOTRESTART to prevent the loading of storyboard and XIB files?

Related

Xamarin forms iOS changed AppIcons but remains showing old default

Starting from a standard Xamarin forms app template and changing the app icons in assets.xcassets, I am unable to make this take effect. The initial xamarin icon keeps showing when deployed to physical devices.
In assets.xcassets, I added all the required image sized.
I ensured that in plist info this asset was set as app icons source.
I have tried cleaning, rebuilding and deleting from the ipad and iphone I am testing with. No success.
I tried deleting the default asset and creating a new one, and make pinfo point to this, and still the old Xamarin icon shows up. This makes me think that there is a cache somewhere on either my windows pc, on which I am developing using vs2019, or on the mac which VS is connected to for doing the actual build, and this is not getting updated, since otherwise that old icon should not exist any longer.
I did read this answer
Xamarin forms: Launcher icon for ios
Which indicates that the OP has a problem with a mismatched path to the asset, but that does not seem to be the case for me. The xcasset folder is at the root of the ios project. As this is simply the default test project it is app1/App1.ios/Fawk.xcassets and the entry in pinfo is
XSAppIconAssets
Fawk.xcassets/AppIcons.appiconset
Does this make any kind of sense?
Edit: Tried vs2019, xamarin forms template. Deleted default asset in assetcatalogs under ios, created a new one, set all my custom icon images (png), updated info.plist/visual assets/appicon to my new asset and then ran it on a physical device. The default xamarin icon is what shows up. This seems to indicate it is not a cache issue, as I suspected, but... something else...
You can right-click Assets.xcassets and view it in the folder, there is a json file in it, please check if the file name is correct.
According to the official documentation, if you are not connected to a Mac, it will only display the original image. For more information, you can check: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/deploy-test/hot-restart#limitations

How to include Android.Support.v4 in Xamarin Forms (iOS)?

I am using Visual Studio For Mac. My Xamarin Forms project is quite large and contains many content pages. Some of them will be only used in android project and some of them only used in iOS project. There is no problem when I compile the project into android. However, when I want to compile the project into iOS, it seems like did not accept anything related to android. Please refer to the screenshot. There is no way I can include the android specialised reference and compile into iOS project. So, any idea to deal with this? Maybe there is a way to force build the iOS project no matter what? The error from the screenshot is from the page that will be only used in android. So what I can do for now is delete the page when I want to compile as iOS and recreate the page when I want to used it for android. But there are plenty of them, it is too heavy for me to do this every time. Please help.
You can't call platform specific APIs at the .NET standard libraries that are used to host Xamarin.Forms code by default.
Basically you have those options:
1) using shared project instead of library and using conditional compiling (easier but it is now not available as the option when creating the project)
2) using dependency injection.

How to use open file dialog in xamarin forms

Please help me, I want to pick the pdf file locally in xamarin forms(cross platform). So on a button click i need to open the file dialog to pick pdf file locally.
This is not something that can be done in a true cross-platform way. For example; on iOS you cannot access the filesystem directly, while on Android and UWP you can.
I have created a NuGet Xamarin.Plugin.FilePicker (Github) (original by rafaelrmou), which tries to solve this for you. On iOS you need iCloud Drive to be configured.
If you do not want to use the plugin you could always look into the code and roll your own.

How to run a PhoneGap app with Sqlite in Ripple?

I have a phongap app with a sqlite plugin that runs in both android and iphone. When I try to run it in Ripple i get several errors depending on the inclusion of the cordova version and device I use. Non of them are working at all. In some comments in stackoverflow i've seen people running sqlite in phonegap under ripple.
I'm using the PG-SQLitePlugin-Android plugin in my project, which it acually only supports Phonegap 2.7.0+.
I've found that i can force Ripple to use 2.7.0 by calling it :
file://localhost/Users/----/----/----/www/index.html?enableripple=cordova-2.7.0
Ripple actually loads great after enabling access to file system through chrome.
When i include cordova-2.7.0.js in my script
The index.html pops me a pop up with the following text :
gap:["Device","getDeviceInfo","Device119187522"]
that i can accept or cancel, then 2 more dialogs appeare, if I accept it gets hanged.
the js console shows that cordova 2.7.0 is really running :
Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only. cordova-2.7.0.js:906
deviceready is not fired
When i include cordova-2.9.0.js in my script
It happens the same as 2.7
Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only. cordova-2.7.0.js:906
but this time I get this other errors
Failed to load resource file://localhost/Users/laullobetpayas/-------/---/------/www/cordova/cordova_plugins.json
Failed to load resource file://localhost/Users/-------/---/------/www/cordova/cordova_plugins.js
deviceready is not fired
When I don't include any cordova.js in my script
SQLitePlugin.js:31
Uncaught ReferenceError: cordova is not defined SQLitePlugin.js:34
Am I using the proper plugin ?
which is the propper version of cordova / device tu run with the plugin and ripple ?
Do i have to include the cordova.js in my project
Hel will be very apreciated, it's for a long time that I'm trying to solve this.
Thank you in advanced.
Phonegap plugins won't work with Ripple because the idea of a Phonegap plugin is that it provides a Javascript interface in order to execute native code. That means, in the case of Android, the Javascript will invoke native Java code and in the case of iOS, the Javascript will invoke native Objective-C.
Ripple is purely Javascript-based, so the Javascript part of the plugin has nothing to interface with.
In the case of the SQLitePlugin, for example, calling SQLitePlugin.close() results in the call:
cordova.exec(null, null, "SQLitePlugin", "close", [this.dbname]);
where SQLitePlugin is the native class name and close is the native function name.
If you want to use the same storage API across Android, iOS and Ripple, maybe consider using lawnchair with appropriate adapters.
As for the issues with Ripple and Phonegap 2.7.0/2.9.0, Ripple has not quite caught up with Phonegap, so you will get these popups and error messages in the console, but that will not stop your Phonegap app (without native plugins) running in Ripple. You can convince yourself of this with a simple test case like:
document.addEventListener("deviceready", function(){
alert("I'm alive");
});
But the answer is, yes, you do need to include cordova.js in order for it to work at all in Ripple.
The Cordova-SQLitePlugin is a drop-in replacement for the HTML5 SQL API, so when running inside Ripple you don't need to call the Cordova layer you can just replace calls to sqlitePlugin.openDatabase() with window.openDatabase(). I've not yet tested this with Ripple but it should work. There are some database size limitations but this is probably all you need for testing.
There several ways to test if your inside Cordova. You could create a shim for the openDatabase() method based on testing for Cordova on app startup.
Since your primary goal is really to do rapid testing of SQLite with Cordova (rather than specifically to use Ripple) I'd like to suggest another new alternative to using Ripple.
I wrote an app call Sencha Touch Live that can be used for rapid development of Cordova / HTML5 apps by allowing you to Live Edit and Debug the HTML/JS/CSS code on your mobile device simply by updating files on your development computer - so you can skip most recompile/redeploy/restart debugger time costs. It has tons of other cool features. I'm using it myself for SQLite app testing instead of Ripple or Weinre
Detailed overview and Step by Step Guides
Installation Guide
It's based on the code from Adobe's PhoneGap Developer App so core code is well tested. It's been extensively adapted and tuned for Sench Touch framework though it should also work for jQuery Mobile or any framework that places HTML5 code under the phonegap/www or cordova/www folder. Just start up the server in you PhoneGap or Cordova project folder.
For testing your SQL and controller logic, I recommend using Geny Motion emulator with a version of Android 4.4.x KitKat. Start up an recent version of Chrome on your desktop and once you get your app working on the emulator or real device open chrome://inspect and now you can use the full Chrome debugger on your remote device app. You can also use a recent version of Safari for OSX/iPhone Simulator testing.
You can watch a demo here (starts at the 5 min. mark). Yes! It needs a more polished video with less echoes but you'll get the idea:
https://www.youtube.com/watch?v=94J4HBB0f7I

Why does Flash Builder 4 use Flash Player instead of a browser to run apps?

I've got an old flex builder 3 project that I imported into Flash Builder 4, and I want this project to run its web applications in my web browser. However, the apps persistently run in the Flash Player instead. This is causing no end of problems because of the flash player bug documented at https://bugs.adobe.com/jira/browse/FP-209.
How can I make a project's apps run in the browser instead of the player?
This issue can be caused by HTML generation being disabled. In the project property panel:
Screen Shot of the settings http://img685.imageshack.us/img685/1487/screenshot20100422at124.png
In your debug configurations, make sure that the url or path to launch points to the html file that the swf is embeded in, not the swf itself. You can reach the debug configuration menu by clicking the little arrow next to the debug bug icon... (and probably some other way, but i always use that menu).

Resources