Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for arbitrary extensions to be bundled in XI/XM apps #9048

Merged
merged 14 commits into from
Jul 16, 2020

Conversation

chamons
Copy link
Contributor

@chamons chamons commented Jul 9, 2020

  • This commit adds a hook, "AdditionalAppExtensions", to the msbuild to allow
    extensions written in other languages, such as Swift, to be embedded and signed in an
    Xamarin iOS/Mac App bundle easily.
  • Example:
<AdditionalAppExtensions Include="$(MSBuildProjectDirectory)/../../native">
        <Name>NativeTodayExtension</Name>
        <BuildOutput Condition="'$(Platform)' == 'iPhone'">build/Debug-iphoneos</BuildOutput>
        <BuildOutput Condition="'$(Platform)' == 'iPhoneSimulator'">build/Debug-iphonesimulator</BuildOutput>
</AdditionalAppExtensions>

Consider reviewing commit by commit, as last two are "stock" test projects and noisy.

…tion bundle

- This commit adds a hook, "AdditionalAppExtensions", to the msbuild to allow
extensions written in other languages, such as Swift, to be embedded and signed in an
Xamarin App bundle easily.
- Example:
<AdditionalAppExtensions Include="$(MSBuildProjectDirectory)/../../native">
	<Name>NativeTodayExtension</Name>
	<BuildOutput Condition="'$(Platform)' == 'iPhone'">build/Debug-iphoneos</BuildOutput>
	<BuildOutput Condition="'$(Platform)' == 'iPhoneSimulator'">build/Debug-iphonesimulator</BuildOutput>
</AdditionalAppExtensions>
- Tests added in next commit for easier review
- Outside of the .gitignore, and making all the projects have the same
bundle ID, not much to see here
- Not much to see here either, just lining up the bundle ID
@chamons chamons added the note-highlight Worth calling out specifically in release notes label Jul 9, 2020
@chamons chamons requested a review from emaf as a code owner July 9, 2020 17:40
@monojenkins

This comment has been minimized.

Comment on lines 571 to +572
_ResolveAppExtensionReferences;
_ExtendAppExtensionReferences;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably remove _ResolveAppExtensionReferences here, since _ExtendAppExtensionReferences depends on _ResolveAppExtensionReferences. Optional, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathanpeppers would that still run _ResolveAppExtensionReferences even if _ExtendAppExtensionReferences's Condition was false?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it will , the condition only applies to the current target, not its dependency chain.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to test this!

It seems the dependency chain is not executed: https://gist.github.com/rolfbjarne/86fa3d32923fe7198549534ca00a850d

And the MSBuild documentation says: "If the condition evaluates to false, the target will not execute the body of the target or any targets that are set in the DependsOnTargets attribute." (https://docs.microsoft.com/en-us/visualstudio/msbuild/target-element-msbuild?view=vs-2019)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must have been thinking about Inputs/Outputs then.

@monojenkins
Copy link
Collaborator

Build failure
Provisioning succeeded
Build succeeded
API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Test run failed 🔥

Test results

2 tests failed, 157 tests passed.

Failed tests

  • mmptest/macOS/Debug: Failed (Execution failed with exit code 2)
  • MSBuild tests/iOS: Failed (Execution failed with exit code 1)

// NativeContainer
//
// Created by Chris Hamons on 7/7/20.
// Copyright © 2020 Chris Hamons. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove this?

Comment on lines 571 to +572
_ResolveAppExtensionReferences;
_ExtendAppExtensionReferences;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathanpeppers would that still run _ResolveAppExtensionReferences even if _ExtendAppExtensionReferences's Condition was false?

msbuild/Xamarin.Shared/Xamarin.Shared.targets Outdated Show resolved Hide resolved
@monojenkins
Copy link
Collaborator

Build failure
Provisioning succeeded
Build succeeded
API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Test run failed 🔥

Test results

2 tests failed, 157 tests passed.

Failed tests

  • mmptest/macOS/Debug: Failed (Execution failed with exit code 2)
  • MSBuild tests/iOS: Failed (Execution failed with exit code 1)

@rolfbjarne
Copy link
Member

rolfbjarne commented Jul 10, 2020

@chamons looks like the xcode projects are failing code signing in xcodebuild:

error: No profiles for 'com.xamarin.extension.widget' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.xamarin.extension.widget'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'NativeTodayExtension' from project 'NativeContainer')

Maybe it would be possible to disable signing completely for the native extensions?

@chamons
Copy link
Contributor Author

chamons commented Jul 10, 2020

I'm having trouble convincing Xcode to not sign the extension :(

@monojenkins
Copy link
Collaborator

Build failure
Provisioning succeeded
Build succeeded
API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Test run failed 🔥

Test results

3 tests failed, 156 tests passed.

Failed tests

  • monotouch-test/tvOS - simulator/Debug (LinkSdk): Failed
  • monotouch-test/watchOS 32-bits - simulator/Debug: Failed Known issue: HE0038)
  • MSBuild tests/iOS: Failed (Execution failed with exit code 1)

@chamons
Copy link
Contributor Author

chamons commented Jul 13, 2020

Looking into failures now.

This is legit:

17:32:43.8127290 1) Failed : Xamarin.iOS.Tasks.EmbeddedExtension("iPhoneSimulator").BasicTest
17:32:43.8127990   Expected: 0
17:32:43.8128330   But was:  65
17:32:43.8128570   at Xamarin.iOS.Tasks.EmbeddedExtension.BasicTest () [0x00151] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/EmbeddedExtension.cs:32 

@monojenkins
Copy link
Collaborator

Build failure
Build failed or was aborted

Provisioning succeeded
Build succeeded
API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)

@monojenkins
Copy link
Collaborator

Build failure
Provisioning succeeded
Build succeeded
API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Test run failed 🔥

Test results

2 tests failed, 158 tests passed.

Failed tests

  • monotouch-test/watchOS 32-bits - simulator/Debug: Failed Known issue: HE0038)
  • MSBuild tests/iOS: Failed (Execution failed with exit code 1)

@monojenkins
Copy link
Collaborator

Build failure
Provisioning succeeded
Build succeeded
API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Test run failed 🔥

Test results

1 tests failed, 159 tests passed.

Failed tests

  • MSBuild tests/iOS: Failed (Execution failed with exit code 1)

@rolfbjarne
Copy link
Member

This is the build error:

error: An empty identity is not valid when signing a binary for the product type 'App Extension'. (in target 'NativeTodayExtension' from project 'NativeContainer')

😞

@monojenkins
Copy link
Collaborator

Build failure
Provisioning succeeded
Build succeeded
API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Test run failed 🔥

Test results

1 tests failed, 159 tests passed.

Failed tests

  • MSBuild tests/iOS: Failed (Execution failed with exit code 1)

@chamons
Copy link
Contributor Author

chamons commented Jul 15, 2020

Still looking at this:

18:09:51.2682990   Build Failed:Command line invocation:    /Applications/Xcode_11.5.0.app/Contents/Developer/usr/bin/xcodebuild -configuration Debug -target NativeTodayExtension -arch x86_64 buildBuild settings from command line:    ARCHS = x86_64note: Using new build systemnote: Planning buildnote: Constructing build descriptionerror: An empty identity is not valid when signing a binary for the product type 'App Extension'. (in target 'NativeTodayExtension' from project 'NativeContainer')warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s). (in target 'NativeTodayExtension' from project 'NativeContainer')** BUILD FAILED **

I can reproduce it locally now.

@monojenkins
Copy link
Collaborator

Build failure
Provisioning succeeded
Build succeeded
API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Test run failed 🔥

Test results

3 tests failed, 157 tests passed.

Failed tests

  • monotouch-test/iOS Unified 64-bits - simulator/Release (all optimizations): Failed
  • monotouch-test/watchOS 32-bits - simulator/Debug: Failed Known issue: HE0038)
  • [NUnit] Mono MonoRuntimeTests/watchOS 32-bits - simulator/Debug: HarnessException (Harness exception for '[NUnit] Mono MonoRuntimeTests': System.IO.FileNotFoundException: Could not find file "/Users/builder/jenkins/workspace/xamarin-macios-pr-builder/jenkins-results/tests/[NUnit]-Mono-MonoRuntimeTests/196/vsts-nunit-test-watchos-20200715_151525.xml"
    File name: '/Users/builder/jenkins/workspace/xamarin-macios-pr-builder/jenkins-results/tests/[NUnit]-Mono-MonoRuntimeTests/196/vsts-nunit-test-watchos-20200715_151525.xml'
    at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x00259] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/FileStream.cs:274
    at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/FileStream.cs:106
    at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions)
    at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize) [0x00055] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/IO/StreamReader.cs:182
    at System.IO.StreamReader..ctor (System.String path, System.Boolean detectEncodingFromByteOrderMarks) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/IO/StreamReader.cs:157
    at System.IO.StreamReader..ctor (System.String path) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/IO/StreamReader.cs:152
    at (wrapper remoting-invoke-with-check) System.IO.StreamReader..ctor(string)
    at Microsoft.DotNet.XHarness.iOS.Shared.TestReporter.ParseResultFile (Microsoft.DotNet.XHarness.iOS.Shared.AppBundleInformation appInfo, System.String test_log_path, System.Boolean timed_out) [0x00330] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/xharness/Microsoft.DotNet.XHarness.iOS.Shared/TestReporter.cs:336
    at Microsoft.DotNet.XHarness.iOS.Shared.TestReporter.TestsSucceeded (Microsoft.DotNet.XHarness.iOS.Shared.AppBundleInformation appInfo, System.String test_log_path, System.Boolean timed_out) [0x00032] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/xharness/Microsoft.DotNet.XHarness.iOS.Shared/TestReporter.cs:368
    at Microsoft.DotNet.XHarness.iOS.Shared.TestReporter.ParseResult () [0x000cf] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/xharness/Microsoft.DotNet.XHarness.iOS.Shared/TestReporter.cs:451
    at Xharness.AppRunner.RunAsync () [0x01528] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/xharness/AppRunner.cs:429
    at Xharness.TestTasks.RunSimulator.RunTestAsync () [0x002b1] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/xharness/TestTasks/RunSimulator.cs:124
    at Xharness.TestTasks.RunTest.ExecuteAsync () [0x001b9] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/xharness/TestTasks/RunTest.cs:107
    at Microsoft.DotNet.XHarness.iOS.Shared.Tasks.TestTasks.RunInternalAsync () [0x00226] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/xharness/Microsoft.DotNet.XHarness.iOS.Shared/Tasks/TestTask.cs:283 )

@chamons
Copy link
Contributor Author

chamons commented Jul 15, 2020

Failures:

3rd one is super strange, rekicking

@chamons
Copy link
Contributor Author

chamons commented Jul 15, 2020

build

@monojenkins
Copy link
Collaborator

Build failure
Provisioning succeeded
Build succeeded
API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Test run failed 🔥

Test results

1 tests failed, 159 tests passed.

Failed tests

  • [NUnit] Mono MonoRuntimeTests/watchOS 32-bits - simulator/Debug: HarnessException (Harness exception for '[NUnit] Mono MonoRuntimeTests': System.IO.FileNotFoundException: Could not find file "/Users/builder/jenkins/workspace/xamarin-macios-pr-builder/jenkins-results/tests/[NUnit]-Mono-MonoRuntimeTests/196/vsts-nunit-test-watchos-20200715_184051.xml"
    File name: '/Users/builder/jenkins/workspace/xamarin-macios-pr-builder/jenkins-results/tests/[NUnit]-Mono-MonoRuntimeTests/196/vsts-nunit-test-watchos-20200715_184051.xml'
    at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x00259] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/FileStream.cs:274
    at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/FileStream.cs:106
    at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions)
    at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize) [0x00055] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/IO/StreamReader.cs:182
    at System.IO.StreamReader..ctor (System.String path, System.Boolean detectEncodingFromByteOrderMarks) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/IO/StreamReader.cs:157
    at System.IO.StreamReader..ctor (System.String path) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/IO/StreamReader.cs:152
    at (wrapper remoting-invoke-with-check) System.IO.StreamReader..ctor(string)
    at Microsoft.DotNet.XHarness.iOS.Shared.TestReporter.ParseResultFile (Microsoft.DotNet.XHarness.iOS.Shared.AppBundleInformation appInfo, System.String test_log_path, System.Boolean timed_out) [0x00330] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/xharness/Microsoft.DotNet.XHarness.iOS.Shared/TestReporter.cs:336
    at Microsoft.DotNet.XHarness.iOS.Shared.TestReporter.TestsSucceeded (Microsoft.DotNet.XHarness.iOS.Shared.AppBundleInformation appInfo, System.String test_log_path, System.Boolean timed_out) [0x00032] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/xharness/Microsoft.DotNet.XHarness.iOS.Shared/TestReporter.cs:368
    at Microsoft.DotNet.XHarness.iOS.Shared.TestReporter.ParseResult () [0x000cf] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/xharness/Microsoft.DotNet.XHarness.iOS.Shared/TestReporter.cs:451
    at Xharness.AppRunner.RunAsync () [0x01528] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/xharness/AppRunner.cs:429
    at Xharness.TestTasks.RunSimulator.RunTestAsync () [0x002b1] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/xharness/TestTasks/RunSimulator.cs:124
    at Xharness.TestTasks.RunTest.ExecuteAsync () [0x001b9] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/xharness/TestTasks/RunTest.cs:107
    at Microsoft.DotNet.XHarness.iOS.Shared.Tasks.TestTasks.RunInternalAsync () [0x00226] in /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/xharness/Microsoft.DotNet.XHarness.iOS.Shared/Tasks/TestTask.cs:283 )

@rolfbjarne
Copy link
Member

The failing test is a known issue: https://github.com/xamarin/maccore/issues/2267

@chamons chamons merged commit 5657a63 into xamarin:main Jul 16, 2020
@chamons chamons deleted the ios-native-extensions branch July 16, 2020 15:13
chamons added a commit to chamons/xamarin-macios that referenced this pull request Jul 16, 2020
…arin#9048)

- This commit adds a hook, "AdditionalAppExtensions", to the msbuild to allow
extensions written in other languages, such as Swift, to be embedded and signed in an
Xamarin App bundle easily.
- Example:
<AdditionalAppExtensions Include="$(MSBuildProjectDirectory)/../../native">
	<Name>NativeTodayExtension</Name>
	<BuildOutput Condition="'$(Platform)' == 'iPhone'">build/Debug-iphoneos</BuildOutput>
	<BuildOutput Condition="'$(Platform)' == 'iPhoneSimulator'">build/Debug-iphonesimulator</BuildOutput>
</AdditionalAppExtensions>
chamons added a commit that referenced this pull request Jul 27, 2020
…) (#9107)

- This commit adds a hook, "AdditionalAppExtensions", to the msbuild to allow
extensions written in other languages, such as Swift, to be embedded and signed in an
Xamarin App bundle easily.
- Example:
<AdditionalAppExtensions Include="$(MSBuildProjectDirectory)/../../native">
	<Name>NativeTodayExtension</Name>
	<BuildOutput Condition="'$(Platform)' == 'iPhone'">build/Debug-iphoneos</BuildOutput>
	<BuildOutput Condition="'$(Platform)' == 'iPhoneSimulator'">build/Debug-iphonesimulator</BuildOutput>
</AdditionalAppExtensions>
@chamons chamons mentioned this pull request Sep 16, 2020
@BjornVanslembrouck
Copy link

I almost got this working with a Sharing Extension, but when trying to build, the signing keeps failing.
Looking through the build logs, it seems that when signing the iOS project it passes in a - for the signing identity, but when it signs the extension, it signs it with iPhone Developer

Target _CodesignFrameworks:
    Tool /usr/bin/codesign execution started with arguments: -v --force --timestamp=none --sign - --timestamp=none "xyz/bin/iPhoneSimulator/Debug/device-builds/iphone 11 pro-14.0/test.app/Frameworks/Mono.framework/Mono"
            
    Creating directory "obj/iPhoneSimulator/Debug/device-builds/iphone 11 pro-14.0/codesign".
    Creating "obj/iPhoneSimulator/Debug/device-builds/iphone 11 pro-14.0/codesign/Mono" because "AlwaysCreate" was specified.
Target _CodesignFrameworks:
    Tool /usr/bin/codesign execution started with arguments: -v --force --timestamp=none --sign - --timestamp=none "xyz/bin/iPhoneSimulator/Debug/device-builds/iphone 11 pro-14.0/test.app/Frameworks/libSkiaSharp.framework/libSkiaSharp"
            
    Creating "obj/iPhoneSimulator/Debug/device-builds/iphone 11 pro-14.0/codesign/libSkiaSharp" because "AlwaysCreate" was specified.
Target _CodesignAppExtensions:
    Tool /usr/bin/codesign execution started with arguments: -v --force --timestamp=none --sign "iPhone Developer" --timestamp=none "xyz/bin/iPhoneSimulator/Debug/device-builds/iphone 11 pro-14.0/test.app/PlugIns/share-extension.appex"

In my Xamarin.iOS project, the signing is set to Developer (Automatic) and the same checkbox is ticked in Xcode for both the dummy parent app and the extension.

Both the Provisioning Profiles and the Signing Certificates are OK, as when I run it directly from Xcode, there are no issues.

If however I set the signing to my actual account in the Xamarin.iOS project, it seems to work fine, but that then becomes a potential problem if other people work on the same project and have different Signing Identities

Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
note-highlight Worth calling out specifically in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants