فهرست منبع

修复iOS 16.4新建RN0.64无法运行

vbea 3 سال پیش
والد
کامیت
a17dd2055b
2فایلهای تغییر یافته به همراه92 افزوده شده و 19 حذف شده
  1. 8 1
      Strides-APP/README.md
  2. 84 18
      Strides-APP/ios/Podfile

+ 8 - 1
Strides-APP/README.md

@@ -149,4 +149,11 @@ https://stackoverflow.com/questions/36685372/how-to-zoom-in-out-in-react-native-
 https://stackoverflow.com/questions/57227291/victory-native-events-props-not-working-in-react-native-event-not-firing-in/57723808  
 https://www.jianshu.com/p/0a51624dee2f  
 https://www.jianshu.com/p/8f75eb58b030  
-https://www.cnblogs.com/sundaysgarden/p/10357051.html
+https://www.cnblogs.com/sundaysgarden/p/10357051.html
+
+## 踩坑记
+[疑难杂症之module map file not found](https://blog.csdn.net/weixin_43883776/article/details/106793263)  
+
+## iOS16专题
+https://github.com/facebook/react-native/issues/32496
+https://stackoverflow.com/questions/71597475/symbols-not-found-for-architecture-arm64-xcode

+ 84 - 18
Strides-APP/ios/Podfile

@@ -61,32 +61,98 @@ target 'JuicePlus' do
   #  react_native_post_install(installer)
   #end
 
-  #⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄修复iOS 14.5新建RN0.64无法运行⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄
-  def find_and_replace(dir, findstr, replacestr)
-    Dir[dir].each do |name|
-      text = File.read(name)
-      replace = text.gsub(findstr,replacestr)
-      if text != replace
-        puts "Fix: " + name
-        File.open(name, "w") { |file| file.puts replace }
-        STDOUT.flush
+  #--------------------修复iOS 16.4新建RN0.64无法运行--------------------------
+  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
-    Dir[dir + '*/'].each(&method(:find_and_replace))
   end
 
-  post_install do |installer|
-    flipper_post_install(installer)
-    find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
-    "atomic_notify_one(state)", "folly::atomic_notify_one(state)")
+  projects = installer.aggregate_targets
+    .map{ |t| t.user_project }
+    .uniq{ |p| p.path }
+    .push(installer.pods_project)
 
-    find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
-    "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
-    installer.pods_project.targets.each do |target|
+  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|
-        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0' #将所有插件更新为iOS12可用
+        fix_config(config)
       end
     end
+    project.save()
   end
+end
+# 在Xcode中选择您的项目,然后转到“Build Settings”,向下滚动,直到您看到“Search Paths”,最后看到“Library Search Paths”。
+# 将"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"替换为"$(SDKROOT)/usr/lib/swift"
+
+  # 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|
+  #   installer.pods_project.targets.each do |target|
+  #     target.build_configurations.each do |config|
+  #       config.build_settings['ENABLE_BITCODE'] = 'NO'
+  #       config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
+  #     end
+  #   end
+  #   react_native_post_install(installer)
+  # end
+  #--------------------修复iOS 16.4新建RN0.64无法运行--------------------------
+
+  #⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄修复iOS 14.5新建RN0.64无法运行⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄
+  # def find_and_replace(dir, findstr, replacestr)
+  #   Dir[dir].each do |name|
+  #     text = File.read(name)
+  #     replace = text.gsub(findstr,replacestr)
+  #     if text != replace
+  #       puts "Fix: " + name
+  #       File.open(name, "w") { |file| file.puts replace }
+  #       STDOUT.flush
+  #     end
+  #   end
+  #   Dir[dir + '*/'].each(&method(:find_and_replace))
+  # end
+
+  # post_install do |installer|
+  #   flipper_post_install(installer)
+  #   find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
+  #   "atomic_notify_one(state)", "folly::atomic_notify_one(state)")
+
+  #   find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
+  #   "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
+  #   installer.pods_project.targets.each do |target|
+  #     target.build_configurations.each do |config|
+  #       config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0' #将所有插件更新为iOS12可用
+  #     end
+  #   end
+  # end
   #⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃修复iOS 14.5新建RN0.64无法运行⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃
 end