Closed sasha-borodin closed 5 months ago
3. Add
ForceSimulatorX64ArchitectureInIDE
to the csproj file, in an attempt to always build for simulator using the x64 architecture (as was the case when targettingnet7.0-ios
) 4. Try to build (ex. from command line, usingdotnet build
)
As the property name ForceSimulatorX64ArchitectureInIDE
says, it only affects in IDE builds (not command line builds). So the behavior you're explaining is expected.
When building from the command line, you can pass the runtime identifier like this:
$ dotnet build /p:RuntimeIdentifier=iossimulator-x64
in order to build for the x64 simulator.
That said, it sounds like you're seeing the same behavior in an IDE - can you confirm this? And which IDE you're using?
@rolfbjarne - thank you for the quick response. Issue triage is a thankless and tedious job, but much appreciated.
That said, it sounds like you're seeing the same behavior in an IDE - can you confirm this? And which IDE you're using?
We have been using JetBrains Rider ever since the VS for Mac retirement announcement.
Is the ForceSimulatorX64ArchitectureInIDE
setting only supported in Visual Studio? If so, is there any creative conditional PropertyGroup
project settings that can be used to achieve the previous net7.0-ios
behavior? Specifically, we are looking for a way to have the Rider IDE build for iossimulator-x64
when a sim device is selected on an ARM Mac. I would like to avoid adding another build configuration to make the distinction, but will if that's the only feasible solution.
Thank you!
Is the
ForceSimulatorX64ArchitectureInIDE
setting only supported in Visual Studio?
IIRC it should also work in VSCode, but I haven't tested it personally.
Note that this property needs support from the IDE, which is probably why Rider doesn't work (if you could file a bug with them then they might fix it).
If so, is there any creative conditional
PropertyGroup
project settings that can be used to achieve the previousnet7.0-ios
behavior? Specifically, we are looking for a way to have the Rider IDE build for iossimulator-x64 when a sim device is selected on an ARM Mac.
I assume you also want iossimulator-x64 when building on an x64 Mac (because iossimulator-arm64 wouldn't launch if you were able to build it).
Which really means you always want iossimulator-x64 when targeting a simulator.
As for creative ideas, maybe this works?
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'iossimulator-arm64'">
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
</PropertyGroup>
@rolfbjarne - thanks for the suggestion. We tried this, but unfortunately it had no effect on the build process. Build artifacts continue to get generated in bin/Debug/net8.0-ios/iossimulator-arm64
folder, and we eventually see the same build errors as before.
I have filed a JetBrains Rider issue. Just for documentation, this is the link: https://youtrack.jetbrains.com/issue/RIDER-113336/Support-for-ForceSimulatorX64ArchitectureInIDE-iOS-project-setting
If you have any other suggestions for creative project file manipulation to get us unblocked, they would be greatly appreciated.
Thanks again!
@sasha-borodin can you get a build log from a Rider build (as verbose as possible - I don't know Rider so I don't know how to change the verbosity) and attach it here?
@rolfbjarne - Rider has two options for building: ReSharper and MSBuild. Attached are logs for each. Also, note that these builds were conducted with both the ForceSimulatorX64ArchitectureInIDE
and RuntimeIdentifier
(per your suggestion) project settings.
So it's not obvious from the build logs how Rider tells the build which device (simulator or device) you're building for. In theory they don't have to tell the build to build for the simulator (because that's the default), in which case the build log wouldn't show this.
What is clear from the build log, is that our default logic to select the runtime identifier executes:
Property reassignment: $(RuntimeIdentifier)="iossimulator-arm64" (previous value: "") at /usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/17.2.8053/targets/Xamarin.Shared.Sdk.props (122,3)
which gives me the idea to reverse the check from before, so instead put this in your csproj:
<PropertyGroup Condition="'$(RuntimeIdentifier)' != 'ios-arm64'">
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
</PropertyGroup>
Basically: if not building for the device, then build for the x64 simulator.
If that doesn't work, please provide build logs like before, but for a device build.
@rolfbjarne - reversing the Condition
per your suggestion did the trick. Thank you for your help on this!
This is a viable workaround that should be used until/unless the Rider IDE adds support for the ForceSimulatorX64ArchitectureInIDE
project setting.
I will continue to update this GitHub issue as progress is made on the JetBrains side and will report if/when the workaround becomes unnecessary.
Steps to Reproduce
ForceSimulatorX64ArchitectureInIDE
to the csproj file, in an attempt to always build for simulator using the x64 architecture (as was the case when targettingnet7.0-ios
)dotnet build
)Expected Behavior
Build process builds for simulator using
x64
architecture.Actual Behavior
Build process attempts to build for simulator using
arm64
architecture, and errors out with one or more of the following:Environment
Version information
Build Logs
Example Project (If Possible)
n/a
Additional Comments
The suggestion from official documentation here is to specify Runtime Identifiers. However, I can't figure out a way to do this in such a way that debugging works on both simulator and physical device. For example, if I specify something like...
...this will work great when debugging on a physical device, but not the simulator (and vice versa).