question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to build projects due to Xcode mismatch

See original GitHub issue

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

Running on macOS 12 with Xcode 14.2, having Visual Studio Mac 17.5.4 installed, and a handful of .NET SDK 7.0.1xx and 7.0.2xx installed (including 7.0.203 which appears to be required by this version of VS Mac). If I try to build a project targeted to either net6.0-ios or net6.0-ios14.2 (if this doesn’t say to use Xcode 14.2, then what in the world is it meant for?) I cannot for the life of me get an ios project to build because of a complaint that “this version of microsoft.ios needs the headers from Xcode 14.3” during the IL trimming phase. First of all… what version is this referring to? I’m guessing that it is talking about the ios workload?

Ok so experimentation time. I first tried to roll back to the packages (is there a source that says which version of the workloads requires what Xcode?) and set up a global.json to push me back to 7.0.103 for building. This fails even sooner, as it complains that Microsoft.Maui is linked with Microsoft.iOS 16.4, while I am only linking with 16.2. I can’t figure out how to downgrade Maui here either…

The message suggests a workaround, though I have found reason to believe that the workaround is bogus and does nothing. That is, it suggests that I change the linking settings to “Link Framework SDKs only”. Brilliant…except that’s already what it was set to. So no dice here either.

Furthermore, it suggests that I can disable trimming by setting PublishTrimmed to false. Ok cool…now it complains that iOS must have PublishTrimmed set to true. Now it almost feels like intentional trolling.

Is the only remedy at this point to find out which version of vs mac uses 7.0.1xx, downgrade to that somehow, and remove the 7.0.2xx SDks all together? Or upgrade to macOS 13 so that I have the privilege of using Xcode 14.3 (and it’s terrible new iron fist when it comes to pedantic compiler warnings)?

Exceptions (if any)

  • With PublishTrimmed unset
"/Users/jim.borden/Development/couchbase-lite-net-ee-helium/src/Couchbase.Lite.Tests.Maui/Couchbase.Lite.Tests.Maui.csproj" (default target) (1) ->
       (_RunILLink target) -> 
         ILLink : unknown error IL7000: An error occured while executing the custom linker steps. Please review the build log for more information. [/Users/jim.borden/Development/couchbase-lite-net-ee-helium/src/Couchbase.Lite.Tests.Maui/Couchbase.Lite.Tests.Maui.csproj::TargetFramework=net6.0-ios]
         ILLINK : error MT0180: This version of Microsoft.iOS requires the iOS 16.4 SDK (shipped with Xcode 14.3). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only in your project's iOS Build Options > Linker Behavior (to try to avoid the new APIs). [/Users/jim.borden/Development/couchbase-lite-net-ee-helium/src/Couchbase.Lite.Tests.Maui/Couchbase.Lite.Tests.Maui.csproj::TargetFramework=net6.0-ios]
         ILLINK : error MT2301: The linker step 'Setup' failed during processing: This version of Microsoft.iOS requires the iOS 16.4 SDK (shipped with Xcode 14.3). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only in your project's iOS Build Options > Linker Behavior (to try to avoid the new APIs). [/Users/jim.borden/Development/couchbase-lite-net-ee-helium/src/Couchbase.Lite.Tests.Maui/Couchbase.Lite.Tests.Maui.csproj::TargetFramework=net6.0-ios]


       "/Users/jim.borden/Development/couchbase-lite-net-ee-helium/src/Couchbase.Lite.Tests.Maui/Couchbase.Lite.Tests.Maui.csproj" (default target) (1) ->
       (ILLink target) -> 
         /usr/local/share/dotnet/sdk/7.0.203/Sdks/Microsoft.NET.ILLink.Tasks/build/Microsoft.NET.ILLink.targets(86,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false. [/Users/jim.borden/Development/couchbase-lite-net-ee-helium/src/Couchbase.Lite.Tests.Maui/Couchbase.Lite.Tests.Maui.csproj::TargetFramework=net6.0-ios]
  • Rolled back to workload 16.2.2054 and sdk 7.0.103
CSC : error CS1705: Assembly 'Microsoft.Maui' with identity 'Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'Microsoft.iOS, Version=16.4.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' which has a higher version than referenced assembly 'Microsoft.iOS' with identity 'Microsoft.iOS, Version=16.2.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' [/Users/jim.borden/Development/couchbase-lite-net-ee-helium/src/Couchbase.Lite.Tests.Maui/Couchbase.Lite.Tests.Maui.csproj::TargetFramework=net6.0-ios]
  • With PublishTrimmed set to false
       "/Users/jim.borden/Development/couchbase-lite-net-ee-helium/src/Couchbase.Lite.Tests.Maui/Couchbase.Lite.Tests.Maui.csproj" (default target) (1) ->
       (_ComputePublishTrimmed target) -> 
         /usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.4.47/targets/Xamarin.Shared.Sdk.targets(269,3): error : iOS projects must build with PublishTrimmed=true. Current value: False. [/Users/jim.borden/Development/couchbase-lite-net-ee-helium/src/Couchbase.Lite.Tests.Maui/Couchbase.Lite.Tests.Maui.csproj::TargetFramework=net6.0-ios]

Further technical details

.NET SDK:
 Version:   7.0.203
 Commit:    5b005c19f5

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  12.6
 OS Platform: Darwin
 RID:         osx.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/7.0.203/

Host:
  Version:      7.0.5
  Architecture: x64
  Commit:       8042d61b17

.NET SDKs installed:
  6.0.405 [/usr/local/share/dotnet/sdk]
  6.0.406 [/usr/local/share/dotnet/sdk]
  6.0.407 [/usr/local/share/dotnet/sdk]
  6.0.408 [/usr/local/share/dotnet/sdk]
  7.0.102 [/usr/local/share/dotnet/sdk]
  7.0.103 [/usr/local/share/dotnet/sdk]
  7.0.200 [/usr/local/share/dotnet/sdk]
  7.0.201 [/usr/local/share/dotnet/sdk]
  7.0.202 [/usr/local/share/dotnet/sdk]
  7.0.203 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.14 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.15 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.16 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.31 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.16 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found <-- note this is after I deleted the global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

VS4MAC 17.5.4 on macOS 12.6.3

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rolfbjarnecommented, Jun 12, 2023

First:

If I try to build a project targeted to either net6.0-ios or net6.0-ios14.2

.NET 6 is out of support, you should use net7.0-* instead.

I cannot for the life of me get an ios project to build because of a complaint that “this version of microsoft.ios needs the headers from Xcode 14.3” during the IL trimming phase. First of all… what version is this referring to? I’m guessing that it is talking about the ios workload?

Kind of, but it’s all rather complicated unfortunately. A workload is comprised of several other packages, and “this version” refers to the version of those packages.

That is, it suggests that I change the linking settings to “Link Framework SDKs only”. Brilliant…except that’s already what it was set to. So no dice here either.

Can you attach your csproj? Changing the linker setting may or may not work, but it shouldn’t suggest doing that if you’ve changed it.

Furthermore, it suggests that I can disable trimming by setting PublishTrimmed to false. Ok cool…now it complains that iOS must have PublishTrimmed set to true. Now it almost feels like intentional trolling.

Yes, this is unfortunate, and we have an issue to fix this for .NET 8 (by not suggesting to set PublishTrimmed to false - that’s a general advice for all types of projects, but does not work for iOS projects in particular).

Is the only remedy at this point to find out which version of vs mac uses 7.0.1xx, downgrade to that somehow, and remove the 7.0.2xx SDks all together? Or upgrade to macOS 13 so that I have the privilege of using Xcode 14.3 (and it’s terrible new iron fist when it comes to pedantic compiler warnings)?

The easiest by far is to use Xcode 14.3. Note that Apple will eventually force you to upgrade anyways, because the App Store will require you to build using a new(er) version of Xcode, otherwise you won’t be able to publish your app.

If you want to downgrade, you’ll have to do something like this:

  1. Install .NET 7.0.2xx.
  2. Create a rollback file. Ideally this would have been done with the working workloads installed, but you can also edit the file manually. To create a rollback file, do dotnet workload update --print-rollback. Save the results to a file (say rollback.json).
  3. Edit the rollback file to use the versions you want. For the iOS workloads, you can look at our releases here: https://github.com/xamarin/xamarin-macios/releases. This is probably the release you’ll want: https://github.com/xamarin/xamarin-macios/releases/tag/dotnet-7.0.2xx-2054
  4. Roll back using the rollback file: dotnet workload update --from-rollback-file rollback.json

We’re aware this is a rather cumbersome process, and we’re working on making this better for .NET 8.

I can’t figure out how to downgrade Maui here either…

I believe @mattleibow can answer that.

1reaction
vitek-karascommented, Jun 11, 2023

@ivanpovazan could you please add the right people to look into this? iOS/XCode/MAUI targeting/versioning problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to prepare this device for deployment
In xCode Go into Window/Devices and Simulators. Select the device you are using · It will likely show that the Device is unavailable...
Read more >
Xcode build failed - swift
Sometimes build error arises from changes in the Build Settings properties. Try examine those project properties. Look for the library versions.
Read more >
xcodebuild failure due to bundle identifier mismatch #3369
In my Xcode project Code Signing Identity is set to a development identity for all configurations and Provisioning Profile is set to Automatic...
Read more >
Swift build failure with ninja and Xcode 11.5 default toolchain ...
Hi everybody, A couple of days ago I stopped being able to build swift, which is weird. The configuration is MacOS 10.5.5 with...
Read more >
XCode archive fails due to derived data needing to be rebuilt
The solution is to set the Xcode task's action to 'clean', and to allow the archive to only be created by setting packageApp...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found