Bug 34514 - [watchOS] CLKComplicationServer.SharedInstance is null
Summary: [watchOS] CLKComplicationServer.SharedInstance is null
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.WatchOS.dll ()
Version: XI 9.3 (xcode 7.1 previews)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-10-01 20:29 UTC by CraigD
Modified: 2015-10-29 04:39 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description CraigD 2015-10-01 20:29:50 UTC
Apple's docs:

Trying to get an instance of the CLKComplicationServer to access complications, eg

	var complicationServer = CLKComplicationServer.SharedInstance; // is null :-(
	foreach (var complication in complicationServer.ActiveComplications) {

but `SharedInstance` is null. This is the sample

=== Xamarin Studio ===

Version 5.10 (build 913)
Installation UUID: 81270b48-59a5-4b76-86eb-a908e437fbd4
	Mono 4.0.4 ((detached/d481017)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400040004

=== Apple Developer Tools ===

Xcode 7.1 (9069)
Build 7B75

=== Xamarin.Mac ===

Version: (Business Edition)

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 155d35b
Branch: master
Build date: 2015-09-30 18:26:52-0400

=== Build Information ===

Release ID: 510000913
Git revision: d437b9453df0bd08103df76b60a2bb95c3a864a6
Build date: 2015-09-30 16:56:55-04
Xamarin addins: 2c839fd62864efbeb8d02091e4ba3dfde24a099a
Build lane: monodevelop-lion-xcode7.1

=== Operating System ===

Mac OS X 10.10.5
Darwin Craigs-MacBook-Pro.local 14.5.0 Darwin Kernel Version 14.5.0
    Wed Jul 29 02:26:53 PDT 2015
    root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
Comment 1 Sebastien Pouliot 2015-10-01 21:04:19 UTC
Sadly I do not reach that code with your sample, I always end up with:

Need to listen for memory warnings on the watch
STATE CUE CARD: (? means a positive number, usually 1 or 2, * means any number)
	0x0	- starting (GOOD, unless the thread is running managed code)
	0x1	- running (BAD, unless it's the gc thread)
	0x2	- detached (GOOD, unless the thread is running managed code)
	0x?03	- async suspended (GOOD)
	0x?04	- self suspended (GOOD)
	0x?05	- async suspend requested (BAD)
	0x?06	- self suspend requested (BAD)
	0x*07	- blocking (GOOD)
	0x?08	- blocking with pending suspend (GOOD)
--thread 0x79678e50 id 0x7ed01d4 [0x70b] (tid_70b) state 105  
--thread 0x7966b5d0 id 0xb0197000 [0x1c07] (tid_1c07) state 1  GC INITIATOR
--thread 0x79686070 id 0xb031b000 [0x2703] (tid_2703) state 7  
--thread 0x79686480 id 0xb041d000 [0x2607] (tid_2607) state 7  
WAITING for 1 threads, got 0 suspended
2015-10-01 20:56:14.955 WatchComplication[59032:21009045] error: suspend_thread suspend took 203 ms, which is more than the allowed 200 ms

but if I move the code to `ApplicationDidFinishLaunching` then `CLKComplicationServer.SharedInstance` is not null.

Does it works if you try to isolate the code ? in that case it might not be an API issue (but a runtime issue).
Comment 2 CraigD 2015-10-01 21:09:18 UTC
I still can't get the `ExtensionDelegate` to work, so I don't have access to `ApplicationDidFinishLaunching`. I will try to figure that out first - I can only assume I have an environment issue - although I can't think what :(
Comment 3 CraigD 2015-10-29 04:39:29 UTC
Works in Preview 2
in `ApplicationDidFinishLaunching`

(sadly `complicationServer.ActiveComplications` is still null - but that's another story).