Flutter Podfile and Pods folders not created in ios directory

前端 未结 5 759
日久生厌
日久生厌 2021-02-06 06:22

Created a new flutter project from Android Studio using the wizard.

Newly created project folder does not have any of the Pods folders or podfile in the ios directory.

相关标签:
5条回答
  • 2021-02-06 06:33

    Once you run flutter build ios a Podfile and Podfile.lock will be created for you in the ios directory.

    Follow the steps in the deploy steps official documentation.

    0 讨论(0)
  • 2021-02-06 06:39

    Here is what I usually do:

    1. go into ios folder
    2. delete the PodFile.lock file
    3. rm -rf Pods
    4. pod cache clean --all
    5. pod deintegrate
    6. pod setup
    7. pod install

    You may also want to do

    pod repo update

    0 讨论(0)
  • 2021-02-06 06:58
    flutter:
          plugin:
            platforms:
              ios:
                pluginClass: AppDelegate
    

    You need to add the above lines to the pubspec.yaml and then the pub would automatically generate the Podfile inside the ios folder.

    0 讨论(0)
  • 2021-02-06 06:59

    I will suggest simply go to your Flutter Package and do flutter create . It will automatically create all the missing files and even Podfile. I have used this command in my project and it is fruitful.

    0 讨论(0)
  • 2021-02-06 07:00

    Recently, I encountered the same problem. No Podfile created even when I add dependency packages in the pubspec.yaml file. In the end, I have to manually add a Pod file in the ios directory and issue 'pod deintegrate', 'pod setup' and 'pod install'.

    Here is my podfile. You can try it:

    # Uncomment this line to define a global platform for your project
    platform :ios, '9.0'
    
    # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
    ENV['COCOAPODS_DISABLE_STATS'] = 'true'
    
    pod 'Firebase/Core'
    pod 'FBSDKLoginKit' #optional
    pod 'GoogleAnalytics'
    
    def parse_KV_file(file, separator='=')
      file_abs_path = File.expand_path(file)
      if !File.exists? file_abs_path
        return [];
      end
      pods_ary = []
      skip_line_start_symbols = ["#", "/"]
      File.foreach(file_abs_path) { |line|
          next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
          plugin = line.split(pattern=separator)
          if plugin.length == 2
            podname = plugin[0].strip()
            path = plugin[1].strip()
            podpath = File.expand_path("#{path}", file_abs_path)
            pods_ary.push({:name => podname, :path => podpath});
          else
            puts "Invalid plugin specification: #{line}"
          end
      }
      return pods_ary
    end
    
    target 'Runner' do
      # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
      # referring to absolute paths on developers' machines.
      use_frameworks! 
      system('rm -rf .symlinks')
      system('mkdir -p .symlinks/plugins')
    
      # Flutter Pods
      generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
      if generated_xcode_build_settings.empty?
        puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
      end
      generated_xcode_build_settings.map { |p|
        if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
          symlink = File.join('.symlinks', 'flutter')
          File.symlink(File.dirname(p[:path]), symlink)
          pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
        end
      }
    
      # Plugin Pods
      plugin_pods = parse_KV_file('../.flutter-plugins')
      plugin_pods.map { |p|
        symlink = File.join('.symlinks', 'plugins', p[:name])
        File.symlink(p[:path], symlink)
        pod p[:name], :path => File.join(symlink, 'ios')
      }
    end
    
    
    #pre_install do |installer|
      # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
     # Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    #end
    
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['ENABLE_BITCODE'] = 'NO'
          config.build_settings['SWIFT_VERSION'] = '4.2'
        end
    
        # Peter aded on 8 Oct 2018
        # workaround for https://github.com/CocoaPods/CocoaPods/issues/7463
        #target.headers_build_phase.files.each do |file|
         # file.settings = { 'ATTRIBUTES' => ['Public'] }
        #end
    
      end
    end
    

    Also, I tried using Vcode to create a new Flutter project. Add package in pubspec.yaml file, save and the podfile was automatically created,

    Create a new Flutter project using Vcode

    1. Start VS Code
    2. Invoke View>Command Palette…
    3. Type ‘flutter’, and select the ‘Flutter: New Project’ action
    4. Enter a project name (e.g. myapp), and press Enter
    5. Specify a location to place the project, and press the blue OK button
    6. Wait for the project creation to continue, and the main.dart file to appear
    7. Add a package in the pubspec.yaml file and save it.
    8. The podfile should be created.
    0 讨论(0)
提交回复
热议问题