首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用iOS!:链接=>:静态时映射use_frameworks构建问题

使用iOS!:链接=>:静态时映射use_frameworks构建问题
EN

Stack Overflow用户
提问于 2021-04-06 09:55:48
回答 3查看 4K关注 0票数 3

主要错误:找不到GMUHeatmapTileLayer.h not foundGMUKMLParser.h .

我的Podfile是这样的:

代码语言:javascript
运行
复制
source 'https://github.com/CocoaPods/Specs.git'
    
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
    
install! 'cocoapods', :deterministic_uuids => false
    
platform :ios, '10.0'
    
 
target 'myProject' do
  rn_maps_path = '../node_modules/react-native-maps';
  pod 'react-native-google-maps', path: rn_maps_path
  pod 'GoogleMaps'
  pod 'GooglePlaces'
  pod 'Google-Maps-iOS-Utils',


  config = use_native_modules!
  use_react_native!(
  :path => config[:reactNativePath],
  # to enable hermes on iOS, change `false` to `true` and then install pods
  :hermes_enabled => false
  )

  pod 'react-native-document-picker', :path => '../node_modules/react-native-document-picker'

  pod 'Google-Mobile-Ads-SDK',  '~> 7.69.0'

  pod 'GoogleSignIn', '~> 5.0.0'

  pod 'RNPhotoEditor', :path => '../node_modules/react-native-photo-editor/ios'

  use_frameworks! :linkage => :static

  pod 'iOSPhotoEditor', :git => 'https://github.com/prscX/photo-editor', :branch => 'master'


  post_install do |installer|
     installer.pods_project.targets.each do |target|
      if target.name.include?('iOSPhotoEditor')
        target.build_configurations.each do |config|
          config.build_settings['SWIFT_VERSION'] = '5'
        end
      end
      target.build_configurations.each do |config|
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
      end

      if target.name == 'react-native-google-maps'
        target.build_configurations.each do |config|
          config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
        end
      end

      if (target.name&.eql?('FBReactNativeSpec'))
        target.build_phases.each do |build_phase|
          if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
            target.build_phases.move(build_phase, 0)
          end
        end
      end
    end
  end

  # Follow [Flipper iOS Setup Guidelines][https://fbflipper.com/docs/getting-started/ios-native/]
  # This is required because iOSPhotoEditor is implementated using Swift
  $static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly',
    'CocoaAsyncSocket', 'ComponentKit', 'Flipper-DoubleConversion',
    'Flipper-Glog', 'Flipper-PeerTalk', 'Flipper-RSocket', 'Yoga', 'YogaKit',
    'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native']

  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    installer.pod_targets.each do |pod|
        if $static_framework.include?(pod.name)
          def pod.build_type;
            Pod::BuildType.static_library
          end
        end
      end
  end
end

在为react-native-photo-editor添加了需要use_frameworks! :linkage => :static的代码之后

react-native-maps找不到google-maps-ios-utils文件。

GMUHeatmapTileLayer.h file not found

我尝试过手动添加google-maps-ios-utils,如下所述:

https://github.com/googlemaps/google-maps-ios-utils/blob/b721e95a500d0c9a4fd93738e83fc86c2a57ac89/Swift.md

但是,AirGoogleMaps文件仍然无法访问这些文件:

经社部:

代码语言:javascript
运行
复制
RN: 0.64.0
react-native-maps: 0.28
Google-Maps-iOS-Utils: 2.1.0
GoogleMaps: 3.5.0

是否有人在google地图和use_frameworks!中成功地使用了use_frameworks!

我的豆荚文件有什么问题吗?

我如何使这个Google-Maps-iOS-Utils: 2.1.0工作?

有没有任何步骤可以手动添加这个库,并让它使用RN0.64中的桥接头与上面的use_frameworks一起构建呢?

我也尝试了所有的步骤从这个答案,但同样的错误,在打印屏幕图像显示。

https://github.com/react-native-maps/react-native-maps/issues/3536#issuecomment-683563649

有关node_modules deps的更多信息:

代码语言:javascript
运行
复制
"dependencies": {
"@react-native-async-storage/async-storage": "1.14.1",
"@react-native-community/geolocation": "2.0.2",
"@react-native-community/google-signin": "5.0.0",
"@react-native-community/hooks": "2.6.0",
"@react-native-community/image-editor": "2.3.0",
"@react-native-community/netinfo": "6.0.0",
"@sentry/browser": "6.2.3",
"@sentry/react-native": "2.4.0",
"@svgr/webpack": "4.2.0",
"@xobotyi/scrollbar-width": "1.9.5",
"abortcontroller-polyfill": "1.7.1",
"bfj": "6.1.1",
"case-sensitive-paths-webpack-plugin": "2.2.0",
"color": "3.1.3",
"cross-fetch": "3.1.2",
"css-loader": "1.0.1",
"dotenv": "6.2.0",
"dotenv-expand": "4.2.0",
"file-loader": "2.0.0",
"html-webpack-plugin": "4.0.0-beta.4",
"leaflet": "1.7.1",
"lokijs": "1.5.11",
"mini-css-extract-plugin": "0.4.4",
"optimize-css-assets-webpack-plugin": "5.0.1",
"pnp-webpack-plugin": "1.2.1",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"postcss-preset-env": "6.5.0",
"postcss-safe-parser": "4.0.1",
"query-string": "6.6.0",
"react": "17.0.1",
"react-dev-utils": "10.2.1",
"react-dom": "17.0.1",
"react-leaflet": "3.1.0",
"react-native": "0.64.0",
"react-native-admob": "2.0.0-beta.6",
"react-native-device-info": "8.0.7",
"react-native-document-picker": "5.0.2",
"react-native-fs": "2.16.6",
"react-native-google-places-autocomplete": "2.2.0",
"react-native-image-crop-picker": "0.36.0",
"react-native-image-size": "1.1.3",
"react-native-local-mongodb": "2.2.9",
"react-native-maps": "0.28.0",
"react-native-photo-editor": "^1.0.10",
"react-native-safe-area-context": "3.2.0",
"react-native-sensitive-info": "5.5.8",
"react-native-splash-screen": "3.2.0",
"react-native-svg": "12.1.0",
"react-native-vector-icons": "8.1.0",
"react-native-web": "0.15.0",
"react-router": "5.1.2",
"react-router-dom": "5.1.2",
"resolve": "1.10.0",
"rn-fetch-blob": "0.12.0",
"sass-loader": "7.1.0",
"style-loader": "0.23.1",
"terser-webpack-plugin": "1.2.3",
"ts-events": "3.4.0",
"typescript": "4.0.5",
"url-loader": "1.1.2",
"uuid": "3.4.0",
"webpack": "4.41.6",
"webpack-dev-server": "3.10.3",
"webpack-manifest-plugin": "2.2.0",
"workbox-webpack-plugin": "3.6.3"
},
"resolutions": {
  "typescript": "4.0.5"
},
"devDependencies": {
"@babel/core": "7.12.9",
"@babel/plugin-proposal-class-properties": "7.12.13",
"@babel/plugin-proposal-decorators": "7.12.13",
"@babel/plugin-transform-flow-strip-types": "7.12.13",
"@babel/plugin-transform-runtime": "7.12.15",
"@babel/polyfill": "7.12.1",
"@babel/runtime": "7.12.5",
"@carimus/metro-symlinked-deps": "1.1.0",
"@react-native-community/eslint-config": "2.0.0",
"@typescript-eslint/eslint-plugin": "4.19.0",
"@typescript-eslint/parser": "4.19.0",
"babel-jest": "26.6.3",
"babel-loader": "8.2.2",
"babel-plugin-module-resolver": "4.0.0",
"babel-plugin-named-asset-import": "0.2.3",
"babel-plugin-react-native-web": "0.15.0",
"babel-plugin-transform-remove-console": "6.9.4",
"babel-preset-react-app": "7.0.2",
"eslint": "7.19.0",
"jest": "26.6.3",
"jetifier": "^1.6.6",
"metro-react-native-babel-preset": "0.64.0",
"mockdate": "2.0.5",
"moment-timezone": "0.5.33",
"path-exists": "4.0.0",
"react-error-overlay": "6.0.6",
"react-test-renderer": "17.0.1",
"sftp-sync-deploy": "0.7.1",
"yarn-run-all": "3.1.1"
},

补充说明:

当我添加https://github.com/prscX/react-native-photo-editor (它需要use_frameworks)时,构建过程被破坏了(触发新的崩溃与rn-map相关)。如果我从Podfile中删除这个模块和与它相关的额外设置,一切都是正常的。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2021-04-12 17:57:32

为了能够像问题中所描述的那样使用react-native-mapsuse_frameworks构建项目,我必须分叉react-native-maps库并替换

中的头导入中带有Google_Maps_iOS_UtilsGoogle_Maps_iOS_Utils

lib/ios/AirGoogleMaps/AIRGoogleMap.m**:**

代码语言:javascript
运行
复制
#import <Google_Maps_iOS_Utils/GMUKMLParser.h>
#import <Google_Maps_iOS_Utils/GMUPlacemark.h>
#import <Google_Maps_iOS_Utils/GMUPoint.h>
#import <Google_Maps_iOS_Utils/GMUGeometryRenderer.h>

lib/ios/AirGoogleMaps/AIRGoogleMapHeatmap.h**:**中

代码语言:javascript
运行
复制
#import <Google_Maps_iOS_Utils/GMUHeatmapTileLayer.h>

如果有人知道一个比这更好的解决办法,我很乐意接受它,如果在接下来的几天里增加答案,我将给予它附加在这个问题上的赏赐。

我可能会一直使用叉子,直到react-native-maps更新为一个更新的google-maps-ios-utils版本(在v3中,我认为问题已经解决了)。

"react-native-maps": "https://github.com/fdobre/react-native-maps#hot-fix-use-frameworks-ios",

票数 2
EN

Stack Overflow用户

发布于 2021-04-14 11:59:18

TL;DR:这里是使用基本需求的项目构建(具有用户框架的react-原生映射和react原生-照片编辑器)。

添加AirMaps和AirGoogleMaps。

来源

  1. 右键单击项目并单击Add files to <projecjName>

  1. goto -> node_modules/react-native-maps/lib/ios/
  2. 同时选择AirMaps和AirGoogleMaps
  3. 确保选项create groups和目标被选中。

将Airmap文件夹添加到库搜索路径:

  1. Goto目标->构建设置->搜索库搜索路径,并为调试和发布( "$(PODS_ROOT)/../../node_modules/react-native-maps/lib/ios/AirMaps" )添加以下行(带引号)

添加google-maps ios-utils:

根据这些官方的说明

  1. 在ios文件夹上使用不同名称的git clone https://github.com/googlemaps/google-maps-ios-utils。我们只需要src文件夹的内容。
  2. 在XCODE上,右键单击一个项目并创建一个名为Google-Maps-iOS-Utils的组。
  1. 右键单击该文件夹并单击Add files to ...
  2. 选择步骤(I)之前克隆的src目录的所有文件夹。
  3. 确保选择的选项是“创建组”,并选择目标作为您的应用程序目标。
  1. 删除Google-Maps-iOS-Utils/Heatmap/HeatMapInterpolationPoint.swift file中提到的这里。删除时选择删除引用。
  2. Goto项目->构建设置->搜索preprocessor macros,并为调试和发布添加以下内容。 HAVE_GOOGLE_MAPS=1 HAVE_GOOGLE_MAPS_UTILS=1

重复符号错误

由于我们手动添加了AirGoogleMaps、AirMaps、AirGoogleMaps iOS-Utils,我们可能会出错:

错误: ld: 658用于架构x86_64的重复符号

解决办法:

  1. 从“删除Google-Maps-iOS-Utils”部分删除Pods/Pods (选择“删除引用”选项)。因为我们手动添加了Google-Maps-iOS-Utils

如果我们编译,我们将得到ld: 470 duplicate symbols for architecture x86_64

  1. react-native-mapsreact-native-google-maps中删除Pods/Development Pods

(This is the repetitive task)这里删除的所有3个文件夹,都将重新生成pod install执行的所有内容。

更新1:

下面是我的Pod文件的样子:

代码语言:javascript
运行
复制
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '10.0'

target 'myAwesomeProject' do
  rn_maps_path = '../node_modules/react-native-maps'
  pod 'react-native-google-maps', :path => rn_maps_path
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  target 'myAwesomeProjectTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()
  pod 'RNPhotoEditor', :path => '../node_modules/react-native-photo-editor/ios'
use_frameworks! :linkage => :static
pod 'iOSPhotoEditor', :git => 'https://github.com/prscX/photo-editor', :branch => 'master'

post_install do |installer|
installer.pods_project.targets.each do |target|
  flipper_post_install(installer) # as stated here https://fbflipper.com/docs/getting-started/react-native-ios/#react-native-063
  if target.name.include?('iOSPhotoEditor')
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '5'
    end
  end
  if target.name == 'react-native-google-maps'
    target.build_configurations.each do |config|
      config.build_settings['CLANG_ENABLE_MODULES'] = 'No' # as mentioned here https://github.com/react-native-maps/react-native-maps/issues/3597#issuecomment-745026120
    end
  end
  if (target.name&.eql?('FBReactNativeSpec')) #as mentioned here https://github.com/software-mansion/react-native-screens/issues/842#issuecomment-812543933
    target.build_phases.each do |build_phase|
      if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
        target.build_phases.move(build_phase, 0)
      end
    end
  end
end
end 

$static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly',
'CocoaAsyncSocket', 'ComponentKit', 'Flipper-DoubleConversion',
'Flipper-Glog', 'Flipper-PeerTalk', 'Flipper-RSocket', 'Yoga', 'YogaKit',
'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native']


pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
installer.pod_targets.each do |pod|
    if $static_framework.include?(pod.name)
      def pod.build_type;
        Pod::BuildType.static_library
      end
    end
  end
end



  # post_install do |installer|
  #   react_native_post_install(installer)
  # end
end

更新2:

如果你的问题没有被上面的答案解决。请一步一步地遵循我的GitHub回购上的说明。

更新3:

错误:“Google iOs-Utils/GMUKMLParser.h”文件未找到

解决方案:

反应-本机-地图官方指南他说遵循本说明在google-maps-ios-utils/Swift.md上。然而,这些指示含糊不清。这里是一个更清晰的指令集:

  1. 我们已经克隆并添加了google-maps ios-utils之上的.If你还没有,请按照这些说明回避。
  2. 创建Swift桥接标头
代码语言:javascript
运行
复制
1. File > New > File > Header File
2. Usually the name would be [Project Name]-Bridging-Header.h but you name it whatever you want. I am naming it just `Header.h` in this project as it is really a simple project.

代码语言:javascript
运行
复制
1. Goto target->Build Settings->search for `Swift Compiler - General` 
    1. In `Objective-C Bridging Header` put `Header.h`.

  1. 将以下行放在头文件上: #import "GMUKMLParser.h“#import”GMUKMLParser.h“#import”GMUGetimeyRenderer.h“
  2. Google-Maps-iOS-Utils/Clustering/GMUMarkerClustering.h中放置以下行 #导入"GMUDefaultClusterIconGenerator.h“#import”GMUDefaultClusterIconGenerator.h“#导入"GMUDefaultClusterRenderer.h”#导入"GMUGridBasedClusterAlgorithm.h“#import”GMUNonHierarchicalDialBasedDietBasedAlgorithm.h“#import "GMUStaticCluster.h”#import“GMUTPointQuadTree.h”
  3. (This is a repetitive task. you need to do this step every time "yarn install" executes)更改为将语句导入到AirGoogleMaps/AIRGoogleMapHeatmap.h文件中的#import "GMUHeatmapTileLayer.h"
  1. (This is a repetitive task. you need to do this step every time "yarn install" executes)AirGoogleMaps/AIRGoogleMap.m中放置了以下一行 #导入"GMUKMLParser.h“#import "GMUPlacemark.h”#import "GMUPoint.h“#import”GMUGetimeyRenderer.h“

更新4:

在评论中,弗洛林提到了一个错误

无法找到生成输入文件:'/ios/master/src/GeometryUtils/Internal/CatesianPoint.swift'...‘

这是因为我不知道如何在git中使用子模块。因此,当克隆谷歌地图-ios-utils时,该回购不会被推到我的GitHub回购(在这个答案的第一行中提到)。这个问题已经解决了。我刚刚添加了‘src文件夹内容,而没有克隆整个回购在我的回购和推动的变化。

票数 1
EN

Stack Overflow用户

发布于 2022-12-02 11:29:35

为了避免use_framwork,我不得不添加谷歌地图和防火墙,这两者都是必要的。这就是我在这件事上浪费了两天的时间。

解决办法是使用像这样的火药库

代码语言:javascript
运行
复制
  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true  
  pod 'FirebaseStorageInternal', :modular_headers => true
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseAppCheckInterop', :modular_headers => true
  pod 'FirebaseAuthInterop', :modular_headers => true
  pod 'FirebaseMessagingInterop', :modular_headers => true
  pod 'GTMSessionFetcher', :modular_headers => true
  pod 'FirebaseAppCheckInterop', :modular_headers => true
  pod 'FirebaseAuthInterop', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true

正如在这个链接上所解释的。也给那个人竖起大拇指。

https://dev.to/matthewzruiz/firebase-the-following-swift-pods-cannot-yet-be-integrated-as-static-libraries-b59

我的豆荚文件:

代码语言:javascript
运行
复制
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '13.0'
install! 'cocoapods', :deterministic_uuids => false

target 'ReactNativeBoilerPlate' do

  rn_maps_path = '../node_modules/react-native-maps'
  pod 'react-native-google-maps', :path => rn_maps_path

  config = use_native_modules!
# React Native Maps dependencies
  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true

  pod 'react-native-splash-screen', :path => '../node_modules/react-native-splash-screen'

  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

  pod 'RNPermissions', :path => '../node_modules/react-native-permissions'

  target 'ReactNativeBoilerPlateTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  # use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64"
      end
    end
  end
 
end
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66966465

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档