具有本地代码(如SHARED_Preferences)的M1 Mac-Ffltter项目上的Pod安装错误 [英] Pod install error on M1 Mac - Flutter project with native code like shared_preferences

查看:27
本文介绍了具有本地代码(如SHARED_Preferences)的M1 Mac-Ffltter项目上的Pod安装错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的是MacBook Pro M1(在有人说是因为M1或其他原因之前,我已经用Ffltter和M1编程好几个星期了,但之后我必须重置我的M1)……我的大问题:

我无法使用包含shared_preferencessqlite等本机代码的程序包启动项目,因为每次运行Pod Install时都会出现错误

我在Stack Overflow上搜索,到目前为止没有任何帮助。如果我在没有软件包的情况下开始我的项目,没有任何问题,这是我的Ffltter代码,非常简单:

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:shared_preferences/shared_preferences.dart';

void main() {
 runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Home(),
    );
  }

}


`class Home extends StatelessWidget {
  const Home({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: RaisedButton.icon(
          onPressed: ()async{
            final prefs = await SharedPreferences.getInstance();
            if(prefs.containsKey("test")){
              print("available");
            }else{
              await prefs.setInt("test", 1);
            }
            final send = await post("xxx",body: {
              "query":"SELECT * FROM NEWS"
            });
            print(json.decode(send.body));
          },
          icon: Icon(Icons.person),
          label: Text("Hii")
        ),
      ),
    );
  }
} ,

这是我从Ffltter得到的错误:

    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:177:in `sources'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:1073:in `block in resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/user_interface.rb:64:in `section'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:414:in `analyze'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/user_interface.rb:64:in `section'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:160:in `install!'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command/install.rb:52:in `run'
    /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command.rb:52:in `run'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/bin/pod:55:in `<top (required)>'
    /usr/local/bin/pod:23:in `load'
    /usr/local/bin/pod:23:in `<main>'
    ```
    ――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
    [!] Oh no, an error occurred.
    Search for existing GitHub issues similar to yours:
    https://github.com/CocoaPods/CocoaPods/search?q=dlsym%280x7fdfa0da8bc0%2C+Init_ffi_c%29%3A+symbol+not+found+-+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.14.2%2Flib%2Fffi_c.bundle&type=Issues
    If none exists, create a ticket, with the template displayed above, on:
    https://github.com/CocoaPods/CocoaPods/issues/new
    Be sure to first read the contributing guide for details on how to properly submit a ticket:
    https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md
    Don't forget to anonymize any private data!
    Looking for related issues on cocoapods/cocoapods...
    Found no similar issues. To create a new issue, please visit:
    https://github.com/cocoapods/cocoapods/issues/new
Error output from CocoaPods:
↳
    [!] Automatically assigning platform `iOS` with version `12.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

我编辑了我的Podfile并指定了平台,但没有任何帮助。以下是一些详细信息:

Flutter Version = 1.22.5 (I tried also the newest version 1.22.6)
Xcode Version = 12.3 (I tried also the newest version 12.4)
Cocoa-pods  = 1.10.0 ((I tried also the newest version 1.10.1)

我安装并重新安装了很多次Cocoa-Pods,它也没有帮助

推荐答案

而不是pod install,您需要执行以下操作:

arch -x86_64 pod install     

CocoaPods仍然没有完全支持Apple Silicon。使用arch -x86_64运行命令会强制终端改用Rosetta 2。

如果不起作用,请尝试关注this article

这篇关于具有本地代码(如SHARED_Preferences)的M1 Mac-Ffltter项目上的Pod安装错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆