Forum Xamarin.iOS

Is it possible to build a watchkit UI with code (no storyboard)?

djTomServodjTomServo Member ✭✭

Hello all, and apologies if this has been asked already.
Is it possible to build a watchkit ui completely in code and if so, can anyone recommend any samples or tutorials for this?

The reason I ask is I'm new to watchkit development, using Visual Studio 2019 and Xcode 11, and I'm sorry to say I've run into just about every issue possible, e.g.:

  • Unable to open the storyboard in the iOS designer in VS, I've seen some threads indicating that MS has a fix, but I haven't seen a release date or if the fix was ever released
  • Unable to create outlets and actions in Xcode. I've tried following the recommended fixes, i.e. adding @IBOutlet and @IBAction code to the header file manually, or cleaning and restarting Xcode, but I've had no luck there either.

For now, I just need to get something up and running, so if anyone could point me in the right direction (if it exists), much appreciated!

Best Answer

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    Is it possible to build a watchkit UI with code (no storyboard)?

    The short answer is NO.

    WatchOS's layout system is different from iOS's so there is no frame, no bounds, and even no auto-layout there.
    We can't dynamically add controls in the code behind like what we did in iOS.

    Unable to open the storyboard in the iOS designer in VS, I've seen some threads indicating that MS has a fix, but I haven't seen a release date or if the fix was ever released

    Try to troubleshoot what happened on your side. The interface builder should work after connecting to Mac.

  • djTomServodjTomServo Member ✭✭

    Cool, good to know, thanks for the info!

    Re: Xcode Interface Builder vs Visual Studio iOS Designer, just for reference and clarity, Interface Builder works fine on mac if I set it in Preferences > iOS > Designer tool or Right-Click > Open With, but on Windows I get this issue:

    forums.xamarin.com/discussion/171021/visual-studio-for-mac-8-3-1-not-able-to-render-watchos-storyboards (sorry, can't post links yet)

    which from all my research seems to be a known to all relevant parties. The specific issue I was referring to with Xcode is that I'm unable to Ctrl-Drag from a control in the storyboard editor to the header file (InterfaceController.h) in the assistant editor to create an Outlet or Action as indicated in this documentation:

    docs.microsoft.com/en-us/xamarin/ios/watchos/troubleshooting#manually-adding-interface-controller-files

    There are some workarounds I've tried, including cleaning, re-building, waiting for Xcode to index, but in trying all of those, I still get an error stating "Could not insert new outlet connection: Could not find any information for the class named ". It does work if I add some code to the header file first, but again, the doc seems to indicate this isn't necessary. Just FYI.

Sign In or Register to comment.