简体   繁体   English

React Native:依赖项和归档我的项目的问题

[英]React Native: Problem with dependencies and archiving my project

I have returned to a project which I haven't worked on in a little while.我已经回到了一个我有一段时间没有工作的项目。 I added a delete account feature and planned to release it to the apple store that day.我添加了删除帐户功能,并计划在当天将其发布到苹果商店。

I ran npm install --legacy-peer-deps && cd ios && pod install .我跑了npm install --legacy-peer-deps && cd ios && pod install This all worked fine (my packages are a little out of date since I haven't worked in this project for a while so I had to user legacy-peer-deps instead).这一切都很好(我的包有点过时了,因为我有一段时间没有在这个项目中工作了,所以我不得不使用 legacy-peer-deps 代替)。

Next step, I went to XCode and tried to archive my project as usual but got a build failed with the error being Undefined symbol: _swift_stdlib_isStackAllocationSafe - after some research下一步,我去了 XCode 并尝试像往常一样存档我的项目,但构建失败,错误为Undefined symbol: _swift_stdlib_isStackAllocationSafe - 经过一些研究

I found a solution on this post: Symbol(s) not found for architecture arm64 - XCode我在这篇文章中找到了一个解决方案: Symbol(s) not found for architecture arm64 - XCode

There was a really helpful approved answer.有一个非常有用的批准答案。 I added the suggested code to my podfile and tried to run npm install react-native-purchases@latest as suggested.我将建议的代码添加到我的 podfile 中,并尝试按照建议运行npm install react-native-purchases@latest BUT, I am presented with the following error:但是,我收到以下错误:

React Native 购买错误码

At this point I'm thinking hmmm conflicting dependency let me try to install with npm install react-native-firebase/app and then this shows me the next error.在这一点上,我在想嗯冲突依赖让我尝试使用npm install react-native-firebase/app ,然后这向我显示下一个错误。

在此处输入图像描述

I try to install babel-plugin-root-import and then it shows me the first image error again and repeats.我尝试安装 babel-plugin-root-import,然后它再次向我显示第一个图像错误并重复。 I'm a bit stuck, I just want to get this project back up and running but its a pain!我有点卡住了,我只想让这个项目重新启动并运行,但它很痛苦!

Here's my package.json for reference:这是我的 package.json 供参考:

{
  "scripts": {
    "start": "react-native start",
    "android": "npx react-native run-android",
    "ios": "npx react-native run-ios --simulator='iPhone 13'",
    "start:development": "NODE_ENV=development npx react-native start",
    "start:production": "NODE_ENV=production npx react-native start"
  },
  "dependencies": {
    "@fawazahmed/react-native-read-more": "^2.2.2",
    "@invertase/react-native-apple-authentication": "^2.1.0",
    "@react-native-community/async-storage": "^1.12.1",
    "@react-native-community/blur": "^3.6.0",
    "@react-native-community/google-signin": "^5.0.0",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/slider": "^3.0.3",
    "@react-native-firebase/app": "^13.0.1",
    "@react-native-firebase/auth": "^14.2.1",
    "@react-native-firebase/firestore": "^10.5.1",
    "@react-native-firebase/storage": "^13.0.1",
    "@react-navigation/bottom-tabs": "^5.11.7",
    "@react-navigation/native": "^5.9.2",
    "@react-navigation/stack": "^5.14.2",
    "expo": "~40.0.0",
    "expo-app-loading": "^1.0.1",
    "expo-apple-authentication": "~2.2.2",
    "expo-google-app-auth": "^8.1.4",
    "expo-google-sign-in": "~8.4.0",
    "expo-linear-gradient": "~8.4.0",
    "expo-notifications": "~0.8.2",
    "expo-splash-screen": "~0.8.0",
    "expo-status-bar": "~1.0.3",
    "expo-updates": "~0.4.0",
    "firebase": "^8.2.5",
    "lottie-react-native": "^4.0.2",
    "react": "16.13.1",
    "react-apple-signin-auth": "^0.0.7",
    "react-dom": "16.13.1",
    "react-native": "~0.63.4",
    "react-native-calendars": "^1.1254.0",
    "react-native-countdown-circle-timer": "^2.5.0",
    "react-native-device-info": "^8.0.7",
    "react-native-dotenv": "^3.3.1",
    "react-native-fast-image": "^8.5.11",
    "react-native-gesture-handler": "^1.9.0",
    "react-native-google-signin": "^2.1.1",
    "react-native-haptic-feedback": "^1.11.0",
    "react-native-input-scroll-view": "^1.11.0",
    "react-native-keep-awake": "^4.0.0",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-parallax-header": "^1.1.4",
    "react-native-purchases": "^4.1.1",
    "react-native-reanimated": "^1.13.2",
    "react-native-responsive-screen": "^1.4.2",
    "react-native-safe-area-context": "^3.1.9",
    "react-native-screens": "^2.17.1",
    "react-native-sound": "^0.11.1",
    "react-native-svg": "12.1.0",
    "react-native-unimodules": "~0.12.0",
    "react-native-web": "~0.13.12",
    "react-navigation": "^4.4.3",
    "use-sound": "^2.0.1"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0",
    "babel-jest": "~25.2.6",
    "babel-plugin-root-import": "^6.6.0",
    "eslint-import-resolver-babel-plugin-root-import": "^1.1.1",
    "jest": "~25.2.6",
    "metro-react-native-babel-preset": "^0.66.2",
    "prettier": "2.6.2",
    "react-test-renderer": "~16.13.1"
  },
  "private": true,
  "name": "Flexeee-RN",
  "version": "1.0.0"
}

PODFILE:播客文件:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

$FirebaseSDKVersion = '8.9.0'

platform :ios, '11.0'

target 'FlexeeeRN' do
  use_unimodules!
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])

  # Uncomment the code below to enable Flipper.
  #
  # You should not install Flipper in CI environments when creating release
  # builds, this will lead to significantly slower build times.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work.
  #
  #  use_flipper!
  #  post_install do |installer|
  #    flipper_post_install(installer)
  #  end
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
   target.build_configurations.each do |config|
    config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
   end
  end
 end

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

def fix_library_search_paths(installer)
  def fix_config(config)
    lib_search_paths = config.build_settings["LIBRARY_SEARCH_PATHS"]
    if lib_search_paths
      if lib_search_paths.include?("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)") || lib_search_paths.include?("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
        # $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) causes problem with Xcode 12.5 + arm64 (Apple M1)
        # since the libraries there are only built for x86_64 and i386.
        lib_search_paths.delete("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)")
        lib_search_paths.delete("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
        if !(lib_search_paths.include?("$(SDKROOT)/usr/lib/swift") || lib_search_paths.include?("\"$(SDKROOT)/usr/lib/swift\""))
          # however, $(SDKROOT)/usr/lib/swift is required, at least if user is not running CocoaPods 1.11
          lib_search_paths.insert(0, "$(SDKROOT)/usr/lib/swift")
        end
      end
    end
  end

  projects = installer.aggregate_targets
    .map{ |t| t.user_project }
    .uniq{ |p| p.path }
    .push(installer.pods_project)

  projects.each do |project|
    project.build_configurations.each do |config|
      fix_config(config)
    end
    project.native_targets.each do |target|
      target.build_configurations.each do |config|
        fix_config(config)
      end
    end
    project.save()
  end
end

Any help is appreciated.任何帮助表示赞赏。 Thanks for your time.谢谢你的时间。

UPDATE: I did npm install react-native-purchases@latest --legacy-peer-deps as suggested below (seems to have worked).更新:我按照下面的建议做了npm install react-native-purchases@latest --legacy-peer-deps (似乎有效)。 But now, when I run pod install it doesn't like the code I added into the Podfile and says:但是现在,当我运行 pod install 时,它不喜欢我添加到 Podfile 中的代码并说:

[!] Invalid Podfile file: syntax error, unexpected end, expecting end-of-input. [!] Podfile文件无效:语法错误,意外结束,预期输入结束。

 #  from /Users/jacksaunders/Flexeee-V2/ios/Podfile:40
 #  -------------------------------------------
 #    end
 >  end
 #  
 #  -------------------------------------------

I've double checked the code I've added and its the exact same.我已经仔细检查了我添加的代码,它完全相同。 Unsure, what to do from here.不确定,从这里做什么。

Try this podfile试试这个 podfile

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

$FirebaseSDKVersion = '8.9.0'

platform :ios, '11.0'

target 'FlexeeeRN' do
  use_unimodules!
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])

  # Uncomment the code below to enable Flipper.
  #
  # You should not install Flipper in CI environments when creating release
  # builds, this will lead to significantly slower build times.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work.
  #
  #  use_flipper!
  #  post_install do |installer|
  #    flipper_post_install(installer)
  #  end
  post_install do |installer|
    installer.pods_project.targets.each do |target|
     target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
     end
    end
    react_native_post_install(installer)
    fix_library_search_paths(installer)
   end
end

def fix_library_search_paths(installer)
  def fix_config(config)
    lib_search_paths = config.build_settings["LIBRARY_SEARCH_PATHS"]
    if lib_search_paths
      if lib_search_paths.include?("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)") || lib_search_paths.include?("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
        # $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) causes problem with Xcode 12.5 + arm64 (Apple M1)
        # since the libraries there are only built for x86_64 and i386.
        lib_search_paths.delete("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)")
        lib_search_paths.delete("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
        if !(lib_search_paths.include?("$(SDKROOT)/usr/lib/swift") || lib_search_paths.include?("\"$(SDKROOT)/usr/lib/swift\""))
          # however, $(SDKROOT)/usr/lib/swift is required, at least if user is not running CocoaPods 1.11
          lib_search_paths.insert(0, "$(SDKROOT)/usr/lib/swift")
        end
      end
    end
  end

  projects = installer.aggregate_targets
    .map{ |t| t.user_project }
    .uniq{ |p| p.path }
    .push(installer.pods_project)

  projects.each do |project|
    project.build_configurations.each do |config|
      fix_config(config)
    end
    project.native_targets.each do |target|
      target.build_configurations.each do |config|
        fix_config(config)
      end
    end
    project.save()
  end
end

I think there should be only one post_install block in podfile, so I merged the two blocks.我认为 podfile 中应该只有一个 post_install 块,所以我合并了两个块。 If this does not work right away, check if your do s match the end s.如果这不能立即起作用,请检查您的do是否与end匹配。 There was one extra end in your original file.您的原始文件中有一个额外的结尾。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM