Uno-Platform: How to add a Library - uno-platform

Uno Platform...
In VS2019 (out of the box tests):
added uno templates: all good
create project.....: all good
run WASM project...: all good
run UWP project....: all good
added a Uno Library: various issues (see list below)
Uno Library (in UWP and WASM) issues:
complaint about a android 10 library... I remove it and compile OK
after adding this library to the UWP project found multiple netstandard2 compilation code;
I am using the uno project template as is... but can't even add a Uno-Library without adding any code, just what ever is generated by the wizard.
Question:
I will like to prepare a library and add it to any target... any advise?
Ed.

It appears (so far) to be a successful workaround:
Temporarily move the uap10.0.xxx target framework to be at least second in the TargetFrameworks list. (See this for more details: https://github.com/unoplatform/uno/issues/3909)

Related

Xamarin Forms: BLE Laerdal Dfu OTA. compilation problems

I am trying to get an App to work with OTA Nordic Dfu, and the only xamarin nuget I can find was the one made by Laerdal on GitHub
When I try to build under iOS I am getting a few error like this one here:
Error MT5211: Native linking failed, undefined Objective-C class: _TtC13iOSDFULibrary11DFUFirmware. The symbol '_OBJC_CLASS_$__TtC13iOSDFULibrary11DFUFirmware' could not be found in any of the libraries or frameworks linked with your application.
A bug is open for this, but so far not a word from the people maintaining it.
I am left wondering if this is actually a local problem and not a problem with the nugget its self. So if any one out here is able to compile this under iOS help would be really appreciated.

Uno-Platform: Cross Platform Library, #if conditional for WASM?

In pre 4.0 Uno-Platform, I was able to use the #if __WASM__ compiler directive for WebAssembly specific code in a cross platform class library. This was very useful for creating WASM specific widgets using the WASM specific SetHtmlAttribute method.
However, in version 4.0 Uno-Platform, my code isn't building because the compiler isn't finding the __WASM__ constant. I hesitate adding it manually to the libraries *.csproj file ...
<DefineConstants Condition="$(TargetFramework.StartsWith('netstandard'))">__WASM__;$(DefineConstants);</DefineConstants>
... because I'm afraid it will build if the target is WPF. So, is there a better approach?
While your approach covers the scenario where a given API is available on all Uno targets, it will not work in case it really is WASM or Skia specific, unfortunately. For those cases though we have another type of library - cross-runtime library (see docs). Currently this kind of library can only be created via dotnet command-line tooling:
dotnet new unolib-crossruntime -o MyCrossRuntimeLibrary
By default it generates the following solution layout:
Both projects are pointing to the same source-code files, however the ".Wasm" one is specifically referencing the WebAssembly runtime and will correctly adhere to #if __WASM__ declarations. Similarly you could create another project for ".Skia" to have Skia-specific declarations.
Doh! I don't know why I had not noticed this before! Looks like SetHtmlAttribute is implemented on all Uno target platforms! So, rather than using the #if __WASM__ compiler directive, I can use #if !WINDOWS_UWP and implemented my WASM code knowing it will be ignored on the other Uno target platforms.
Very clever, Uno Team!

Codename One How to add BLE extension

I developed a mobile app using CN1's BLE library. The BLE api did not work after I've added the library that I've downloaded from https://github.com/chen-fishbein/bluetoothle-codenameone, however, I solved this issue by adding the library using CN1's settings/extensions UI instead of manually copying the downloaded libs after I've found the EvSunWoodard's comment here Codenameone Bluetooth APIs not working on android.
CN1 recently updated and I'm stuck with the same problem after I've added the BLE extension using the new and old settings UI. When I try to call any bluetooth method, the app does not respond and does not catch any exeptions - it simply does nothing. I've noticed that the new settings UI adds a new java package to the impl/stubs library that did not use to be there before the update, I've tried removing this package, as the bluetooth.class file is still there, but this did not have any affect.
Anyone have any ideas on how to get the BLE library working again?
The most current repo with the bluetoothle lib is https://github.com/codenameone/bluetoothle-codenameone
It is a couple of commits ahead of the fork you used. It should work for you.
However, it is the same version that you'll get by simply downloading it through Codename One preferences.

Stuck with creating Keyword library using Java in Eclipse and using that JAR file in RIDE

I'm new to ROBOT framework and must create library keyword using java and utilize the JAR files in RIDE editor. I have followed the below steps. But still have confusions in where to start up. Please help me to achieve this.
Steps:
1) Installed Python, wxPython, pybot, RIDE, selenium2library successfully and I'm able to work with RIDE using predefined keywords.
2) For creating own java library, Installed Eclipse Mars, Java, ROBOT IDE manually using the link https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki/Installation
The question here is,
Anything i'm missing to install?
How to proceed further with Robot Framework coding?
Note: I'm reading many materials in parts to proceed things. But that is confusing me what are the steps to be followed. Is there any single material that i can get having the sequences of steps that need to be followed for my requirements?
The below links I referred with,
https://github.com/NitorCreations/RobotFramework-EclipseIDE/wiki/Usage
Maven error "Failure to transfer..."
Create a Maven project in Eclipse complains "Could not resolve archetype"
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#using-set-test-suite-global-variable-keywords
Let's start with the basics. RIDE is an editor for Robot Script files. Robot Script files are executed by the Robot Framework robot application. It is important to understand the difference between these two applications. One creates files and the other uses them.
Assuming for a moment here that you have some custom functionality in a Jar file that you would like to make available inside the Robot Script files test cases. If this is indeed the case then your focus should be on create Robot Test Libraries. In the documentation there are numerous java examples given for basing your own library on.
This means that you do not need Maven, unless you want to, to create your library. Also Eclipse IDE is not needed nor is RIDE. The library you create can be used by Robot Framework even when it's run from the command line. Feel free to use them for what they are good at: writing Robot Scripts efficiently and running Robot through menu options instead of command line windows.
When you are familiar with Eclipse and comfortable with it's features, then I can also recommend using the Eclipse Application RED which is a mature Eclipse add on for creating, running and debugging Robot scripts.
There are two ways of implementing a Java routine in Robot Framework and it depends a bit on how you run Robot Framework: Python or Jython. Running Python means that you need to run the Java in a separate JVM container and connect to it. The simplest way is via Command Line interaction. This may cause some security concerns. The second approach is to use the Remote Library approach. A good example of this is the Robot Framework Sikuli Library. An added bonus is that you can run Robot and your Java application on two separate machines/servers.
The Jython way has been discussed on StackOverflow before and I gladly refer to it. Please bear in mind that although the examples refer to RIDE, the Library org.company.Keywordlibrary works in all IDE's, provided robot framework is run using Jython.
In the Jython documentation it clearly explains how to setup an Eclipse based IDE with Jython. Do keep in mind that it's recommended to use the same interpreter in development and production. I.e. if you create your scripts in Jython, do run them in 'production' also using Jython. Otherwise you open yourself up to interpreter differences where functionality does not work or behaves differently then expected.
An alternative approach with Jython is the all-in-one Robot Framework Maven JAR plugin. Adding a custom Java Library in this setup is not too difficult. A nice short tutorial can be found on the blog of Valerio Bruno. If this is your preferred route for development, then you may want to read the RED howto on integrating the Robot Framework Maven jar.
Working on your custom functionality is likely going to be a independent project in Eclipse, but can be linked to an Robot project via the Class Path settings in red.xml if you use RED or the CLASS_PATH environment variable.
Done! I have installed RED and required add on using following below steps. It worked successfully with predefined keywords. Now I'm gonna create user defined keywords/libraries using the same editor. I don't know where to start up. Will it work creating just a java project? Should I need to include any additional libraries?
Steps followed to proceed with RED:
1. RED Version Conclusion: https://github.com/nokia/RED/blob/master/release.md
2. RED Installation Instructions: https://github.com/nokia/RED/blob/master/installation.md
3. ROBOT Framework prerequisites using RED: https://github.com/nokia/RED/blob/master/red_help/first_steps/download_install.html.md
4. To verify Installations in Eclipse: Help -> Installation Details to check if RED is visible on installed features list
5. Create Project and Tests using RED in Eclipse: https://github.com/nokia/RED/blob/master/red_help/first_steps/create_run.html.md
6. RED Steps: https://github.com/nokia/RED/blob/master/First_steps.md
7. Quick STart: https://github.com/nokia/RED/blob/master/red_help/user_guide/quick_start.html.md

Exclude Arduino library from compilation

I've created an Arduino project using the "Adafruit_SSD1306" display library, which works as expected using a Uno board.
A subsequent project needed to use the ESP8266 wifi board, which required a new display library "ESP_SSD1306". I can see from the source this library is derived from the "Adafruit_SSD1306". Everything compiles and works as expected.
However, if I go back and try to rebuild my old project, or any old project, sample etc that references "Adafruit_SSD1306", it will not build, unless I remove the "ESP_SSD1306" library from my "libraries" folder.
The error is:
sketch_aug04b_xxxxxxx.ino:24:30: fatal error: Adafruit_SSD1306.h: No such file or directory
compilation terminated.
Error compiling.
The workaround is to add or remove this library from the libraries folder whenever I switch to non-ESP8266 project and manually add it back when I switch to an ESP8266-based project.
I'm guessing the libraries conflict in some way, but I am hoping there is a better user experience for dealing with this. Some #define or project setting I can use to remove a library from the compilation path (other then the current process, which involves manually removing the library).
Looks like I've found the answer.
Both libraries have the identical name in their library.properties file. This appears to be what is causing the conflict.
The solution was to change the name property of the ESP_SSD1306 library from "Adafruit SSD1306" to "ESP SSD1306":
name=ESP SSD1306
version=1.0.0
author=Adafruit
maintainer=Adafruit
sentence=SSD1306 oled driver library for 'monochrome' 128x64 and 128x32 OLEDs!
paragraph=SSD1306 oled driver library for 'monochrome' 128x64 and 128x32 OLEDs!
category=Display
url=https://github.com/adafruit/Adafruit_SSD1306
architectures=*

Resources