如何在 iPhone 上使用 EAS 版本修复 Google 地图错误?

     2023-02-16     304

关键词:

【中文标题】如何在 iPhone 上使用 EAS 版本修复 Google 地图错误?【英文标题】:How to fix a Google Maps Error with EAS build on iPhone? 【发布时间】:2022-01-13 17:02:42 【问题描述】:

我将 Expo SDK 43 Managed Workflow 项目迁移到 EAS Build。

我使用 Google 地图作为 Android 和 iOS 的默认地图选择,但是当我导航到带有地图的屏幕时,我收到此错误:

react-native-maps: AirGoogleMaps dir must be added to your xCode project to support GoogleMaps
 on iOS. at node_modules/react-native-maps/lib/components/decorateMapComponent.js:27:54 in <anonymous>

当我按照错误中列出的路径访问我的 node_modules 文件时,它会将我带到“decorateMapComponent.js”,这是一个包含以下代码的 js 文件。

需要修改哪些内容才能让 iOS 上的 EAS 接受 Google 地图?

下面是代码:

import PropTypes from 'prop-types';
import  requireNativeComponent, NativeModules, Platform  from 'react-native';
import  PROVIDER_DEFAULT, PROVIDER_GOOGLE  from './ProviderConstants';

export const SUPPORTED = 'SUPPORTED';
export const USES_DEFAULT_IMPLEMENTATION = 'USES_DEFAULT_IMPLEMENTATION';
export const NOT_SUPPORTED = 'NOT_SUPPORTED';

export function getAirMapName(provider) 
  if (Platform.OS === 'android') 
    return 'AIRMap';
  
  if (provider === PROVIDER_GOOGLE) 
    return 'AIRGoogleMap';
  
  return 'AIRMap';


function getAirComponentName(provider, component) 
  return `$getAirMapName(provider)$component`;


export const contextTypes = 
  provider: PropTypes.string,
;

export const createNotSupportedComponent = message => () => 
  console.error(message);
  return null;
;

function getViewManagerConfig(viewManagerName) 
  const UIManager = NativeModules.UIManager;
  if (!UIManager.getViewManagerConfig) 
    // RN < 0.58
    return UIManager[viewManagerName];
  
  // RN >= 0.58
  return UIManager.getViewManagerConfig(viewManagerName);


export const googleMapIsInstalled = !!getViewManagerConfig(
  getAirMapName(PROVIDER_GOOGLE)
);

export default function decorateMapComponent(
  Component,
   componentType, providers 
) 
  const components = ;

  const getDefaultComponent = () =>
    requireNativeComponent(getAirComponentName(null, componentType), Component);

  Component.contextTypes = contextTypes;

  Component.prototype.getAirComponent = function getAirComponent() 
    const provider = this.context.provider || PROVIDER_DEFAULT;
    if (components[provider]) 
      return components[provider];
    

    if (provider === PROVIDER_DEFAULT) 
      components[PROVIDER_DEFAULT] = getDefaultComponent();
      return components[PROVIDER_DEFAULT];
    

    const providerInfo = providers[provider];
    const platformSupport = providerInfo[Platform.OS];
    const componentName = getAirComponentName(provider, componentType);
    if (platformSupport === NOT_SUPPORTED) 
      components[provider] = createNotSupportedComponent(
        `react-native-maps: $componentName is not supported on $Platform.OS`
      );
     else if (platformSupport === SUPPORTED) 
      if (
        provider !== PROVIDER_GOOGLE ||
        (Platform.OS === 'ios' && googleMapIsInstalled)
      ) 
        components[provider] = requireNativeComponent(componentName, Component);
      
     else 
      // (platformSupport === USES_DEFAULT_IMPLEMENTATION)
      if (!components[PROVIDER_DEFAULT]) 
        components[PROVIDER_DEFAULT] = getDefaultComponent();
      
      components[provider] = components[PROVIDER_DEFAULT];
    

    return components[provider];
  ;

  Component.prototype.getUIManagerCommand = function getUIManagerCommand(name) 
    const componentName = getAirComponentName(
      this.context.provider,
      componentType
    );
    return getViewManagerConfig(componentName).Commands[name];
  ;

  Component.prototype.getMapManagerCommand = function getMapManagerCommand(
    name
  ) 
    const airComponentName = `$getAirComponentName(
      this.context.provider,
      componentType
    )Manager`;
    return NativeModules[airComponentName][name];
  ;

  return Component;

【问题讨论】:

试试这个github.com/react-native-maps/react-native-maps/issues/… @ErikMazzelli 我没有可以像这样安装的原生可可豆荚;我的项目最初是 Expo Managed Workflow 【参考方案1】:

尝试像这样将“expoCli”:“4.13.0”添加到您的 eas.json:

  "cli": 
    "version": ">= 0.41.0"
  ,
  "build": 
    "base": 
      "expoCli": "4.13.0",
    ,
    "simulator": 
      "extends": "base",
      "android": 
        "buildType": "apk"
      ,
      "ios": 
        "simulator": true
      
    ,
    "development": 
      "extends": "base",
      "developmentClient": true,
      "distribution": "internal"
    ,
    "preview": 
      "extends": "base",
      "distribution": "internal"
    ,
    "production": 
      "extends": "base",
      "releaseChannel": "production"
    
  ,
  "submit": 
  


有同样的问题,对我有用。

【讨论】:

很抱歉我的回复延迟了。事实证明,我必须为 iOS 设备本身添加一个 API 密钥,但我无法在 Android 上加载地图。对这个问题有什么想法吗?

仅在 iphone 11 上显示 UI 图像在其他 iphone 版本上隐藏

...发布时间】:2021-01-0416:33:02【问题描述】:使用情节提要如何仅在特定iphone版本上显示UI图像并将其隐藏在其他iphone版本(例如iphone8)上?这可能很快吗?【问题讨论】:【参考方案1】:使用Storyboard,您可以根据尺 查看详情

如何在同一部 iPhone 中获取两个不同版本的可执行文件?使用 Xcode

】如何在同一部iPhone中获取两个不同版本的可执行文件?使用Xcode【英文标题】:HowtogettwodifferentversionofexecutableinthesameiPhone?usingXcode【发布时间】:2012-09-0413:20:49【问题描述】:如果我的问题非常基本,请原谅。我使用的是Xcode4.3... 查看详情

如何在 iPhone 6 上安装旧版本的 TestFlight

】如何在iPhone6上安装旧版本的TestFlight【英文标题】:HowtoinstallanoldversionofTestFlightonaniPhone6【发布时间】:2020-12-0812:00:26【问题描述】:我想在iPhone6上测试一个IOS应用程序,但为此,我需要安装TestFlight。不过最新版本的TestFlight... 查看详情

如何提交在 iPhone OS 3 和 iPhone SDK 4 上运行的应用程序版本?

】如何提交在iPhoneOS3和iPhoneSDK4上运行的应用程序版本?【英文标题】:HowtosubmitanappversionwhichrunsoniPhoneOS3andiPhoneSDK4?【发布时间】:2010-06-2821:54:44【问题描述】:我在我的Mac上安装了sdk4。我需要提交在OS3和OS4上运行的版本吗?我... 查看详情

如何让视频背景在 iPhone / 手机上播放?

】如何让视频背景在iPhone/手机上播放?【英文标题】:HowtomakevideobackgroundsplayoniPhone/mobile?【发布时间】:2016-01-2001:16:47【问题描述】:我们计划使用AfterEffects视频作为我们的横幅/英雄图像,因为我们的动画序列有点复杂。但是... 查看详情

如何使用 G++ 和 CPLEX 修复此“未定义引用”错误?

】如何使用G++和CPLEX修复此“未定义引用”错误?【英文标题】:HowcanIfixthis"undefinedreference"errorusingG++andCPLEX?【发布时间】:2020-08-0609:52:01【问题描述】:如果这不是正确的社区来询问这个问题,我深表歉意,在这种情况... 查看详情

如何修复“升级的”颠覆工作目录?

】如何修复“升级的”颠覆工作目录?【英文标题】:HowcanIrepair"upgraded"subversionworkingdirectories?【发布时间】:2010-09-1305:27:57【问题描述】:这听起来可能很愚蠢,但有时我会遇到两个颠覆版本之间的版本冲突。我使用sshf... 查看详情

如何使用 Python 2.7 在 Windows 上修复 pip 安装证书问题? [复制]

】如何使用Python2.7在Windows上修复pip安装证书问题?[复制]【英文标题】:HowcanIfixpipinstallcertificateissueonWindowswithPython2.7?[duplicate]【发布时间】:2018-09-2713:08:49【问题描述】:在Windows中,我安装了Python2.7。我在我的虚拟环境中使用... 查看详情

iPhone:如何将 inputAccessoryView 修复为 View?

】iPhone:如何将inputAccessoryView修复为View?【英文标题】:iPhone:HowtofixinputAccessoryViewtoView?【发布时间】:2011-07-2123:43:22【问题描述】:我有一个工具栏,我需要在编辑文本时使用它,什么时候不需要。在以前的应用中,我手动移... 查看详情

如何在iphone上制作小部件

学习如何从第三方应用程序制作可自定义的小部件和小部件。可以在任何装有iOS14或更高版本的iPhone上执行此操作。如何在iPhone上制作小部件要制作小部件,首先从应用商店下载第三方应用,例如Widgetsmith。在主屏幕上,点击并按... 查看详情

iPhone 发布版本的功能与调试版本不同

...asdebugbuild【发布时间】:2009-08-3117:44:51【问题描述】:在使用调试版本时,我的程序在iPhone模拟器和iPhone本身上都按照我希望的方式运行。但是,当我将其更改为发布版本时,它可以在iPhone模拟器上运行,但不能在设备上运行。... 查看详情

如何在 Unity 上修复“Gradle Build Failed”?

】如何在Unity上修复“GradleBuildFailed”?【英文标题】:Howtofix\'\'GradleBuildFailed\'\'onUnity?【发布时间】:2021-12-1422:57:51【问题描述】:我正在尝试构建我的android应用程序一段时间,但似乎找不到任何解决此问题的方法:ImageUnity版... 查看详情

如何在 c++ Autotools 项目中使用不同版本的 g++ 进行编译

】如何在c++Autotools项目中使用不同版本的g++进行编译【英文标题】:HowcanIcompilewithdifferentversionofg++inc++Autotoolsproject【发布时间】:2018-12-2509:18:25【问题描述】:我有一个大的autotools项目,子目录下一部分代码使用g++-4.9编译,其... 查看详情

如何在应用程序版本更新时维护 iPhone 上 SQLite 数据库中的数据?

】如何在应用程序版本更新时维护iPhone上SQLite数据库中的数据?【英文标题】:HowtomaintaindatainanSQLiteDatabaseonaniPhoneataversionupdateoftheapplication?【发布时间】:2011-04-0516:20:15【问题描述】:我的iPhone应用程序的第一个版本(位于应用... 查看详情

如何在 iPhone 上创建圆角 UILabel?

】如何在iPhone上创建圆角UILabel?【英文标题】:HowdoIcreatearoundcorneredUILabelontheiPhone?【发布时间】:2010-10-0508:29:16【问题描述】:是否有创建圆角UILabel的内置方法?如果答案是否定的,人们将如何创建这样一个对象?【问题讨论... 查看详情

在 Android 上构建 Flutter 应用程序时如何修复“依赖失败”

】在Android上构建Flutter应用程序时如何修复“依赖失败”【英文标题】:Howtofix\'Dependencyfailing\'whenbuildingFlutterapplicationonAndroid【发布时间】:2019-08-2900:44:42【问题描述】:我正在尝试在我的Flutter应用程序中使用Google登录。但是,... 查看详情

如何在运行时检查操作系统版本,例如在 Windows 或 Linux 上,不使用条件编译语句

】如何在运行时检查操作系统版本,例如在Windows或Linux上,不使用条件编译语句【英文标题】:HowtochecktheOSversionatruntime,e.g.onWindowsorLinux,withoutusingaconditionalcompilationstatement【发布时间】:2011-07-0406:29:51【问题描述】:如何确定我... 查看详情

在 iPhone 上使用 UISplitViewController 时如何实现推送导航?

】在iPhone上使用UISplitViewController时如何实现推送导航?【英文标题】:HowtoimplementpushnavigationwhenusingUISplitViewControlleroniPhone?【发布时间】:2014-07-3121:24:08【问题描述】:我想实现一个在iPad和iPhone上运行的UISplitViewController。在iPhone... 查看详情