I am currently trying to test my flutter app on iPhone so I installed intellij, flutter and all other stuff. Everything was going well except that I was unable to build even the demo flutter app on my Mac. In fact, when I run
$ flutter create project_name
It returns
Creating project project_name... Wrote 54 files.
Running "flutter packages get" in project_name...
Could not find a file named "pubspec.yaml" in "/Users/user/.pub-cache/hosted/pub.dart-lang.org/typed_data-1.1.3".
pub get failed (1)
I can neither run "flutter run" nor "flutter packages get" with the same kind of error, it seem's that the paths to flutter packages are always wrong but when I try in sudo mode I can run all of those commands but I cannot see any device.
Do you have any idea of what I can do to solve this issue ?
Flutter relies on Dart's Pub package manager to manage dependencies under the hood. Pub maintains a cache of downloaded packages in ~/.pub-cache. This cache appears to be at least partially corrupted in your case. The pub cache is entirely safe to delete; pub will re-download anything it needs.
The simplest bet is to delete the entire cache via rm -rf ~/.pub-cache. It's possible that just that one package is corrupt, in which case, you may be able to get away with selectively deleting just the one (rm -rf ~/.pub-cache/hosted/pub.dart-lang.org/typed_data-1.1.3).
Related
What to do when the Flutter app gets stuck on launching or installing dependencies or it fails out of the blue. I have noticed this issue coming up more and more in iOS. Android has its own issues. but a basic flutter upgrade or flutter pub upgrade can cause a lot wastage in developer time as the app will refuse to Build after some of the previously mentioned actions.
Track the list of items one can do to fix the unexpected long build times and build failures
I have been working with flutter for a while and there are few things which I believe can be done to get out of a bad flutter build situation.
Problems being considered
Stuck on flutter clean.
Stuck on flutter run.
Build Failure on Flutter pub upgrade.
The below mentioned solutions were performed and it has solved the problems for me in the past and I very well understand this is not a very clear solution but it still would be worth trying as it solved the issue for me in most cases.
Listing down few of the commands or actions which helped me in solving the issues.
Note: These are mostly related to solving the issues in building on iOS
flutter upgrade.
flutter pub cache clean.
flutter pub cache repair
flutter clean.
Deleting .dart_tools
Deleting Runner.xcworkspace.
Deleting .symlinks
Deleting Pods/
pod deintegrate(inside iOS folder)
pod cache clean --all.
pod repo update
pod update
pod install
if nothing works then
update the bundle identifier.
Delete iOS folder, run flutter create app with the bundle id and copy the iOS folder to project
I'm trying to run my application on an iPhone simulator. from the console, I can see the build was successful. but on the next line, I get this.
error Couldn't find "PLATFORM_NAME" variable in xcodebuild output. Please report this issue and run your project with Xcode instead. react-native.
This is quite bizarre, but after getting this error I opened up the workspace in Xcode and ran it from there. Afterwards this error went away when running react-native run-ios
I suspect this might have something to do with the way Xcode 12 optimizes builds and that re-building it from Xcode somehow fixed it. I would like to know why, but I cbf'ed figuring it out myself.
This happened to me because I clean up some image, and removed some native dependancies. All I did was cd ios && pod install then yarn ios to build again.
Tried cleaning build folder and ran, it worked.
Xcode toolbar -> Product -> Clean build folder
Step - 1: Clean the build folder from Xcode.
Xcode toolbar -> Product -> Clean build folder
Step - 2: Delete the App installed in the device/simulator
Step - 3: Go to VSCode and move to ios directory using command line and just to be on the safer side, run the following command (just to remove build folder via VSCode as well)
rm -rf build
Step - 4: Run
pod install
Step - 5: Go back to the project folder and build the app again:
npx react-native run-ios
Context: react-native upgrade fails and cleaning the build folder doesn't work.
What works:
Trash out the node_modules folder.
Make yarn install to re-create dependencies.
It doesn't have any impact on "Podfile", but if you (future users) did, remove Podfile.lock, go to the ios folder and run pod install again. It must solve.
This is obviously overkill, but a reboot fixed this problem for me. I turned off my computer and turned it on again, and it's now working well.
When I log in to "Podfile" I will not be able to say why it does not work, but if you (future users) do it, remove Podfile.lock, go to the ios folder and run it again pod install. It must be resolved
I just installed Exercism and would like to test if I managed to complete the hello-world assignment.
I changed the hello_world.dart file in the lib folder to print the solution, but now I am struggling with running the test file.
In the guide it says to simply run
$ pub run test
Is the $-sign meant to mean something to me? Cause all I am getting is: "'$' is not recognized as an internal or external command,operable program or batch file." I have the same issue with running "pub get" or "pub run test". (What does pub mean?)
To summarize, I ran:
exercism configure "my token"
exercism download --exercise=hello-world --track=dart
cd C:\Users\Martin\exercism\dart\hello-world
I changed the file in C:\Users\Martin\Exercism\dart\hello-world\lib
And then I tried
$ pub run test
pub run test
pub get
And none of these seem to do anything. So, I don't know how to test my file.
I do have flutter installed and run is fine with Android Studio, if that is relevant. It seems to me that I can choose to write the solution in both notepad++ or Android Studio.
Thanks for any help
pub is package manager for dart programming language, just like npm for javascript. Since you've installed it on WINDOWS i'm guessing you used choco - package manager to install the dart-sdk. https://dart.dev/get-dart.
Once installed make sure you've set dart-sdk the path in Environment variable.
In a package.json file (which is basically the Node version of Flutters pubspec.yaml) You have a scripts section where you can add your own custom scripts. Normally with a node project you'll have a start script that will kick off the build and, well, start the project. In flutter you have flutter run.
In my flutter project I'm using the json_serializable package that generates the code that I use when serialising my objects to JSON. Right now I have to have two terminal windows open:
Tab 1
Runs flutter packages pub run build_runner watch that does the code generation and watches the file system.
Tab 2
Run flutter run that runs the project with hot reloading.
So it would be great if you had something like Nodes prestart in pubspec.yaml where I can run the code generation automatically when I run flutter run
There currently is no such thing in Dart. You can create your own Dart or shell scripts in tool/ that runs your builder_runner command detached (in the background) and the flutter run command in the foreground.
you can start this just using tool/run.dart
However with build becoming mature and pub serve/pub build being deprecated I assume the Dart team is thinking already about making this a more pleasant experience.
I'm working on a Cordova based mobile application, and wanted to make use of the Cordova CLI's ability to deploy and run my mobile app right from the command line, without having to go into XCode to do the build
When doing:
cordova run ios --device
Cordova graciously tells you that you should install the ios-deploy node module. I did so following the steps on their GIT site.
When I next tried to do a run, I started to get codesign errors, specifically:
/Users/blahblah/platforms/ios/build/device/myApp.app: Permission denied
Command /usr/bin/codesign failed with exit code 1
I couldn't get the code signing to work from Terminal, and worse, going back into XCode resulted in the same error!
Fortunately the error messages says it all: permission denied; I was able to correct this by popping back into Terminal and running a chmod on my entire app folder, i.e.:
chmod -R a+rwx myApp
I could then go back into XCode and get the project building and deploying again (whew!), however if I tried to do the deploy via the Cordova CLI, then same issue would occur.
It seems like the ios-deploy and / or cordova is messing around with the folder permissions, but I'm not sure how to correct this.
Any suggestions would be appreciated!
UPDATE:
To be clear, I am able to successfully sign the app within XCode if I first go into Terminal, and then into the platforms/ios folder and perform a chmod -R a+rwx on the "www" folder.
The problem I'm having is trying to get this to build / sign successfully from the command line.
I've done some further diagnosis, and it seems that the problem is with the Cordova CLI itself, and not with ios-deploy; when I execute:
cordova prepapre
It copies my "www" folder over to the "platforms/ios/www", however it changes the permissions when doing so from everyone having write access (i.e.: drwxrwxrwx) to only my user having write access i.e.: (drwxr-xr-x)
It seems that this is fouling up the codesign application, and is causing my permission denied errors above.
I'm just hoping someone knows how I can work around this, or what I might be doing wrong with my build - I'd prefer not to have to go into XCode to do these builds.
So it turns out that the Cordova CLI is working just fine, as is the ios-deploy npm package.
The problem turns out to be within the solution itself, and has nothing to do with the tools.
I am using the Ionic framework within this particular Cordova application, and their framework installs some "after_prepare" hooks (within the hooks folder) which attempt to help prepare / clean up some extraneous files prior to the build.
One of these hooks (named "020_remove_sass_from_platform.js") was trying to help out by cleaning up unneeded SASS files prior to the build in order to reduce the size of the compiled app.
Unfortunately this hook was adjusting the folder permissions (I guess in order to ensure the delete could succeed), and this was the cause of the "www" folder's permissions changing during a "cordova prepare".
I deleted the hooks, and now the Cordova CLI builds and signs the APK as expected, and the ios-deploy package pushes it to the device, all without using XCode.
Hope this can be of some help to someone else.
Check the CODE_SIGN_IDENTITY property in your build settings. Is your provisioning profile selected there?
You also need to enter a valid bundle identifier in your apps .plist.
The identifier has to match the one you provided when generating the profile.
Try this
sudo npm install -g ios-deploy --unsafe-perm