Skip to content

CI: fix macOS build on macos-26 (canonical Xcode 26.0.1 path + runFirstLaunch, ApplicationId for Mac sample)#4

Merged
maikebing merged 4 commits into
mainfrom
copilot/fix-ci-build-error-macos
May 20, 2026
Merged

CI: fix macOS build on macos-26 (canonical Xcode 26.0.1 path + runFirstLaunch, ApplicationId for Mac sample)#4
maikebing merged 4 commits into
mainfrom
copilot/fix-ci-build-error-macos

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 20, 2026

macOS CI 编译失败修复

第一轮

CI 中 Build macOS sample 失败:

This version of .NET for macOS (26.0.11017) requires Xcode 26.0. The current version of Xcode is 16.4.

原因:macos-latest 仍是 macOS 15 (Xcode 16.4),而 .NET 10 macOS workload 需要 Xcode 26。

第二轮

切到 macos-26 后仍失败:

This version of .NET for macOS (26.0.11017) requires Xcode 26.0. The current version of Xcode is 26.2.

原因:macos-26 镜像默认 Xcode 已升级到 26.2,但 macOS workload Microsoft.macOS.Sdk.net10.0_26.0 严格要求 Xcode 26.0。镜像同时预装了 Xcode 26.0.x,所以只需显式 xcode-select 切换即可。

第三轮

Xcode 校验通过后,Build macOS sample 又出现新错误:

error : A bundle identifier is required. Either add an 'ApplicationId' property in the project file, or add a 'CFBundleIdentifier' entry in the project's Info.plist file.

原因:net10.0-macosExe 项目生成 .app bundle 时必须有 bundle id,NativeWebHost.Sample.Mac 既没有 Info.plist 也没有声明 ApplicationId

第四轮

通过 /Applications/Xcode_26.0.app 符号链接选择 Xcode 后,sample 构建出现:

xcrun: error: unable to find utility "install_name_tool", not a developer tool or in PATH
xcodebuild: error: SDK "/Applications/Xcode_26.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" cannot be located.
install_name_tool exited with code 72

原因:

  1. macos-26 runner 上 /Applications/Xcode_26.0.app 只是指向 Xcode_26.0.1.app 的符号链接,xcrun/xcodebuild 通过该符号链接路径解析 MacOSX SDK 时失败。必须使用规范的真实路径 Xcode_26.0.1.app
  2. 切换 Xcode 之后还需要 sudo xcodebuild -runFirstLaunch 才能注册命令行组件(install_name_tool 等),否则它们不在 PATH 中。

变更

  • .github/workflows/ci.ymlbuild-macos 作业 runs-on 改为 macos-26
  • .github/workflows/release.ymlpack-nuget-macospublish-samples-macos 作业 runs-on 改为 macos-26
  • 在以上三个 macOS 作业中、Install macOS workload 步骤之前新增 Select Xcode 26.0 步骤:
    • sudo xcode-select -s /Applications/Xcode_26.0.1.app(使用真实路径,避免 Xcode_26.0.app 符号链接导致 SDK 解析失败)
    • sudo xcodebuild -runFirstLaunch(注册 SDK / 命令行工具)
    • 附带打印 xcodebuild -versionxcrun --sdk macosx --show-sdk-path 便于排查
  • samples/NativeWebHost.Sample.Mac/NativeWebHost.Sample.Mac.csproj:新增
    • <ApplicationId>com.iotsharp.nativewebhost.sample.mac</ApplicationId>
    • <ApplicationTitle>NativeWebHost.Sample.Mac</ApplicationTitle>
  • YAML 语法校验通过
  • Code Review / CodeQL 验证通过

Copilot AI requested a review from maikebing May 20, 2026 09:49
@maikebing
Copy link
Copy Markdown
Member

@copilot 还是报错。

…acOS Exe builds

Agent-Logs-Url: https://github.com/IoTSharp/NativeWebHost/sessions/ef54cef2-6752-46e3-9d28-679926a2673a

Co-authored-by: maikebing <3445167+maikebing@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 20, 2026

@copilot 还是报错。

这次的错误已经不是 Xcode 的问题了,Xcode 26.0 已经选到,Build macOS package 也通过了。新错误是:

error : A bundle identifier is required. Either add an 'ApplicationId' property in the project file, or add a 'CFBundleIdentifier' entry in the project's Info.plist file.
[samples/NativeWebHost.Sample.Mac/NativeWebHost.Sample.Mac.csproj]

net10.0-macosExe 项目在生成 .app bundle 时必须有 bundle id,而 sample 既无 Info.plist 也未声明 ApplicationId。在 d98dde7NativeWebHost.Sample.Mac.csproj 加上了:

<ApplicationId>com.iotsharp.nativewebhost.sample.mac</ApplicationId>
<ApplicationTitle>NativeWebHost.Sample.Mac</ApplicationTitle>

Copilot AI changed the title CI: run macOS jobs on macos-26 to match .NET 10 macOS workload's Xcode 26 requirement CI: fix macOS build by pinning Xcode 26.0 on macos-26 and adding ApplicationId to Mac sample May 20, 2026
@maikebing
Copy link
Copy Markdown
Member

@copilot 我看了, 但是还在报错。

…fix missing MacOSX SDK

Agent-Logs-Url: https://github.com/IoTSharp/NativeWebHost/sessions/735b758e-d5bc-4c54-821c-f579eec319f9

Co-authored-by: maikebing <3445167+maikebing@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 20, 2026

@copilot 我看了, 但是还在报错。

这次的报错变成了 SDK / 工具找不到(已不是 bundle id 也不是 Xcode 版本):

xcrun: error: unable to find utility "install_name_tool"
xcodebuild: error: SDK "/Applications/Xcode_26.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" cannot be located.
install_name_tool exited with code 72

两个原因:

  1. macos-26 runner 上 /Applications/Xcode_26.0.app 是指向 Xcode_26.0.1.app 的符号链接,xcrun/xcodebuild 通过符号链接路径定位 MacOSX SDK 会失败 → 用真实路径 Xcode_26.0.1.app
  2. 切换 Xcode 后还得 sudo xcodebuild -runFirstLaunch 注册命令行组件,否则 install_name_tool 等工具不在 PATH。

8692648 修改了 ci.ymlrelease.yml 的三个 macOS 作业:

  • xcode-select -s /Applications/Xcode_26.0.1.app(取代符号链接)
  • 追加 sudo xcodebuild -runFirstLaunch
  • xcodebuild -version / xcrun --sdk macosx --show-sdk-path 方便后续排查

Copilot AI changed the title CI: fix macOS build by pinning Xcode 26.0 on macos-26 and adding ApplicationId to Mac sample CI: fix macOS build on macos-26 (canonical Xcode 26.0.1 path + runFirstLaunch, ApplicationId for Mac sample) May 20, 2026
@maikebing maikebing marked this pull request as ready for review May 20, 2026 10:28
Copilot AI review requested due to automatic review settings May 20, 2026 10:28
@maikebing maikebing merged commit 080a4c3 into main May 20, 2026
8 checks passed
@maikebing maikebing deleted the copilot/fix-ci-build-error-macos branch May 20, 2026 10:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates macOS sample metadata and adjusts GitHub Actions macOS jobs to use a newer runner image and explicitly select a specific Xcode version for building/packaging.

Changes:

  • Add macOS app identifier/title metadata to the sample .csproj.
  • Switch macOS CI/release jobs from macos-latest to macos-26.
  • Add steps to force-select a pinned Xcode app and run first-launch initialization before installing the macOS workload.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
samples/NativeWebHost.Sample.Mac/NativeWebHost.Sample.Mac.csproj Adds application identity/title properties for the macOS sample.
.github/workflows/release.yml Moves macOS release jobs to macos-26 and pins Xcode selection before workload install.
.github/workflows/ci.yml Moves macOS CI job to macos-26 and pins Xcode selection before workload install.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/ci.yml
Comment on lines +102 to +108
- name: Select Xcode 26.0
# The .NET 10 macOS workload (Microsoft.macOS.Sdk.net10.0_26.0 26.0.11017)
# pins Xcode to 26.0 exactly. The macos-26 image defaults to a newer Xcode
# (e.g. 26.2), which causes "requires Xcode 26.0" build errors. Switch to
# the Xcode 26.0.x installed on the image. Use the canonical 26.0.1 path
# rather than the /Applications/Xcode_26.0.app symlink — xcrun/xcodebuild
# otherwise fail to resolve the MacOSX SDK ("SDK ... cannot be located",
Comment on lines +151 to +162
- name: Select Xcode 26.0
# The .NET 10 macOS workload pins Xcode to 26.0 exactly; the macos-26
# image defaults to a newer Xcode that the Xamarin SDK rejects. Use the
# canonical Xcode_26.0.1.app path (not the /Applications/Xcode_26.0.app
# symlink), and run -runFirstLaunch so the MacOSX SDK / command-line
# components are properly registered for the new selection.
shell: bash
run: |
sudo xcode-select -s /Applications/Xcode_26.0.1.app
sudo xcodebuild -runFirstLaunch
xcodebuild -version
xcrun --sdk macosx --show-sdk-path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants