Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

watchtips

this is an experiment to see if can use flutter to build an ios app with an accompanying watchos app. my first attempts using the beta product were not successful so the idea was parked. having now re-visited this i can now get a compiled blank watch app up and running with a flutter app, so i will, in stages, try and re-create the watchtips app using flutter.

plan

my plan is to:

  • 1.0 create a vanilla flutter app (this initial commit)
  • 1.1 add a blank watch project and get it working
  • 1.2 modify the watch app functionally into watchtips
  • 1.3 update the flutter app to watchtips
  • 1.4 see if i can bridge between the 2 app (as the titanium version does)
  • 2.0 tidy up both the flutter code and the ios project and use it to submit the app into the app store

flutter package project

from the results of this test project, i have started developing a flutter package to allow communication between a flutter ios app and a watch app. this should allow easier integration with some standard functionality, though it is still a pain atm as after you add a watch kit target to the ios project as flutter run/build no longer works. this means all package testing and development then needs to be done via xcode.

i have got message working from an ios app to the watch via the plugin, this can be seen working in avideo here.

generating a distro build

the only way, so far, i have found of creating a distro build is following this seqence.

set the bundle id

before adding the watch kit app target set the final bundle id, as the watch app and associated extension needs to use the same prefix. if not you may need to update all references before creating the final archive.

change all the version and build values

this must be done for each target (in this case 3), change them to $(flutter_build_name) and $(flutter_build_number) respectively, otherwise although the test runs work, the archive will not unless the version numbers match.

run the flutter build first

this will fail, but it generates the correct shell scripts to enable ios to carry out the build (flutter build ios –release).

create archive in xcode

  • 1 select generic device + watchos device as the destination
  • 2 run product -> archive
  • 3 if build successful , run the validate app
  • 4 if validate successful – upload to app store!!!

versions

2.1

  • updated watch and phone ui
  • currency now defaults to the phone/ipad locale
  • package made universal, so it runs on ipad (no watch supoort)

2.0

  • first app store release

1.4 – rough and ready but working!

i have now managed to add the required code into the ios project to allow it to communicate with flutter and send data updates from the watch so they are reflected in the app.
basically if you do a calculation for a tip on the watch then the data is transferred to the associated device.

you need to forgive the (bad?) objective c coding as it is not really my thing – who in their right mind thought of it in the first place anyway 🙂 . a lot of this was just brute force trial and error as well as a lot of searching and testing.

apart from that the difficult issue for me was that although methodchannel is quite well documented, eventchannel is not, the only examples i found were to do with plugin extensions, but again probably due to my dislike (due to not understanding it very well) of objective c.

i will try to create a generic plug-in later, but that will be done in swift.

1.3

so after a bit of a hair pulling out session i have managed to get this working. i now have a iwatch app as well as a flutter ios app to build and run. i have tested this by building and distribuing to a physical phone via hockeyapp. now the bad news……

i cannot use flutter to either build the flutter project or do the ios release build, so i actually built the flutter app in a seperate project then added the lib dir back into this one.
this is a major pain as to do an testing, on device or simulator i need to use xcode to do all the build (i.e. no hot-reloading), but it does work.

to create the ad-hoc distro of the app i again used xcode, set the target to generic device and archived the project. the resulting ad-oc signed app works well.

but i think the last stage will be a major hurdle as i will need to do all building using xcode………

1.2

updated watch app and added functioning watchtips. watch app can now be used to calculate bill split and tips.

1.1

after using xcode to define a simulator with an attached watch emulator the standard vanilla app (from 1.0) was updated as follows

  • set a bundle id on the ios runner app (u.spiralarm.watchtips)
  • add a new target in xcode (file->new->target), a watchkit app was selected
  • untick include notification scene and include complication
  • name the product watchtips
  • generate 2 sets of assets (i use an app called asset catalog creator), one for the runner app and one for the watch app so that both have a full set of icons.
  • open the interface.storyboard for rhe watchtips app and add a button to the screen

after this i can no longer user the ide (vsc) to start the app up in debug mode as i get the following error ( perhaps some sort of cusom build configuration is required):

=== build target watchtips extension of project runner with configuration debug ===
target specifies product type 'com.apple.product-type.watchkit2-extension', but there's no such product type for the 'iphonesimulator' platform
could not build the application for the simulator.
error launching application on iphone 7 with watch 42mm.

however, if i use xcode i can use xcode to compile the app and run the watch app on the emulator.


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.