-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Steps to Reproduce
Create a new app and build it for the simulator:
flutter create myapp
cd myapp
<add plugin dependency to pubspec.yaml>
flutter run -d i
git init
git add .
git commit
You've just committed a Podfile.lock file that contains local paths to your plugins and Flutter framework, e.g.
EXTERNAL SOURCES:
Flutter:
:path: /Users/jackson/git/flutter/bin/cache/artifacts/engine/ios
Everyone who builds the app will end up with a different Podfile.lock, and won't be sure whether to check in their version. Unfortunately, adding Podfile.lock to .gitignore is not recommended by the CocoaPods team because it makes builds non-reproducible.
I think we can address this by making some changes to the template app's Podfile.
Instead of having .flutter-plugins be a file, have it be a directory that contains contains a symbolic link called Flutter pointing to the Flutter framework directory, as well as symbolic links to the directories of all the plugin Pods.
Now the Flutter section of the Podfile looks like this:
# Flutter Pods
if Dir.exists? '../.flutter-plugins'
Dir.foreach('../.flutter-plugins') { |name|
next if name == '.' or name == '..'
pod name, :path => "../.flutter-plugins/#{name}/ios"
}
end
Benefits
- Less boilerplate code in the Podfile
- Going to the
ios/directory and runningpod installmanually will actually work (after the first Flutter iOS build) instead of complaining that theFLUTTER_FRAMEWORK_DIRenvironment variable is not set. - The
Podfile.lockwill be the same for everyone. It will look like this:
DEPENDENCIES:
- firebase_database (from `../.flutter-plugins/firebase_database/ios`)
- firebase_storage (from `../.flutter-plugins/firebase_storage/ios`)
- Flutter (from `../.flutter-plugins/Flutter/ios`)
- google_sign_in (from `../.flutter-plugins/google_sign_in/ios`)
- image_picker (from `../.flutter-plugins/image_picker/ios`)
EXTERNAL SOURCES:
firebase_database:
:path: ../.flutter-plugins/firebase_database/ios
firebase_storage:
:path: ../.flutter-plugins/firebase_storage/ios
Flutter:
:path: ../.flutter-plugins/Flutter/ios
google_sign_in:
:path: ../.flutter-plugins/google_sign_in/ios
image_picker:
:path: ../.flutter-plugins/image_picker/ios
...
While we are at it, I think we should add Pods/ to ios/.gitignore, which is allowed according to the Cocoapods team. But that's more a matter of taste since (at least in theory) the contents of that directory should be the same for every developer as long as their Flutter engines are in sync.