Bug 58521 - Xamarin.Mac Today extension fails to display
Summary: Xamarin.Mac Today extension fails to display
Status: RESOLVED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Other ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-08-01 11:49 UTC by jeroen.bernsen
Modified: 2017-08-11 14:16 UTC (History)
3 users (show)

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


Attachments
Solution with Today Extension (472.47 KB, application/zip)
2017-08-01 16:15 UTC, jeroen.bernsen
Details


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:
Status:
RESOLVED FIXED

Description jeroen.bernsen 2017-08-01 11:49:11 UTC
I need to build a Mac Today Extension. I took the sample (https://developer.xamarin.com/samples/mac/ExtensionSamples/) and got it to compile (after fixing #58479). After running the example I add the today extension to my today list.

Now the widget does show up but stays empty and shows nothing (it has no height), it should display something like the remaining nr of days in the year.

Then I checked the system log and it shows: "Service exited with abnormal code: 1"
 
Aug  1 13:16:09 Jeroens-MacBook-Pro com.apple.xpc.launchd[1] (com.your-company.TodayExtension[5641]): Service exited with abnormal code: 1
Aug  1 13:16:09 Jeroens-MacBook-Pro com.apple.xpc.launchd[1] (com.apple.imfoundation.IMRemoteURLConnectionAgent): Unknown key for integer: _DirtyJetsamMemoryLimit


I tried adding further logging information with NSLog, but no logging shows up so seems like a startup problem ?

My environment:

Visual Studio Community 2017 for Mac
Version 7.0.1 (build 24)
Installation UUID: c267e52d-f329-45c3-8c20-31e921fde950
Runtime:
	Mono 5.0.1.1 (2017-02/5077205) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 500010001

NuGet
Version: 4.0.0.2323

.NET Core
Runtime: /usr/local/share/dotnet/dotnet
SDK: /usr/local/share/dotnet/sdk/1.0.3/Sdks
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/msbuild/15.0/bin/Sdks

Xamarin.Profiler
Version: 1.5.4
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Apple Developer Tools
Xcode 8.3.3 (12175.1)
Build 8E3004b

Xamarin.Android
Version: 7.3.1.2 (Visual Studio Community)
Android SDK: /Users/jeroenbernsen/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		6.0 (API level 23)
		7.1 (API level 25)

SDK Tools Version: 26.0.2
SDK Platform Tools Version: 25.0.5
SDK Build Tools Version: 23.0.2

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Xamarin.Mac
Version: 3.4.0.36 (Visual Studio Community)

Xamarin.iOS
Version: 10.10.0.36 (Visual Studio Community)
Hash: d2270eec
Branch: d15-2
Build date: 2017-05-22 16:30:53-0400

Xamarin Inspector
Version: 1.2.2
Hash: b71b035
Branch: d15-1
Build date: Fri, 21 Apr 2017 17:57:12 GMT

Build Information
Release ID: 700010024
Git revision: 7ab1ca2ced6f584e56b7a0d4d321d00775cd95c9
Build date: 2017-05-19 05:44:51-04
Xamarin addins: 08d17158f3365beee5e60f67999e607cce4b3f93
Build lane: monodevelop-lion-d15-2

Operating System
Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
    Thu Jun 15 17:36:27 PDT 2017
    root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64
Comment 1 Chris Hamons 2017-08-01 13:24:09 UTC
Can you attach the project and/or binary to the bug?

Have you enabled code signing?

Apple is _very_ particular about macOS extensions, they have to be signed, in a signed application bundle. You have to run the main application at least once for it to show up, then manually enable the extension in question.
Comment 2 jeroen.bernsen 2017-08-01 16:15:38 UTC
Created attachment 23947 [details]
Solution with Today Extension
Comment 3 jeroen.bernsen 2017-08-01 16:22:16 UTC
OK I enabled code signing, but still the widget shows up empty, so still not working. I included the solution I used. Hope you can help fix this

I found three suspicious messages in the System.log:
--------------
SandboxViolation: TodayExtension(869) deny mach-lookup com.apple.GameController.gamecontrollerd
Violation:       deny mach-lookup com.apple.GameController.gamecontrollerd 
Process:         TodayExtension [869]
Path:            /Users/jeroenbernsen/Downloads/ExtensionSamples/ExtensionSamples/bin/Debug/ExtensionSamples.app/Contents/PlugIns/TodayExtension.appex/Contents/MacOS/TodayExtension
Load Address:    0x10d6c5000
Identifier:      com.blueedge.TodayExtension
Version:         1 (1.0)
Code Type:       x86_64 (Native)
Parent Process:  launchd [1]
Responsible:     /Users/jeroenbernsen/Downloads/ExtensionSamples/ExtensionSamples/bin/Debug/ExtensionSamples.app/Contents/PlugIns/TodayExtension.appex/Contents/MacOS/TodayExtension [869]
User ID:         501
--------------
<rdar://problem/11489077> A sandboxed application with pid 869, "TodayExtension" checked in with appleeventsd, but its code signature could not be read and validated by appleeventsd, and so it cannot receive AppleEvents targeted by name, bundle id, or signature. Install the application in /Applications/ or some other world readable location to resolve this issue. Error=ERROR: #100013  { "NSDescription"="SecCodeCopySigningInformation() returned 100013, -." }  (handleMessage()/appleEventsD.cp #2102) com.apple.root.default-qos
--------------
Unhandled Exception:
ObjCRuntime.RuntimeException: Could not find the assembly $TodayExtension in the loaded assemblies.
Comment 4 Chris Hamons 2017-08-03 20:22:19 UTC
Hmm. I was able to run it:

https://www.dropbox.com/s/5zaxeugsvrt57bo/Screen%20Shot%202017-08-03%20at%202.55.22%20PM.png?dl=0

Your error message suggests issue with code signing.

A few things you can try:

- Run codesign --verify --deep --strict --verbose=2 ExtensionSamples.app/ on your binary, which is similar to what GateKeeper does
- Create a simple Cocoa app in cocoa and setup code signing on that. That might download keys/profiles that are missing on your machine. When that works, retry your application.
Comment 5 jeroen.bernsen 2017-08-07 09:33:53 UTC
Thanks for trying, your help is greatly appreciated. I spend another day on it and still cannot get it to run. I am 99% sure the keys/profiles are correct. I created a simple sample app the same problem. 

I fixed one of the "codesignature could not be read" event by outputing to "/Applications/" but still 2 errors that are suspicious:

1) SandboxViolation: TodayExtension(1195) deny mach-lookup com.apple.GameController.gamecontrollerd

2) Unhandled Exception:
ObjCRuntime.RuntimeException: Could not find the assembly $TodayExtension in the loaded assemblies.

I uploaded my binary output here: https://www.dropbox.com/s/1wz86v0w2cpwigy/ExtensionSamplesDir.zip?dl=0 , could you take a loot at it ?

Furthermore a few questions since I don't know where to look anymore:
- Did you test with the attached solution ?
- Do you run on Mac OS X 10.12 (.6) ?
- Did you enable signing on the installer package ? because I did not do that
- Is there a need to enable any special application services in the provisioning profile ?
Comment 6 jeroen.bernsen 2017-08-07 09:52:35 UTC
Oh yes and did you use msbuild or xbuild ?
Comment 7 Chris Hamons 2017-08-08 16:05:35 UTC
So when I run your binary I get:

Termination Reason:    Namespace CODESIGNING, Code 0x1

likely because I don't have your certificate.

Codesign seems happy enough:

 $ codesign --verify --deep --strict --verbose=2 /Users/donblas/Downloads/ExtensionSamplesDir/ExtensionSamples.app 
--prepared:/Users/donblas/Downloads/ExtensionSamplesDir/ExtensionSamples.app/Contents/PlugIns/TodayExtension.appex
--validated:/Users/donblas/Downloads/ExtensionSamplesDir/ExtensionSamples.app/Contents/PlugIns/TodayExtension.appex
/Users/donblas/Downloads/ExtensionSamplesDir/ExtensionSamples.app: valid on disk
/Users/donblas/Downloads/ExtensionSamplesDir/ExtensionSamples.app: satisfies its Designated Requirement


You should be able to ignore this warning:
   1) SandboxViolation: TodayExtension(1195) deny mach-lookup com.apple.GameController.gamecontrollerd

It is just noting we loaded the game controller framework, since you did not link, and you don't have that in your sandbox.

The installer package is not needed and you can uncheck that completely.

Let me re-run things with XM 3.4 installed to double check that.
Comment 8 Chris Hamons 2017-08-08 18:40:06 UTC
So when I run with Stable 3.4 msbuild I get this error on building:

/Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(5,5): Error: The OutputPath property is not set for project 'TodayExtension.csproj'.  Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='Debug'  Platform='x86'.  This error may also appear if some other project is trying to follow a project-to-project reference to this project, this project has been unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform. (ExtensionSamples)

which is this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=57495

Swapping back to xbuild, or using 3.6 (from https://jenkins.mono-project.com/view/Xamarin.MaciOS/job/xamarin-macios-builds-d15-4/) with msbuild both work for me.

I must have originally tested this with 3.6 installed.
Comment 9 Chris Hamons 2017-08-08 18:42:40 UTC
Have you tried running an obj-c extension project from xcode and see if your keys on _that_ work?
Comment 10 victor 2017-08-10 10:56:09 UTC
So, for anyone coming up on this, I will explain what is happening. I spent 3 days trying to make the today widget work, xamarin.mac is the problem.

SWITCH TO BETA branch (XAMARIN.MAC 3.6) in Check for updates under VisualStudio menu bar tab.

Building a Today Extension in Visual Studio 15.2 which has Xamarin.Mac 3.4 throws "Service exited with abnormal code: 1" errorwhen trying to run it and the extension itself has no body. Using Xamarin.Mac 3.6 fixes it (Visual Studio 15.3)
Comment 11 jeroen.bernsen 2017-08-11 10:23:42 UTC
Thanks for the info that saves me a lot of trouble trying. I prefer not to switch to the beta channel because I am afraid of a lot of problems with my currently pretty stable environment. What is the expected release data of VS 15.3 on the stable channel ?
Comment 12 Chris Hamons 2017-08-11 14:16:15 UTC
The beta channel has d15-3 previews. I would expect it to hit stable in the order of weeks.

To be honest though, there are zero expected changes in Xamarin.Mac and few if any in Visual Studio for Mac at this point, so it should be rather stable to move to.