iWidget is a (experimental) tool which allows you to add a
today widget to your B4i app.
Spoiler: HelloWorld widget
How to use?
Download iWidget here
Close the B4i IDE
You need to fill in the following information
the path of the B4i installation directory
the path of the B4i project you want to add the widget to
the name of your App (corresponds to the #ApplicationLabel )
the package name of your App (corresponds to the Package under the Build Configurations)
a title for the widget
choose a port for the logger (see the explanation of the logger in the notes section)
Click on the Apply button
Open the B4i project
Add the attached modules (TodayWidget & WidgetContext) to your project
if you use the logger don't forget to set Logger_Host & Logger_Port variables
Start coding your widget
Notes & tips:
start with the attached HelloWorld project, for the first time it's possible that you have to add the widget manually by clicking on the circled edit button
use a wildcard certificate for your project
the minimum required iOS version is 10, so add: #MinVersion: 10 to your project attributes
always keep in mind the consequences of the fact, that a widget is a totally new target. For example the widget can't access values of a variable, which were set in the main app
the PerformUpdate event is invoked when the widget is loaded and it can also be called in the background. In this sub you need to check whether there is new data available and update your UI. From my experience you should do the same routine also in the Widget_Appear sub
I strongly recommend to create the UI with the designer and use anchors
the normal Log method will be useless for widgets. Instead make use of the Wlog function in the TodayWidget module
the logger will not catch errors: If your widget returns "Unable to load" there is a mistake in your code, use try-catch blocks to locate the issue. However, if you have a local mac, you can open the generated Xcode project and run the Widget target specifically (in this case you will be able to see the logs added with the normal Log method and also see errors)
when working on a widget always test in release mode
everytime you activate or deactivate iWidget you have to restart B4i
when working on your widget project, keep iWidget open
administrator rights are required for editing the Xcode template
iWidget was tested with B4i v.4.81 + local mac builder (Xcode 9.2), I don't know whether the hosted builder has restrictions concerning the template file, just try it out
Feel free to ask questions