Flutter iOS - Run script : xcode_backend.sh Operation not permitted - ios

I'm trying to build any Flutter app on iOS on a new Macbook pro 16"
My project used to work well, then after some flutter upgrade, i can't build any project with Xcode
Problem:
/bin/sh:
/Users/{MyUserName}/Documents/dev/utils/flutter/packages/flutter_tools/bin/xcode_backend.sh:
Operation not permitted Command PhaseScriptExecution failed with a
nonzero exit code
What i tried:
Upgrading Xcode & Command line tools
chmod -R 755 my project, and the flutter lib
Follow the Flutter tutorial to use flutter with the latest version of xcode
Switching flutter channel (tried stable 1.17 & master 1.19)
Delete Xcode (& dependencies) delete Flutter & reinstall both
Now, when i try to create a new flutter project
I always face the issue.
The builds are working when i use flutter run from CLI (on my device)
But if i try to use the project with xcode & try to build or run, i face the issue above.
I cant really find similar issues on the web.
PS: My project are working on my old macbook pro 13" same version of xcode and Flutter

Found the answer:
The problem was that Xcode App didn't have enough rights to read / write files & folders.
To solve it:
Go to System preferences > Security & Privacy
Last tab: Privacy
Full disk access: Add Xcode App
If you dont want Xcode to have full disk access you can add it in "Files and folders" instead, and give Xcode rights to your projects folder

Related

I cant run my flutter project after updating to xcode 14... keep saying Unable to read project 'Runner.xcodeproj'

Unable to get Xcode project information:
2022-12-01 13:57:05.376 xcodebuild[71564:226197] Writing error result bundle to
/var/folders/6g/w7cqd0s54c33_20mrl4v2q640000gn/T/ResultBundle_2022-01-12_13-57-0005.xcresult
xcodebuild: error: Unable to read project 'Runner.xcodeproj'.
Reason: Project /Users/noel/Treegar/treegar-app/ios/Runner.xcodeproj cannot be opened because it is missing its
project.pbxproj file.
i keep getting this error when ever i run flutter run or flutter build ios.
i dont know what to do... it works fine on android but not on ios.
ive updated xcode and flutter same problem
flutter doctor -v
UPdate cocoapod to latest version
update flutter
update xcode
This error message indicates that the Runner.xcodeproj file is missing or cannot be opened.
This file is part of the Xcode project for your Flutter app and is necessary for building and running the app on iOS.
To fix this issue, try the following steps:
Make sure that you have the latest version of Xcode installed on
your computer. You can check for updates and download the latest
version of Xcode from the Mac App Store.
Make sure that you have the latest version of the Flutter SDK
installed on your computer. You can update Flutter by running the
flutter upgrade command in a terminal window.
Make sure that you have the latest version of CocoaPods installed on
your computer. You can update CocoaPods by running the
sudo gem
install -n /usr/local/bin cocoapods
command in a terminal window.
Make sure that you have a valid Xcode project file for your Flutter
app. If the Runner.xcodeproj file is missing, you can try running
the flutter create . command in the root directory of your Flutter
app to recreate the Xcode project files.
If the above steps do not help, you can try deleting the ios directory in your Flutter app and running the flutter create . command again to recreate the Xcode project files from scratch.
After trying these steps, try running the flutter run or flutter build ios command again to see if the issue has been resolved. If you continue to encounter errors, please provide more information about the specific steps you are taking and the full error message you are seeing.
try flutter clear and pubget.
or
try pod install
or
if it is not harmfull for your code try to delete ios folder and recreate it
in your project. may be this can work .

Flutter on OSX M1 Mac gives error on xcode_backend.sh, about xcode project version when building for simulator

I'm on an M1 Mac Mini, Monterey 12.0.1, with XCode 13.1 & it's command-line tools and freshly-installed Flutter MacOS 2.8.0. I create a base Flutter project with
flutter create appname
When I do "flutter run" in the ios folder (in the parent folder it launches ok in Chrome), I get the message:
Could not build the application for the simulator.
Error launching application on iPhone 13.
I tried it with the simulator running, and not. It looks like the Runner XCode project build stages runs a script, xcode_backend.sh. I also tried loading the project in the XCode UI to build and get 'Command PhaseScriptExecution failed with a nonzero exit code' on that script.
If I go and run this script directly, from the project folder of the ios folder:
guy#Guys-Mac-mini ios % /bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh"
I get the message:
error: Your Xcode project is incompatible with this version of Flutter. Run "rm -rf ios/Runner.xcodeproj" and "flutter create ." to regenerate.
I tried the steps indicated, which I also found on Google, and removed the folder and regenerated the project, but the same message is appearing. (I did export the FLUTTER_ROOT environment variable, both in the shell and it's also defined in the XCode project settings.
I can build and run the flutter apps to Chrome, but not for the iOS simulator. I also have no problem building and running Swift apps I've coded on the simulator.
I got my Windows and Android setup running in minutes, but on the M1 Mac it's been hours without success. Any ideas?
I'm a developer with decent of experience, but this is my first stab at Flutter and cross-platform (other than Xamarin). Any help is appreciated.
I can't fully explain it, but the problem I was having was related to my having the project files on an SMB share I was accessing from the Mac.
I setup the project on an SMB share so I could access it from my Windows and Mac workstations. I found that any flutter project on that share would fail compilation.
To test this, I created a new flutter app on my Mac Documents folder, comiled and ran it succesfully in the iOS simulator using 'flutter run'. When I moved that project to the SMB share and tried to run it, I got the compilation error again, and it wouldn't run (I also tried clean and run). I moved the project back to the local drive Documents folder, and was able to run it again.
I also noticed that the Mac access to the SMB share is painfully slow, though I tried a required_signon fixes from
https://kb.synology.com/en-us/DSM/tutorial/What_can_I_do_to_fix_slow_SMB_file_transfers_on_OS_X_10_11_5 but it didn't help.
I had even tried to factory reset my Mac, and I thought that fixed it, but it was only because I hadn't connected to the share yet, and made a test project on the local drive.
PS: I don't expect to use the exact same Flutter project between the Mac and Windows workstations because of paths and SDK locations, but I am using it as a convenient place for transfering the source files.
My team was able to solve this by supplying an absolute path to the xcode_backend script in a run phase and running it. Running it once seemed to be enough and we could remove it thereafter:
/bin/sh "/absolute-path-to-flutter/packages/flutter_tools/bin/xcode_backend.sh" thin
/bin/sh "/absolute-path-to-flutter/packages/flutter_tools/bin/xcode_backend.sh" embed

Build commands failed: CompileAssetCatalog - Cordova for iOS

After setting up a fresh Cordova for iOS project trough the CLI this error comes up.
Build commands failed: CompileAssetCatalog
/Users/a/example/example/platforms/ios/build/emulator/Example.app
/Users/a/example/example/platforms/ios/Example/Images.xcassets
(1 failure) xcodebuild: Command failed with exit code 65
Cordova Version: 9.0.0 (cordova-lib#9.0.1)
Xcode Version: 11.2.1
macOS Version: 10.15
CLI:
cordova create example com.example.app Example
(cd example)
cordova platform add ios
cordova emulate ios --target="iPhone-6-Plus, 9.3"
What I tried:
- Clean up build folder
- Update Node/NPM
- Update Xcode
P.S.: Does it make a difference if the .ipa gets build trough the Cordova CLI or from within Xcode?
Two things here:
If you are using cordova 9.0.0, I'm assuming you're also using cordova-ios 5+. In that case, the "-UseModernBuildSystem=0" in your build.json is no longer necessary. cordova-ios#5 supports the modern build system.
You should also remove the target: --target="iPhone-6-Plus, 9.3". XCode 11 no longer, by default, ships with iOS9 simulators. In fact, you should not specify a target at all, unless necessary.
If you're still facing problems after fixing these two issues, try opening and running your project via XCode, it is likely to provide an improved error log and possible hints to fixes.
there is meny approach that getting resolve exit code 67
1) method 1
cordova platform remove ios
cordova platform add ios
2) in xcode give your provision profile check
You need a development provisioning profile on your build machine.
Apps can run on the simulator without a profile, but they are required
to run on an actual device
https://cordova.apache.org/docs/en/latest/guide/platforms/ios/
3) cordova platform update ios
further informations cordova run with ios error .. Error code 65 for command: xcodebuild with args:
I have solved this issue in Xcode, by creating new
"iOS App Icon". Name it whatever you want, but you must choose it from dropdown in project's settings ie target settings, parameter is "App icons source". Then copy all images via Finder into that folder, and in Xcode
connect(drag&drop) those uncategorised images into placeholders.

Xcode 11.2.1 codesign error when building react native on a physical device

I am using Xcode 11.2.1 (latest now) to build my iOS react native app (react-native#0.61.4)
The build succeed on any simulator but fails on any physical device (no specific OS version)
Is there any special configuration for the new Xcode - even the react-native template app have the same issue - exit with code 1.
Finally I was able to figure out the issue. It was a code signing issue on the physical device. Simply deleting the old certificates from the keychain access then clean and build did the job.
From your terminal rm -rf ~/Library/Developer/Xcode/DerivedData
Go to KeyChain Access and Search for Apple Development ... in your KeyChains and delete them, Xcode will then ask for KeyChain password, make sure to check "Always Allow"
Inside Xcode Product > Clean (or Clean Build Folder)
Build and Run your Project again!
If the error persists you may need to restart your Xcode or even your macbook.
Also, in case of having error with exit code 1, File > Workspace Settings > Build System: Legacy Build System may help debugging your issue.

Flutter, Cannot Build For iOS: Missing .h-Files

Building our Flutter project fails on iOS. The following steps work without problems:
running on the XCode simulator (flutter run)
building in the terminal (flutter build ios)
running on a real device in debug mode (flutter run -d "abcd")
If I open the project in XCode, change the build target to "Generic iOS Device" and hit "Build" or "Archive" I get the following error:
/Users/.../development/testproject/ios/Runner/GeneratedPluginRegistrant.m:6:9: 'flutter_exif_rotation/FlutterExifRotationPlugin.h' file not found
After removing the FlutterExifRotationPlugin, the error reoccurs with the next plugin alphabetically, so I figured that plugins in general don't work at the moment.
I tried:
dev, stable and master channels of flutter
reinstalling XCode
reinstalling Flutter
create a new project and moving the old files there
But nothing worked so far.
Ok the solution was very simple. I had to open the .xcworkspace file instead of the .xcodeproject one.
One WEEK went down the pipe for this error. I hope that you, future reader, will find this comment useful.

Resources