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

clang++ exited with code 1: building for 'iOS', but linking in object file libswiftCompatibility50.a[arm64][7](Overrides.cpp.o) built for 'iOS-simulator' #22231

Open
FlavioGoncalves-Cayas opened this issue Feb 21, 2025 · 14 comments
Labels
need-attention An issue requires our attention/response
Milestone

Comments

@FlavioGoncalves-Cayas
Copy link

Description

Hello,

I am having issues building my net9.0 MAUI app for iOS on Azure DevOps, while it works perfectly fine locally. I already compared the workloads, sdks and XCode versions.

Here is the error I am receiving:

/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.2/18.2.9180/targets/Xamarin.Shared.Sdk.targets(1665,3): error : clang++ exited with code 1: [redacted.csproj]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.2/18.2.9180/targets/Xamarin.Shared.Sdk.targets(1665,3): error : ld: building for 'iOS', but linking in object file (/Applications/Xcode_16.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCompatibility50.a[arm64][7](Overrides.cpp.o)) built for 'iOS-simulator' [redacted.csproj]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.2/18.2.9180/targets/Xamarin.Shared.Sdk.targets(1665,3): error : clang++: error: linker command failed with exit code 1 (use -v to see invocation) [redacted.csproj]

This is the pipeline configuration:

vmImage: macOS-15
.NET SDK: 9.0.102
XCode: 16.2
workloads:
  ios                        18.2.9180/9.0.100      SDK 9.0.100        
  maui                       9.0.14/9.0.100         SDK 9.0.100        
  maui-ios                   9.0.14/9.0.100         SDK 9.0.100 

I am using dotnet publish:

dotnet publish redacted.csproj -f net9.0-ios -c Release -p:ArchiveOnBuild=true -p:RuntimeIdentifier=ios-arm64 -p:CodesignKey="$(APPLE_CERTIFICATE_SIGNING_IDENTITY)"

Any ideas on how to fix it, or what's the underlying issue?

I am also wondering why it says Xcode_16.app in the error, when I specifically selected XCode 16.2 with sudo xcode-select -s /Applications/Xcode_16.2.app

@rolfbjarne maybe it's more of a macios issue?

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

9.0.30 SR3

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

@rolfbjarne
Copy link
Member

I am also wondering why it says Xcode_16.app in the error, when I specifically selected XCode 16.2 with sudo xcode-select -s /Applications/Xcode_16.2.app

That's probably the issue.

Check if this file exists, and if it does, just delete it:

~/Library/Preferences/Xamarin/Settings.plist

For more information see: #11172 (comment)

@rolfbjarne rolfbjarne transferred this issue from dotnet/maui Feb 21, 2025
@rolfbjarne rolfbjarne added need-info Waiting for more information before the bug can be investigated and removed t/bug labels Feb 21, 2025
@rolfbjarne rolfbjarne added this to the Future milestone Feb 21, 2025
@FlavioGoncalves-Cayas
Copy link
Author

FlavioGoncalves-Cayas commented Feb 24, 2025

@rolfbjarne thanks for the reply.

cat ~/Library/Preferences/Xamarin/Settings.plist returns no such file or directory

So it looks like that is not the issue.

Also xcode-select -p returns /Applications/Xcode_16.2.app/Contents/Developer as expected, after sudo xcode-select -s /Applications/Xcode_16.2.app

@dotnet-policy-service dotnet-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Feb 24, 2025
@rolfbjarne
Copy link
Member

Can you get an MSBuild binlog that shows the build failure?

@rolfbjarne rolfbjarne added need-info Waiting for more information before the bug can be investigated no-auto-reply For internal use and removed need-attention An issue requires our attention/response labels Feb 24, 2025
@dotnet-policy-service dotnet-policy-service bot removed the no-auto-reply For internal use label Feb 24, 2025
@FlavioGoncalves-Cayas
Copy link
Author

Heres the binlog you requested:

msbuild.binlog.zip

Thanks for the help.

@dotnet-policy-service dotnet-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Feb 25, 2025
@rolfbjarne
Copy link
Member

Is either /Applications/Xcode_16.2.app or /Applications/Xcode_16.app a symlink to somewhere else?

What's the output of this command?

ls -lad /Applications/Xcode*.app

@rolfbjarne rolfbjarne added need-info Waiting for more information before the bug can be investigated no-auto-reply For internal use and removed need-attention An issue requires our attention/response labels Feb 25, 2025
@dotnet-policy-service dotnet-policy-service bot removed the no-auto-reply For internal use label Feb 25, 2025
@FlavioGoncalves-Cayas
Copy link
Author

The output is

lrwxr-xr-x  1 runner  admin  26 Jan 20 05:07 /Applications/Xcode.app -> /Applications/Xcode_16.app
lrwxr-xr-x  1 runner  admin  28 Jan 20 05:06 /Applications/Xcode_15.4.0.app -> /Applications/Xcode_15.4.app
drwxr-xr-x  3 runner  staff  96 Jan 20 04:10 /Applications/Xcode_15.4.app
lrwxr-xr-x  1 runner  admin  26 Jan 20 05:06 /Applications/Xcode_16.0.0.app -> /Applications/Xcode_16.app
lrwxr-xr-x  1 runner  admin  26 Jan 20 05:06 /Applications/Xcode_16.0.app -> /Applications/Xcode_16.app
lrwxr-xr-x  1 runner  admin  28 Jan 20 05:06 /Applications/Xcode_16.1.0.app -> /Applications/Xcode_16.1.app
drwxr-xr-x  3 runner  staff  96 Jan 20 04:10 /Applications/Xcode_16.1.app
lrwxr-xr-x  1 runner  admin  28 Jan 20 05:06 /Applications/Xcode_16.2.0.app -> /Applications/Xcode_16.2.app
drwxr-xr-x  3 runner  staff  96 Jan 20 04:10 /Applications/Xcode_16.2.app
drwxr-xr-x  3 runner  staff  96 Jan 20 04:10 /Applications/Xcode_16.app

@dotnet-policy-service dotnet-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Feb 25, 2025
@rolfbjarne
Copy link
Member

Can you try executing this, just before executing dotnet publish, and see if that fixes anything:

xcrun -k

This removes a cache used when looking up Xcode's development tools and properties on the command line (you can verify this by looking at xcrun's man page ("man xcrun")).

@rolfbjarne rolfbjarne added need-info Waiting for more information before the bug can be investigated no-auto-reply For internal use and removed need-attention An issue requires our attention/response labels Feb 25, 2025
@dotnet-policy-service dotnet-policy-service bot removed the no-auto-reply For internal use label Feb 25, 2025
@FlavioGoncalves-Cayas
Copy link
Author

Unfortunately that did not help.

@rolfbjarne
Copy link
Member

This is getting stranger and stranger :(

Next idea to get more verbose output from the native linker, please add this to the csproj and get an updated binlog:

<ItemGroup>
    <_CustomLinkFlags Include="-v" />
</ItemGroup>

@FlavioGoncalves-Cayas
Copy link
Author

Here's the new binlog
msbuild (2).binlog.zip

@dotnet-policy-service dotnet-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Feb 25, 2025
@rolfbjarne
Copy link
Member

I think I see something wrong with the Org.Jitsi.Meet.Sdk.iOS package, it adds linker flags to the build that hardcodes paths to /Application/Xcode.app, which is a symlink that ends up resolving to /Application/Xcode_16.app.

I couldn't find this package on NuGet.org, so I assume it's a private package? Do you control it / do you have the source code for it?

@rolfbjarne rolfbjarne added need-info Waiting for more information before the bug can be investigated no-auto-reply For internal use and removed need-attention An issue requires our attention/response labels Feb 25, 2025
@dotnet-policy-service dotnet-policy-service bot removed the no-auto-reply For internal use label Feb 25, 2025
@FlavioGoncalves-Cayas
Copy link
Author

FlavioGoncalves-Cayas commented Feb 25, 2025

Oh, I see. Yes that is a private package I control.
It has LinkerFlags like these

<NativeReference Include="..\iOS\JitsiMeetSdkProxy\Pods\JitsiMeetSDK\Frameworks\JitsiMeetSDK.xcframework">
        <Kind>Framework</Kind>
          <SmartLink>False</SmartLink>
        <Frameworks>Foundation UIKit</Frameworks>
          <LinkerFlags>-L /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/ -L /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -Wl,-rpath -Wl,@executable_path/Frameworks -ObjC </LinkerFlags>
      </NativeReference>

I don't quite remember when and why I added them. Probably read it somewhere when I was trying to get the binding working.
Do you happen to know if they are necessary?

@dotnet-policy-service dotnet-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Feb 25, 2025
@rolfbjarne
Copy link
Member

Can you try and see if this works?

<NativeReference Include="..\iOS\JitsiMeetSdkProxy\Pods\JitsiMeetSDK\Frameworks\JitsiMeetSDK.xcframework">
    <Kind>Framework</Kind>
    <SmartLink>False</SmartLink>
    <Frameworks>Foundation UIKit</Frameworks>
    <LinkWithSwiftSystemLibraries>true</LinkWithSwiftSystemLibraries>
</NativeReference>

If not, please attach an updated binlog.

@FlavioGoncalves-Cayas
Copy link
Author

Did that. Now I'm facing other errors

/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.2/18.2.9180/targets/Xamarin.Shared.Sdk.targets(1665,3): error : Undefined symbols for architecture arm64: [/Users/runner/work/1/s/redacted.csproj]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.2/18.2.9180/targets/Xamarin.Shared.Sdk.targets(1665,3): error :   "_OBJC_CLASS_$_JitsiMeetConferenceOptionsBuilderProxy", referenced from: [/Users/runner/work/1/s/redacted.csproj]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.2/18.2.9180/targets/Xamarin.Shared.Sdk.targets(1665,3): error :        in registrar.o [/Users/runner/work/1/s/redacted.csproj]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.2/18.2.9180/targets/Xamarin.Shared.Sdk.targets(1665,3): error :   "_OBJC_CLASS_$_JitsiMeetViewProxy", referenced from: [/Users/runner/work/1/s/redacted.csproj]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.2/18.2.9180/targets/Xamarin.Shared.Sdk.targets(1665,3): error :        in registrar.o [/Users/runner/work/1/s/redacted.csproj]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.2/18.2.9180/targets/Xamarin.Shared.Sdk.targets(1665,3): error :   "_OBJC_CLASS_$__TtC17JitsiMeetSdkProxy25JitsiMeetViewDelegateImpl", referenced from: [/Users/runner/work/1/s/redacted.csproj]
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.2/18.2.9180/targets/Xamarin.Shared.Sdk.targets(1665,3): error :        in registrar.o [/Users/runner/work/1/s/redacted.csproj]

msbuild (4).binlog.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-attention An issue requires our attention/response
Projects
None yet
Development

No branches or pull requests

2 participants