kineapps / flutter_archive

Flutter plugin for creating and extracting ZIP files.
https://pub.dev/packages/flutter_archive
BSD 3-Clause "New" or "Revised" License
59 stars 44 forks source link

mac version not working due to regular file instead of symlink #26

Closed fibbers closed 3 years ago

fibbers commented 3 years ago

First of all, thanks for providing this library 👍

I'm trying to build a Mac desktop app and when Flutter runs pub get, I see the following: (stripping prefix dir /opt/flutter/.pub-cache/hosted/pub.dartlang.org/)

$ ls -l flutter_archive-2.0.1/macos/Classes/SwiftFlutterArchivePlugin.swift
-rwxr-xr-x  1 willem  wheel    49B Dec 15 13:03 /flutter_archive-2.0.1/macos/Classes/SwiftFlutterArchivePlugin.swift
$ cat /flutter_archive-2.0.1/macos/Classes/SwiftFlutterArchivePlugin.swift
../../ios/Classes/SwiftFlutterArchivePlugin.swift

and this triggers a Swift error Expressions are not allowed at the top level since it's a regular file instead of a symlink.

When I remove the file and actually create a symlink towards that path, it works:

$ rm /flutter_archive-2.0.1/macos/Classes/SwiftFlutterArchivePlugin.swift
$ ln -s ../../ios/Classes/SwiftFlutterArchivePlugin.swift /flutter_archive-2.0.1/macos/Classes/SwiftFlutterArchivePlugin.swift
$ ls -l /flutter_archive-2.0.1/macos/Classes/SwiftFlutterArchivePlugin.swift
lrwxr-xr-x  1 willem  wheel  49 Jan 28 21:06 /flutter_archive-2.0.1/macos/Classes/SwiftFlutterArchivePlugin.swift -> ../../ios/Classes/SwiftFlutterArchivePlugin.swift

now my app starts running.


I tried to create a PR by making the file a symlink, but I saw it already is a symlink.

So maybe pub doesn't work too well with symlinks, either during publishing or during downloading 🤷‍♂️ I did find this issue, which might be related.

NB: my flutter --version is:

Flutter 1.26.0-12.0.pre • channel dev • https://github.com/flutter/flutter.git
Framework • revision a706cd2112 (2 weeks ago) • 2021-01-14 18:20:26 -0500
Engine • revision effb529ece
Tools • Dart 2.12.0 (build 2.12.0-224.0.dev)
kinex commented 3 years ago

Thanks for your issue report. Please suggest how to fix this, or make a PR. I am not building for Mac in my own projects currently (Mac support was implemented by a contributor). I could look at this later when I have time.

fibbers commented 3 years ago

I'm not sure what's the best solution, but could it be that you're doing pub publish from a Windows machine which might process symlinks incorrectly (just a guess 🤷)? In that case doing pub publish from Linux/Mac might fix it, if that's a feasible option.

And otherwise, I can make a simple PR which removes the symlink and just uses a copy of the file. Downside of course is that maintenance now has to be done in 2 places.

Let me know, I'm happy to create a PR with just a copy of the involved file.

fibbers commented 3 years ago

I created a PR anyway, just in case the Linux/Mac suggestion might not be a solution.

Either decline the PR or merge it, I'm fine with both 😄

kinex commented 3 years ago

Could you please check if 2.0.2 fixes this. I published the plugin from Mac.

fibbers commented 3 years ago

Just updated to 2.0.2 and now it works out of the box 👍 I'll close my PR. Thanks!

kinex commented 3 years ago

Great! Thanks for your help.