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

[MacOS 14.0 & Xcode15] "failed to write to a file" error during build #135199

Closed
wanyangye opened this issue Sep 21, 2023 · 19 comments
Closed

[MacOS 14.0 & Xcode15] "failed to write to a file" error during build #135199

wanyangye opened this issue Sep 21, 2023 · 19 comments
Labels
a: build Building flutter applications with the tool a: desktop Running on desktop e: OS-version specific Affects only some versions of the relevant operating system P2 Important issues not at the top of the work list platform-mac Building on or for macOS specifically r: duplicate Issue is closed as a duplicate of an existing issue team-macos Owned by the macOS platform team

Comments

@wanyangye
Copy link

wanyangye commented Sep 21, 2023

Steps to reproduce

I experienced a compilation error after upgrading to MacOS 14.0 Xcode15。

[Edited to hide, as this picture is of an unrelated warning] ![WX20230921-123454@2x](https://github.com/flutter/flutter/assets/44550529/ab7c06d8-8929-4d3a-88c2-98135ff114e8)

Expected results

buildinfo.log

Actual results

buildinfo.log

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

/// Flutter code sample for [TextField].

class ObscuredTextFieldSample extends StatelessWidget {
  const ObscuredTextFieldSample({super.key});

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: 250,
      child: TextField(
        inputFormatters: [
          FilteringTextInputFormatter.deny(RegExp("[\u4e00-\u9fa5]")),
        ],
        autofocus: false,
        obscureText: true,
        keyboardType: TextInputType.visiblePassword,
        textInputAction: TextInputAction.next,
        decoration: InputDecoration(
          border: OutlineInputBorder(),
          labelText: 'Password',
        ),
      ),
    );
  }
}

class TextFieldExampleApp extends StatelessWidget {
  const TextFieldExampleApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Demo')),
        body: const Center(
          child: ObscuredTextFieldSample(),
        ),
      ),
    );
  }
}

void main() => runApp(const TextFieldExampleApp());

Screenshots or Video

Screenshots / Video demonstration

WX20230921-123454@2x

Flutter Doctor output

flutter doctor -v
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel unknown, 3.10.2, on macOS 14.0 23A339 darwin-arm64, locale
    zh-Hans-CN)
    ! Flutter version 3.10.2 on channel unknown at
      /Users/steven/Steven/Work/DevelopTools/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an
      official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions
      at https://flutter.dev/docs/get-started/install.
    ! Unknown upstream repository.
      Reinstall Flutter by following instructions at
      https://flutter.dev/docs/get-started/install.
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for
      more details.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
[✓] VS Code (version 1.82.2)
[✓] Connected device (2 available)
Attempting to reach github.com...⣻
[!] Network resources             
    ✗ A network error occurred while checking "https://github.com/": Operation timed out

! Doctor found issues in 4 categories.

@ImagineBoom

This comment was marked as off-topic.

@wanyangye

This comment was marked as off-topic.

@huycozy huycozy added the in triage Presently being triaged by the triage team label Sep 21, 2023
@huycozy
Copy link
Member

huycozy commented Sep 21, 2023

@wanyangye @ImagineBoom I haven't had macOS 14.0 yet but I found this answer that you can try ti see if it works.

If it doesn't work, please confirm:

  • Does the issue happen on a newly created Flutter project (counter app)?
  • Please upgrade your Flutter SDK to the latest stable or master channel and retry to see if the result is different.
flutter channel master
flutter upgrade
  • Please provide the entire output of flutter run -v on the reproducible sample code.

Thanks!

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 21, 2023
@ImagineBoom

This comment was marked as off-topic.

@wanyangye
Copy link
Author

@wanyangye @ImagineBoom I haven't had macOS 14.0 yet but I found this answer that you can try ti see if it works.

If it doesn't work, please confirm:

  • Does the issue happen on a newly created Flutter project (counter app)?
  • Please upgrade your Flutter SDK to the latest stable or master channel and retry to see if the result is different.
flutter channel master
flutter upgrade
  • Please provide the entire output of flutter run -v on the reproducible sample code.

Thanks!

flutterInfo.log

this file is flutter run -v info

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 21, 2023
@ImagineBoom

This comment was marked as off-topic.

@wanyangye
Copy link
Author

error: Sandbox: rsync.samba(44082) deny(1) file-write-create /Users/steven/Steven/Work/Code/PrintHub/Client/flutter/client/build/macos/Build/Products/Debug/FlutterMacOS.framework (in target 'Flutter Assemble' from project 'Runner')
Flutter failed to write to a file at "/Users/steven/Steven/Work/Code/PrintHub/Client/flutter/client/build/macos/Build/Products/Debug/.last_build_id".
Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.
Try running:
sudo chown -R $(whoami) /Users/steven/Steven/Work/Code/PrintHub/Client/flutter/client/build/macos/Build/Products/Debug/.last_build_id

warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Flutter Assemble' from project 'Runner')
** BUILD FAILED **

@ImagineBoom

This comment was marked as off-topic.

@huycozy
Copy link
Member

huycozy commented Sep 21, 2023

@wanyangye I notice this is indeed permission error on your output log (at flutterInfo.log) at #135199 (comment). I don't see the initial warning (at buildinfo.log) there, though.

[ ] [ +1 ms] Flutter failed to write to a file at "/Users/steven/Steven/Work/Code/PrintHub/Client/flutter/client/build/macos/Build/Products/Debug/.last_build_id".
[ ] Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.
[ ] Try running:
[ ] sudo chown -R $(whoami) /Users/steven/Steven/Work/Code/PrintHub/Client/flutter/client/build/macos/Build/Products/Debug/.last_build_id

You can try the following suggestion to see if it works.


@ImagineBoom I can see the same Warning on your output log (at flutterInfo2.log), the build is succeeded however.

Regarding the initial warning, I will label this for other's input.

Initial warning (from output log files)
[  +37 ms] 2023-09-21 18:35:45.108 xcodebuild[18082:138468] [MT] DVTAssertions: Warning in
/System/Volumes/Data/SWE/Apps/DT/BuildRoots/BuildRoot11/ActiveBuildRoot/Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-22267/IDEFoundation/Provisionin
g/Capabilities Infrastructure/IDECapabilityQuerySelection.swift:103
[        ] Details:  createItemModels creation requirements should not create capability item model for a capability item model that already exists.
[        ] Function: createItemModels(for:itemModelSource:)
[        ] Thread:   <_NSMainThread: 0x600002620240>{number = 1, name = main}
[        ] Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.

@huycozy huycozy added platform-mac Building on or for macOS specifically a: desktop Running on desktop a: build Building flutter applications with the tool e: OS-version specific Affects only some versions of the relevant operating system team-desktop and removed in triage Presently being triaged by the triage team labels Sep 21, 2023
@stuartmorgan stuartmorgan changed the title [MacOS 14.0 & Xcode15] build error [MacOS 14.0 & Xcode15] "failed to write to a file" error during build Sep 21, 2023
@stuartmorgan
Copy link
Contributor

I've retitled this to be about the error, since it was reported as a build error, and hidden the screenshot of the unrelated and harmless warning.

@ImagineBoom Please file a new issue about the warning you are seeing, since that's not related to the error.

@gspencergoog gspencergoog added P2 Important issues not at the top of the work list triaged-desktop labels Sep 21, 2023
@cbracken
Copy link
Member

cbracken commented Sep 21, 2023

I ran across this in a couple Xcode/Sonoma betas. It disappeared for one developer beta (maybe the 6th beta), then reappeared in a later one. I can repro on last week's release candidates.

The warning reads as though part of the issue is a bug with Xcode incremental builds but I suspect it's likely that our build wiring is out-of-the-ordinary enough that we might be hitting some unusual edge-case.

In testing with a non-Flutter (AppKit/Swift) app, the same warning is emitted during commandline builds via xcodebuild build as well. Looks like there's a new Xcode release candidate a couple days ago; will try again with that and if I'm still seeing this, will file the bug with Apple, and see what's needed on our end to workaround (or suppress) the warning.

@cbracken
Copy link
Member

After testing with Xcode Version 15.0 (15A240d), I'm still seeing this error both in Flutter and non-Flutter app builds that are built from the command-line.

@wanyangye
Copy link
Author

@wanyangye I notice this is indeed permission error on your output log (at flutterInfo.log) at #135199 (comment). I don't see the initial warning (at buildinfo.log) there, though.

[ ] [ +1 ms] Flutter failed to write to a file at "/Users/steven/Steven/Work/Code/PrintHub/Client/flutter/client/build/macos/Build/Products/Debug/.last_build_id".
[ ] Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.
[ ] Try running:
[ ] sudo chown -R $(whoami) /Users/steven/Steven/Work/Code/PrintHub/Client/flutter/client/build/macos/Build/Products/Debug/.last_build_id

You can try the following suggestion to see if it works.

@ImagineBoom I can see the same Warning on your output log (at flutterInfo2.log), the build is succeeded however.

Regarding the initial warning, I will label this for other's input.

Initial warning (from output log files)

[  +37 ms] 2023-09-21 18:35:45.108 xcodebuild[18082:138468] [MT] DVTAssertions: Warning in
/System/Volumes/Data/SWE/Apps/DT/BuildRoots/BuildRoot11/ActiveBuildRoot/Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-22267/IDEFoundation/Provisionin
g/Capabilities Infrastructure/IDECapabilityQuerySelection.swift:103
[        ] Details:  createItemModels creation requirements should not create capability item model for a capability item model that already exists.
[        ] Function: createItemModels(for:itemModelSource:)
[        ] Thread:   <_NSMainThread: 0x600002620240>{number = 1, name = main}
[        ] Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.

its not work。I've followed the advice, and it's not working. I have just upgraded to MacOS14 Xcode15 to run the flutter project when this prompt appears, before the latest version of MacOS13 and the latest version of Xcode14, there is no problem.

@wanyangye
Copy link
Author

I uninstalled Xcode 15 and used XCode 14.3 and now the flutter project is built properly.

image

Is flutter only supported up to 10.14? I need to be compatible with 10.13, is that OK?

@ImagineBoom
Copy link

I've retitled this to be about the error, since it was reported as a build error, and hidden the screenshot of the unrelated and harmless warning.

@ImagineBoom Please file a new issue about the warning you are seeing, since that's not related to the error.

OK, I have filed this issue #135277

Thanks!

@cbracken
Copy link
Member

@wanyangye the error you're experiencing is unrelated to the warning here

2023-09-21 11:25:40.187 xcodebuild[84698:3805495] [MT] DVTAssertions: Warning in /System/Volumes/Data/SWE/Apps/DT/BuildRoots/BuildRoot11/ActiveBuildRoot/Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-22267/IDEFoundation/Provisioning/Capabilities Infrastructure/IDECapabilityQuerySelection.swift:103
Details:  createItemModels creation requirements should not create capability item model for a capability item model that already exists.
Function: createItemModels(for:itemModelSource:)                                   
Thread:   <_NSMainThread: 0x13e609ea0>{number = 1, name = main}                                                                                     
Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.

It's due to this error:

error: DT_TOOLCHAIN_DIR cannot be used to evaluate LD_RUNPATH_SEARCH_PATHS, use TOOLCHAIN_DIR instead (in target 'Runner' from project 'Runner')
error: DT_TOOLCHAIN_DIR cannot be used to evaluate LD_RUNPATH_SEARCH_PATHS, use TOOLCHAIN_DIR instead (in target 'Flutter Assemble' from project 'Runner') 
error: DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead (in target 'Flutter Assemble' from project 'Runner')
error: DT_TOOLCHAIN_DIR cannot be used to evaluate LD_RUNPATH_SEARCH_PATHS, use TOOLCHAIN_DIR instead (in target 'Pods-Runner' from project 'Pods')

which was filed in: #132755
and was fixed in: #132803

This is caused by an issue in CocoaPods, which was fixed in: CocoaPods/CocoaPods#12009

However, as far as I'm aware, they haven't yet published a new release that includes their fix, so you'll need to rely on our workaround.

Please make sure you've got the latest Flutter version installed. You may need to switch master branch, but I believe this has been cherry-picked to stable (though not sure if we've published that stable version yet).

Closing as a duplicate of #132755.

@cbracken
Copy link
Member

cbracken commented Sep 22, 2023

Is flutter only supported up to 10.14? I need to be compatible with 10.13, is that OK?

This is off-topic for this bug; however, you can see our Supported deployment platforms page for details. Short answer: 10.14 (Mojave) is the minimum required version today. This is because Flutter requires Metal support. If you need support for older versions of macOS, you'll need to use an older version of Flutter (and possibly older version of Xcode).

@huycozy huycozy added the r: duplicate Issue is closed as a duplicate of an existing issue label Sep 27, 2023
@acamue
Copy link

acamue commented Sep 29, 2023

https://www.youtube.com/watch?v=VQIn41rFVAc

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 13, 2023
@cbracken cbracken added team-macos Owned by the macOS platform team and removed team-desktop labels Jun 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: build Building flutter applications with the tool a: desktop Running on desktop e: OS-version specific Affects only some versions of the relevant operating system P2 Important issues not at the top of the work list platform-mac Building on or for macOS specifically r: duplicate Issue is closed as a duplicate of an existing issue team-macos Owned by the macOS platform team
Projects
None yet
Development

No branches or pull requests

7 participants