Skip to content

flutter run failed due to 'Permission denied' when replacing signature of 'Flutter.framework' #40146

Closed
@yrom

Description

@yrom

Steps to Reproduce

  1. Upgrade flutter to 1.9.1+hotfix.2
  2. Run flutter create -t module --org com.test test1
  3. Enter the test1 project: cd test1
  4. Start the ios simulator
  5. Run flutter run, everything works fun at this time.
  6. Add the plugin device_info in pubspec.yaml:
dependencies:
  device_info: ^0.4.0
  1. Run flutter packages get
  2. Run flutter run... failed!

Or clone the test project: https://github.com/yrom/test1

  1. git clone https://github.com/yrom/test1.git
  2. cd test1
  3. flutter packages get
  4. flutter run

Logs

Launching lib/main.dart on iPhone Xʀ in debug mode...
Running pod install...                                              0.9s
Running Xcode build...                                                  
 ├─Assembling Flutter resources...                           5.3s
 └─Compiling, linking and signing...                         2.3s
Xcode build done.                                            9.1s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    mkdir -p /Users/yrom/Downloads/test1/build/ios/Debug-iphonesimulator/Runner.app/Frameworks
    rsync --delete -av --filter P .*.?????? --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter
    "- Modules" "/Users/yrom/Downloads/test1/.ios/Pods/../Flutter/engine/Flutter.framework"
    "/Users/yrom/Downloads/test1/build/ios/Debug-iphonesimulator/Runner.app/Frameworks"
    building file list ... done
    Flutter.framework/
    Flutter.framework/Flutter
    Flutter.framework/Info.plist
    Flutter.framework/icudtl.dat
    Flutter.framework/_CodeSignature/
    Flutter.framework/_CodeSignature/CodeResources

    sent 94440045 bytes  received 120 bytes  62960110.00 bytes/sec
    total size is 94428117  speedup is 1.00
    Stripped /Users/yrom/Downloads/test1/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework/Flutter of architectures: armv7 arm64
    Code Signing /Users/yrom/Downloads/test1/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework with Identity -
    /usr/bin/codesign --force --sign -  --preserve-metadata=identifier,entitlements
    '/Users/yrom/Downloads/test1/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework'
    /Users/yrom/Downloads/test1/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework: replacing existing signature
    /Users/yrom/Downloads/test1/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework: Permission denied
    Command PhaseScriptExecution failed with a nonzero exit code
    note: Using new build systemnote: Planning buildnote: Constructing build description

Could not build the application for the simulator.
Error launching application on iPhone Xʀ.

Check out the full verbose log file: https://raw.githubusercontent.com/yrom/test1/master/1.log

Flutter doctor:

[✓] Flutter (Channel stable, v1.9.1+hotfix.2, on Mac OS X 10.14.6 18G87, locale zh-Hans-CN)
    • Flutter version 1.9.1+hotfix.2 at /Users/yrom/Library/flutter
    • Framework revision 2d2a1ffec9 (3 days ago), 2019-09-06 18:39:49 -0700
    • Engine revision b863200c37
    • Dart version 2.5.0

[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.3, Build version 10G8
    • CocoaPods version 1.7.4

...

[✓] Connected device (1 available)
    • iPhone Xʀ • 00D207ED-8863-48FA-ACE7-061D13525B03 • ios • com.apple.CoreSimulator.SimRuntime.iOS-12-4 (simulator)

Activity

yrom

yrom commented on Sep 10, 2019

@yrom
Author

After investigating, i think the root cause was the xcode_backend.sh will mark the files under Flutter.framework tobe readonly.

For someone run into this issue, try modify the $FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh for workaround:

--- a/packages/flutter_tools/bin/xcode_backend.sh
+++ b/packages/flutter_tools/bin/xcode_backend.sh
@@ -141,7 +141,7 @@ BuildApp() {
     mkdir "${derived_dir}/engine"
     RunCommand cp -r -- "${flutter_podspec}" "${derived_dir}/engine"
     RunCommand cp -r -- "${flutter_framework}" "${derived_dir}/engine"
-    RunCommand find "${derived_dir}/engine/Flutter.framework" -type f -exec chmod a-w "{}" \;
+    RunCommand find "${derived_dir}/engine/Flutter.framework" -type f -iname '.h' -exec chmod a-w "{}" \;
   else
     RunCommand rm -rf -- "${derived_dir}/Flutter.framework"
     RunCommand cp -r -- "${flutter_framework}" "${derived_dir}"
added
t: xcode"xcodebuild" on iOS and general Xcode project management
toolAffects the "flutter" command-line tool. See also t: labels.
on Sep 10, 2019
mtallenca

mtallenca commented on Sep 10, 2019

@mtallenca

I'm using a flutter module inside of existing app. The upgrade instructions at https://github.com/flutter/flutter/wiki/Upgrading-Flutter-added-to-existing-iOS-Xcode-project have the xcode_backend.sh build phase removed.

I did a similar command in the Pods/Target Support Files/Pods-TARGET/Pods-TARGET-frameworks.sh just above the /usr/bin/codesign command.

zanderso

zanderso commented on Sep 10, 2019

@zanderso
Member
jmagman

jmagman commented on Sep 10, 2019

@jmagman
Member

Duplicate of #39507.

jmagman

jmagman commented on Sep 11, 2019

@jmagman
Member

If someone can flutter update (you must be on the master channel to use add-to-app modules!) and let me know if the issue is fixed, that would be awesome!

jmagman

jmagman commented on Sep 11, 2019

@jmagman
Member

Reopening, @OHeroJ says this is still happening.

@OHeroJ Can you run flutter clean before you build to make sure the old read-only files are removed?

OHeroJ

OHeroJ commented on Sep 11, 2019

@OHeroJ

Reopening, @OHeroJ says this is still happening.

@OHeroJ Can you run flutter clean before you build to make sure the old read-only files are removed?

I see execution flutter after the clean, .ios folder disappeared; run flutter build ios the .ios folder appeared(regenerate), in flutter stable channel;

I mean you would need to merge the branch to the stable branch。

I will try a test in master channel, then tell you result.


$ flutter channel master
$ flutter upgrade
$ flutter clean
$ flutter build ios

Building com.mtd.iosFlutterModule for device (ios-release)...
Automatically signing iOS for device deployment using specified development team in Xcode project: BB535CKPXQ
Running pod install...                                              2.6s
Running Xcode build...

 ├─Building Dart code...
  439.3s (!)
 ├─Generating dSYM file...                                   0.4s
 ├─Stripping debug symbols...                                0.4s
 ├─Assembling Flutter resources...                           4.3s
 └─Compiling, linking and signing...                        40.5s
Xcode build done.                                           498.2s
Built /Users/oheroj/Desktop/TN/flutter_module/build/ios/iphoneos/Runner.app.

in master channel run well! @jmagman ,will combine the branch to the stable branch?

GodRightHand

GodRightHand commented on Sep 11, 2019

@GodRightHand

same problem

egenvall

egenvall commented on Sep 11, 2019

@egenvall

@jmagman

I can confirm that it now works in master channel for me as well.

46 remaining items

vitor-gyant

vitor-gyant commented on Nov 20, 2019

@vitor-gyant

@jmagman Do you still need me to file a new issue now that chmod is going to be removed ?

jmagman

jmagman commented on Nov 20, 2019

@jmagman
Member

@jmagman Do you still need me to file a new issue now that chmod is going to be removed ?

@vitor-gyant If the Podfile you generated on the stable channel works but the one generated on master doesn't, a new issue would be very helpful.

changed the title [-]`flutter run` failed due to 'Permission denied' when replacing signature of 'Flutter.framework' in module-type Flutter project[/-] [+]`flutter run` failed due to 'Permission denied' when replacing signature of 'Flutter.framework'[/+] on Nov 26, 2019
ivanesi

ivanesi commented on Dec 5, 2019

@ivanesi

The same error for our app on stable channel.

Flutter 1.9.1+hotfix.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 68587a0916 (3 months ago) • 2019-09-13 19:46:58 -0700
Engine • revision b863200c37
Tools • Dart 2.5.0

On master channel we have no this error and can build the app.

endrelovas

endrelovas commented on Dec 13, 2019

@endrelovas

Posted a workaround here: #39507

jmagman

jmagman commented on Dec 17, 2019

@jmagman
Member

The same error for our app on stable channel.

Flutter 1.9.1+hotfix.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 68587a0916 (3 months ago) • 2019-09-13 19:46:58 -0700
Engine • revision b863200c37
Tools • Dart 2.5.0

On master channel we have no this error and can build the app.

@ivanesi The fix is on stable 1.12.13 https://flutter.dev/docs/development/tools/sdk/releases?tab=macos. Try running flutter upgrade.

ghost

ghost commented on Dec 18, 2019

@ghost

Upgrading to master is NOT a valid solution, as master does not deploy to Huawei devices properly. The only way is to use 1.9.1 until THAT is fixed.

jmagman

jmagman commented on Dec 18, 2019

@jmagman
Member

Upgrading to master is NOT a valid solution, as master does not deploy to Huawei devices properly. The only way is to use 1.9.1 until THAT is fixed.

#45189 is on all channels, not just master. If you have to stay on 1.9.1, you can manually patch your Flutter SDK's packages/flutter_tools/bin/xcode_backend.sh to https://github.com/flutter/flutter/blob/v1.12.13-hotfixes/packages/flutter_tools/bin/xcode_backend.sh. The Flutter SDK is a git repo, and Flutter channels are branches. To reset, make sure you run git checkout . from your SDK folder before you flutter channel or flutter upgrade again (you've voided your easy-upgrade warranty at that point)

TahaAli07

TahaAli07 commented on Jul 1, 2020

@TahaAli07

Moved from v1.9.1+hotfix.6 to v1.11.0 .

To change flutter version to 1.11.0 just run

flutter version v1.11.0

This fixed this issue for me , tried all other other highly voted solutions but none worked.

pkmangukiya

pkmangukiya commented on Jan 16, 2021

@pkmangukiya

To complete solve this! go here:- https://stackoverflow.com/a/65473410/10563627

github-actions

github-actions commented on Aug 7, 2021

@github-actions

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.

locked as resolved and limited conversation to collaborators on Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    t: xcode"xcodebuild" on iOS and general Xcode project managementtoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @jmagman@endrelovas@yrom@mtallenca@GodRightHand

      Issue actions

        `flutter run` failed due to 'Permission denied' when replacing signature of 'Flutter.framework' · Issue #40146 · flutter/flutter