microsoft / appcenter

Central repository for App Center open source resources and planning.
https://appcenter.ms
Creative Commons Attribution 4.0 International
1.01k stars 225 forks source link

Can't build Xamarin.ios with Xcode 15.1 and SDK 17 #2621

Open victorbeltranpinol opened 6 months ago

victorbeltranpinol commented 6 months ago

Describe the solution you'd like I would like to build the iOS Xamarin Forms using Xamarin.iOS 16.4 and Xcode 15.0.1 Preview

Additional context When I try to build my app in the App Center using: SDK version: Xamarin.iOS 16.4 Xcode version: 15.0.1 Preview

I have many errors like this:

/Users/runner/work/1/s/MyProject/obj/iPhone/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.cs(4,20): error CS0400: The type or namespace name 'System' could not be found in the global namespace (are you missing an assembly reference?) [/Users/runner/work/1/s/MyProject/MyProject.csproj] /Users/runner/work/1/s/MyProject/obj/iPhone/Release/netstandard2.0/MyProject.AssemblyInfo.cs(14,55): error CS0518: Predefined type 'System.String' is not defined or imported [/Users/runner/work/1/s/MyProject/MyProject.csproj]

However, if I run the build using: SDK version: Xamarin.iOS 16.2 Xcode version: 14.2

It works like a charm

I received this email from Apple, therefore I must build the APP using SDK iOS 17 and Xcode 15

ITMS-90725: SDK version issue - This app was built with the iOS 16.2 SDK. Starting April 29, 2024, all iOS and iPadOS apps must be built with the iOS 17 SDK or later, included in Xcode 15 or later, in order to be uploaded to App Store Connect or submitted for distribution.

Is there something not ready in the ios build machines of the App Center? Does somebody have success using xcode 15?

Thanks in advance

follesoe commented 5 months ago

As a bare minimum, Microsoft should ensure AppCenter stays alive and supports the last Xamarin releases, preventing developers from having to waste time on yet a migration (from AppCenter to another build service), and rather can focus on migrating from Xamarin to MAUI.

AngelAndresM commented 5 months ago

Is there any update on this incident?

I also have this problem.

victorbeltranpinol commented 5 months ago

@AngelAndresM not yet. As a workaround I published the app building with a local mac

follesoe commented 5 months ago

One possible solution is to use pre-build scripts to try and install Xcode 15 and the latest Xamarin.iOS versions.

I have also submitted an issue for the macos-12 runner, which is what AppCenter uses, to get the latest Xamarin tools included: https://github.com/actions/runner-images/issues/9512

follesoe commented 5 months ago

I used a similar work-around to install the latest version of Xamarin.Android, to build against Android 34. See comment in issue https://github.com/microsoft/appcenter/issues/2611 for the script.

cjrvdev commented 5 months ago

Honestly doubt there will be support in a long time. I personally raised a ticket in the past to support this and they had it planned for like 1 month later (And when I asked it was already way too late so...)

EmmanVazz commented 5 months ago

One possible solution is to use pre-build scripts to try and install Xcode 15 and the latest Xamarin.iOS versions.

I have also submitted an issue for the macos-12 runner, which is what AppCenter uses, to get the latest Xamarin tools included: actions/runner-images#9512

@follesoe Can you post the pre-build script you used here? I think many of us will need it. Thanks!

follesoe commented 5 months ago

@EmmanVazz I believe Xcode 15 is installed already. I have not done manual installs of Xamarin.iOS yet, but this is how I did it for Xamarin.Android:

#!/usr/bin/env bash
PKG_URL="https://dl.xamarin.com/MonoforAndroid/Mac/xamarin.android-13.2.2.0.pkg"
PKG_NAME=${PKG_URL##*/}
curl -4fsLo "${PKG_NAME}" "${PKG_URL}"
sudo installer -pkg "${PKG_NAME}" -target /
noahcolvin commented 5 months ago

Not sure the above pre-build script (modified for Xamarin.iOS) will work here. My build is already installing xamarin.ios-16.4.0.23.pkg and is using the macos-13 image, not 12 like stated above. I'm getting the same errors as OP so there might be more to it.

AjitKRuin commented 5 months ago

@victorbeltranpinol , how do you update Xamarin.iOS to 16.4 in cs proj or code level in Xamarin iOS project? do we need to change any package as for me I kept Xamarin.IOS as reference only how can we update?

rafageist commented 5 months ago

@AjitKRuin You don't need to change your project. Migrate to Github Actions with:

happy hacking

jdinnen commented 4 months ago

I was experiencing a similar issue, it was the nuget restore for solution failing as it was trying to restore things for Android also, even though I am building the iOS csproj.

##[group]Runner Image
Image: macos-13
Version: 20240405.2
Included Software: https://github.com/actions/runner-images/blob/macos-13/20240405.2/images/macos/macos-13-Readme.md
Image Release: https://github.com/actions/runner-images/releases/tag/macos-13%2F20240405.2

This is the error in the nuget restore

/Users/runner/work/1/s/JobTask/JobTask.Android/JobTask.Android.csproj(321,11): error MSB4226: The imported project "/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.CSharp.targets" was not found. Also, tried to find "Xamarin/Android/Xamarin.Android.CSharp.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "/Library/Frameworks/Mono.framework/External/xbuild/" . These search paths are defined in "/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/MSBuild.dll.config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.

Anyway the work around was to add an appcenter-post-clone.sh to the iOS directory and add the following to it, since it seems to be missing something to do with Android...

#!/bin/bash

brew install --cask xamarin-ios 
brew install --cask xamarin-android

Now it installs xamarin-android... FWIW, you can just have the android install as the build scrip will install xamarin-ios later if it is missing. This works for me at least..

noahcolvin commented 4 months ago

Thanks @jdinnen that worked for me! I had tried adding those to the pre-build script before without luck but the post-clone did the trick. I hadn't noticed any errors in the logs related to Android but this did something. TestFlight is reporting the iOS 17 SDK and I'm not seeing any issues running the app.

juanpgallardo commented 4 months ago

Thanks @jdinnen. I can confirm that your solution works. The issue, as you mentioned, was caused by errors during the nuget restore for the Android projects, so, installing the xamarin-android cask on the appcenter-post-clone.sh seems to workaround this issue.

I think this is probably an Appcenter bug, as it doesn't make sense that we need to worry about the android projects during the iOS build. Also, it only happens when upgrading to XCode 15.0.1 Preview, SDK version: Xamarin.iOS 16.4.

AmaluThomas commented 4 months ago

Thanks @jdinnen that worked for me! I had tried adding those to the pre-build script before without luck but the post-clone did the trick. I hadn't noticed any errors in the logs related to Android but this did something. TestFlight is reporting the iOS 17 SDK and I'm not seeing any issues running the app.

Are you able to upload app to testflight with sdk 17 for ios?

noahcolvin commented 4 months ago

@AmaluThomas Yes, TestFlight is reporting the iOS 17 SDK and it was approved by Apple.

Nikclim commented 3 months ago

@EmmanVazz I believe Xcode 15 is installed already. I have not done manual installs of Xamarin.iOS yet, but this is how I did it for Xamarin.Android:

#!/usr/bin/env bash
PKG_URL="https://dl.xamarin.com/MonoforAndroid/Mac/xamarin.android-13.2.2.0.pkg"
PKG_NAME=${PKG_URL##*/}
curl -4fsLo "${PKG_NAME}" "${PKG_URL}"
sudo installer -pkg "${PKG_NAME}" -target /

Maybe I do something wrong, but it doesn't work for me. I've tried to insert it into pre-build script for android and for ios but build is steal crashing.

Nikclim commented 3 months ago

I was experiencing a similar issue, it was the nuget restore for solution failing as it was trying to restore things for Android also, even though I am building the iOS csproj.

##[group]Runner Image
Image: macos-13
Version: 20240405.2
Included Software: https://github.com/actions/runner-images/blob/macos-13/20240405.2/images/macos/macos-13-Readme.md
Image Release: https://github.com/actions/runner-images/releases/tag/macos-13%2F20240405.2

This is the error in the nuget restore

/Users/runner/work/1/s/JobTask/JobTask.Android/JobTask.Android.csproj(321,11): error MSB4226: The imported project "/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.CSharp.targets" was not found. Also, tried to find "Xamarin/Android/Xamarin.Android.CSharp.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "/Library/Frameworks/Mono.framework/External/xbuild/" . These search paths are defined in "/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/MSBuild.dll.config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.

Anyway the work around was to add an appcenter-post-clone.sh to the iOS directory and add the following to it, since it seems to be missing something to do with Android...

#!/bin/bash

brew install --cask xamarin-ios 
brew install --cask xamarin-android

Now it installs xamarin-android... FWIW, you can just have the android install as the build scrip will install xamarin-ios later if it is missing. This works for me at least..

It's a pity, but it doesn't work for me. Should I add something more in the post-clone script?

BitProgress commented 3 months ago

Thanks @jdinnen that worked for me. A little note... If you point to ".sln", the appcenter-post-clone.sh must be located in directory of ".sln" file. If you point to ".prj", the appcenter-post-clone.sh must be located in directory ".prj" file.

Rikard-sut commented 2 months ago

I was experiencing a similar issue, it was the nuget restore for solution failing as it was trying to restore things for Android also, even though I am building the iOS csproj.

##[group]Runner Image
Image: macos-13
Version: 20240405.2
Included Software: https://github.com/actions/runner-images/blob/macos-13/20240405.2/images/macos/macos-13-Readme.md
Image Release: https://github.com/actions/runner-images/releases/tag/macos-13%2F20240405.2

This is the error in the nuget restore

/Users/runner/work/1/s/JobTask/JobTask.Android/JobTask.Android.csproj(321,11): error MSB4226: The imported project "/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.CSharp.targets" was not found. Also, tried to find "Xamarin/Android/Xamarin.Android.CSharp.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "/Library/Frameworks/Mono.framework/External/xbuild/" . These search paths are defined in "/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/MSBuild.dll.config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.

Anyway the work around was to add an appcenter-post-clone.sh to the iOS directory and add the following to it, since it seems to be missing something to do with Android...

#!/bin/bash

brew install --cask xamarin-ios 
brew install --cask xamarin-android

Now it installs xamarin-android... FWIW, you can just have the android install as the build scrip will install xamarin-ios later if it is missing. This works for me at least..

Ive added the post clone script, appcenter tells me the sdk is not available on agent.

_[command]/bin/bash /Users/runner/runners/3.240.1/scripts/select-xamarin-sdk.sh 6_1225 Xamarin SDK not available on agent. ==> Downloading https://download.visualstudio.microsoft.com/download/pr/ceb0ea3f-4db8-46b4-8dc3-8049d27c0107/3960868aa9b1946a6c77668c3f3334ee/xamarin.ios-16.4.0.23.pkg ==> Installing Cask xamarin-ios Warning: macOS's Gatekeeper has been disabled for this Cask ==> Running installer for xamarin-ios with sudo; the password may be necessary. installer: Package name is Xamarin.iOS installer: Installing at base path / installer: The install was successful. 🍺 xamarin-ios was successfully installed!

Then i still receive the exact same error when it's trying to restore nugets for android...

MohamadAminSoltani commented 1 month ago

I was experiencing a similar issue, it was the nuget restore for solution failing as it was trying to restore things for Android also, even though I am building the iOS csproj.

##[group]Runner Image
Image: macos-13
Version: 20240405.2
Included Software: https://github.com/actions/runner-images/blob/macos-13/20240405.2/images/macos/macos-13-Readme.md
Image Release: https://github.com/actions/runner-images/releases/tag/macos-13%2F20240405.2

This is the error in the nuget restore

/Users/runner/work/1/s/JobTask/JobTask.Android/JobTask.Android.csproj(321,11): error MSB4226: The imported project "/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.CSharp.targets" was not found. Also, tried to find "Xamarin/Android/Xamarin.Android.CSharp.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "/Library/Frameworks/Mono.framework/External/xbuild/" . These search paths are defined in "/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/MSBuild.dll.config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.

Anyway the work around was to add an appcenter-post-clone.sh to the iOS directory and add the following to it, since it seems to be missing something to do with Android...

#!/bin/bash

brew install --cask xamarin-ios 
brew install --cask xamarin-android

Now it installs xamarin-android... FWIW, you can just have the android install as the build scrip will install xamarin-ios later if it is missing. This works for me at least..

It's a pity, but it doesn't work for me. Should I add something more in the post-clone script?

in appcenter in build configuration under build app section. set project combo on .csproj not the sln. this action solved my problem with that post clone script