-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[mono] Add iOS app sample using mono runtime #3931
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
Conversation
48c353a
to
1bfe3d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this example. There are some changes you'll need to make so that this sample shows in the samples browser.
- mono runtime | ||
page_type: sample | ||
name: "iOS Sample: Simple greeting and counter (C#)" | ||
description: "An iOS application that contains an example of embedding the mono runtime to invoke unmanaged code with C#." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need the URL it will be hosted at in the samples browser when published: https://review.docs.microsoft.com/en-us/samples/browse/?branch=master
description: "An iOS application that contains an example of embedding the mono runtime to invoke unmanaged code with C#." | |
description: "An iOS application that contains an example of embedding the mono runtime to invoke unmanaged code with C#." | |
urlFragment: "mono-ios-csharp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the url be generated automatically from adding this line or are there other actionables I need to take to get the sample hosted at the url?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IFAIK you just need to add this line. I have heard rumors though that the samples browser doesn't automatically import samples and you need to file a ticket. I've heard it's "supposed" to be automated but it never shows up and when you ask about it, it magically shows up, as if someone is somewhere pushing a button every time.
@IEvangelist true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My experience is that it takes a long time, roughly a week or so - but it does eventually make its way there. There have been a few times too where it has gotten stuck with no reason why, then you have to ask the right people who have access to get it moved.
core/mono-samples/iOS/README.md
Outdated
products: | ||
- dotnet | ||
- iOS | ||
- mono runtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now this needs to be dotnet-core so that it appears in the filter list for the samples browser. There isn't a product filter for ios and mono runtime unfortunately. We'll need to do something about this in the future though: https://review.docs.microsoft.com/en-us/samples/browse/?branch=master&expanded=dotnet&products=dotnet-core
products: | |
- dotnet | |
- iOS | |
- mono runtime | |
products: | |
- dotnet-core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will there be dotnet5 or dotnet6 added to the product filters in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea. I don't have anything to do with the samples. I'll bring this up to our team and see what they know.
e493254
to
0f84fce
Compare
#3939 needs to be merged to fix the build error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is looking good now. Some minor things to adjust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments, looks good overall :)
core/mono-samples/iOS/Program.csproj
Outdated
@@ -6,13 +6,13 @@ | |||
</PropertyGroup> | |||
|
|||
<ItemGroup> | |||
<PackageReference Include="Microsoft.NET.Runtime.iOS.Sample.Mono" Version="6.0.0-dev" /> | |||
<PackageReference Include="Microsoft.NET.Runtime.iOS.Sample.Mono" Version="6.0.0-*" GeneratePathProperty="true"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this doesn't work on CI because this repo installs the 5.0 dotnet sdk. I tried locally and what works is using $(BundledNETCorePlatformsPackageVersion)
as the version since then it'll try to get the same version as it uses for the runtime pack.
That brings up another issue though, right now it tries to restore Microsoft.NETCore.App.Runtime.ios-x64 with version (= 5.0.0)
but the final 5.0 release isn't published to nuget.org yet. And even if it were we don't really want to use the 5.0 version.
As far as I know the only way to consume 6.0 assets is by installing nightly master builds of the dotnet sdk from the dotnet/installer repo. I don't know if we want to do that in CI in this repo (maybe we just need to skip this project there).
Additionally we can add the following global.json next to Program.csproj to force usage of the 6.0 SDK:
{
"sdk": {
"version": "6.0.100-alpha",
"rollForward": "major",
"allowPrerelease": true
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adegeo Tagging you because you made the last commit to the CI yml. Can we add another leg that installs the net6 preview sdk and builds the iOS project? That seems to be the only way to be correct on CI for us. Otherwise, we can just skip the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@steveisok Sorry, missed this alert. Yeah we could do that easily as long as the dotnet-install powershell script supports it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adegeo Looks like it does with the --version
switch. Would it be easier to bump the sdk version in CI or just add another leg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@steveisok If you can give me the exactly command line I'll edit the script to add a leg. I tried .\dotnet-install.ps1 -version 6.0.100-alpha
but it didn't work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the version at 6.0.100-alpha.1.20531.2
.
Depends on #3941 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we address the comment I made about installing .NET 6, I think we can merge this.
core/mono-samples/iOS/README.md
Outdated
|
||
- Xcode: Any version should work with this sample (download Xcode at <https://developer.apple.com/xcode/>). | ||
- iOS simulator 8.0 or greater. | ||
- Daily master build of the dotnet sdk (<https://github.com/dotnet/installer>). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@steveisok @mdh1418 @akoeplinger
Considering it's not easy to install the .NET 6 SDK at the moment, I would improve this with the specific commands to install. I don't see anyone figuring out how to install. I couldn't and had to have @steveisok help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added more details to install the specific dotnet version. Was this what you meant?
0878a8d
to
652fef6
Compare
054930e
to
615f841
Compare
615f841
to
590a8bb
Compare
@adegeo I made a few more changes and think this PR is ready for another look over. |
Summary
This PR looks to port over the iOS sample from
dotnet/runtime
to highlight the concept of building applications on top of the mono runtime.A recent version of XCode as well as an iOS device or simulator is required to run the sample with
dotnet publish
.The sample will depend on a NuGet Package containing the files that build the app and embed the mono runtime into the app, and the code that will build that package can be found here dotnet/runtime#43048