Sailfish Share API and Sailfish WebView

I have no idea. May I suggest you open a new topic about your issue, and post a link to your source code? Perhaps someone can then help you figure out the problem.

This has been fixed with the SailfishOS-4.4.0.58 emulator.

4 Likes

Perhaps it’s just me (usually it is), but I’ve noticed that no YAML is present in a new project, pretty sure they were always present. Using latest SDK 3.10.4 on Windows 10 64bit. Guess I’ll have to manually add the missing YAML file.

I’ve followed the docs, I am still unable to get imports for web stuff to be recognised. Ultimately, why is there no YAML file in my new project…and looking at new and old projects, most are lacking a YAML file. I guess I should make that last remark as a new post.

It’s not just you, YAML files were indeed dropped a while ago. Instead of adding YAML file yourself, you should add the build time dependencies to the RPM spec file as BuildRequires.

I did just that @vige regarding “BuildRequires” but I am still unable to add necessary import statements for WebView stuff.

So what am I missing from .pro file and spec.file ?

my .PRO file;

TARGET = harbour-qml-colors

PKGCONFIG += qt5embedwidget

CONFIG += sailfishapp

SOURCES += src/harbour-qml-colors.cpp

DISTFILES += qml/harbour-qml-colors.qml \
    qml/cover/CoverPage.qml \
    qml/pages/FirstPage.qml \
    qml/pages/SecondPage.qml \
    rpm/harbour-qml-colors.changes.in \
    rpm/harbour-qml-colors.changes.run.in \
    rpm/harbour-qml-colors.spec \
    harbour-qml-colors.desktop

SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172

and my .SPEC file;

Name:       harbour-qml-colors

Summary:    My Sailfish OS Application
Version:    0.1
Release:    1
License:    LICENSE
URL:        http://example.org/
Source0:    %{name}-%{version}.tar.bz2
Requires:   sailfishsilica-qt5 >= 0.10.9
BuildRequires:  pkgconfig(sailfishapp) >= 1.0.2
BuildRequires:  pkgconfig(Qt5Core)
BuildRequires:  pkgconfig(Qt5Qml)
BuildRequires:  pkgconfig(Qt5Quick)
BuildRequires:  desktop-file-utils
BuildRequires:  pkgconfig(qt5embedwidget)

%description
Short description of my Sailfish OS Application


%prep
%setup -q -n %{name}-%{version}

%build

%qmake5 

%make_build


%install
%qmake5_install


desktop-file-install --delete-original         --dir %{buildroot}%{_datadir}/applications                %{buildroot}%{_datadir}/applications/*.desktop

%files
%defattr(-,root,root,-)
%{_bindir}/%{name}
%{_datadir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.png

This looks fine compared with the settings in my app Ielig:Web.

When you add this 2 lines to your qml:

import Sailfish.WebView 1.0
import Sailfish.WebEngine 1.0

QT Creator creates 2 messages ("QML-modul not found…). Thats not a problem. Enter your code and build your app and the app will work on your phone. As I remember the Sailfish emulator can’t run apps with the Sailfish WebEngine.

Happy hacking

2 Likes

Is this still the case in the current version? Hope that this will be fixed with a new SDK Version.
Developing Apps with a WebView is somehow annoying if it does not work in the emulator…

yes. And we will see…
But always a phone is a better testing device. It’s more real life.

Hello! Today I tried to make my app harbour-compatible. It uses Sailfish.WebView, and validator failed with this error:

ERROR [/usr/bin/harbour-saildiscord] The rpath in binary is not allowed: '/home/koza/SailfishOS/mersdk/targets/SailfishOS-4.6.0.13-aarch64.default/usr/share/harbour-saildiscord/lib:/home/koza/SailfishOS/mersdk/targets/SailfishOS-4.6.0.13-aarch64.default/usr/lib64/xulrunner-qt5-78.15.1'
INFO [See also:] https://harbour.jolla.com/faq#6.3.0
INFO [See also:] https://together.jolla.com/question/10713/create-the-example-of-including-your-own-library-and-standard-qt-module-in-a-harbour-compatible-way/#14098
FAILED

I checked another app which uses WebView and was published to harbour, sailfish forum viewer. It seems like it workarounds this by removing WebView from dependencies, but I feel like this way might break something. So, is there a better way to fix this?

Edit: So it seems like not only my app is affected by this, just to name a few: Sailtrix, Jolla Email, Sailfish Browser. I then checked Browser dependencies and they include both qt5embedwidget and sailfish-components-webview-qt5. Since browser is installed on almost all devices, I think the workaround from the forum viewer isn’t actually that bad.

Hmmm. I don’t understand your setting. For me you need only this:

.PRO file:
add this line: PKGCONFIG += qt5embedwidget

.SPEC file:
add this line: BuildRequires: pkgconfig(qt5embedwidget)

and in the QML file add:
import Sailfish.WebView 1.0
import Sailfish.WebEngine 1.0

as documented in the SFOS documentation and in the post above in this thread. And no more.

Why have you a message for xulrunner? Have you an special entry for this in .PRO or .SPEC? Or have you xulrunner in a not standard version?
What is “removing WebView from dependencies”?

I have same setup as you described, except for this additional line in SPEC:

Requires: sailfish-components-webview-qt5

I have no references to xulrunner in my code anywhere. Removing webview from dependencies means removing all those lines completely from SPEC and PRO files.

Please try a run without this line. In my app using Sailfish WebView there is no such line.

1 Like

Are the sources for your app available somewhere, I could try building it myself to see what’s going on.

1 Like

While this does work, this still does not add WebView to the dependencies, which will break on devices without browser installed. The simplest example is the emulator:

[D] unknown:0 - QML debugging is enabled. Only use this in a safe environment.
[D] unknown:0 - Using Wayland-EGL
[W] unknown:3 - file:///usr/share/harbour-webviewtest/qml/harbour-webviewtest.qml:3:1: module "Sailfish.WebView" is not installed 
     import Sailfish.WebView 1.0 
     ^

And I’m not sure if linking against qtmozembed-qt5 is still required, because it worked for me without it.

Yes, they are available here

In any case, my issue is solved since most devices do have browser installed (and sailfish-components-webview-qt5 package). Thank you everyone

Have you read the post above of your first post here in the thread? Maybe this can save time.

Here I wrote (after the discussion of .PRO and .SPEC like in your question):

So please test your app without this line: Requires: sailfish-components-webview-qt5 in .SPEC on a phone, not on the emulator. Many thanks.

Yes, it works on my phone, and I did test it there first. QML module not found errors are because of build engine, not emulator. Emulator is just an example of a device without browser installed. What I meant is, if the package sailfish-components-webview-qt5 is not installed, the app would fail. Besides the emulator example, browser in older sailfishos versions without sailfish-components-webview-qt5 in dependencies could be it.

Anyway, I already said that I’ll proceed as you said here, even though this will break if the webview package is not installed. But still, if someone knows a better way (maybe overwriting rpath with QMAKE_RPATHDIR), let me know.

Thanks for testing. So your question about the correct setting is answered. Fine :heart:

For me your remaining question is:

a) I have a fresh flashed SFOS phone. Will an app with Saifish WebView running out of the box or have I to install some more SFOS components?

b) And is the SDK emulator a good reference for this?

Correct?

1 Like

a) If it is on the latest SailfishOS version, it will work out-of-the-box
b) Yes, SDK emulator is a good example for this. Without that line it would just show a meaningless white screen, but with the line it would install properly. On a device with an old SFOS version with that line it would show an error on installation.

1 Like

So you stated the posts above in this thread saying the Sailfish WebView will not work in the emulator. Thats a good conclusion of this discussion. I wish you good luck with your app and will be happy to see your app in harbour soon ™. For further questions please send a pm.

2 Likes