swift集成rn

image.png
直接删除.cpp文件即可
image.png

如果报错<react/bridging/Bridging.h>
则查看此库中,header和编译文件与以上newProject的不同之处,改为相同即可


image.png
image.png

以下都是废话,如果报错

:flipper_configuration这句替换一下,改成disable
:flipper_configuration => FlipperConfiguration.disabled
·····官网的每一个字都是重点

如果出现错误'react/bridging/Bridging.h' file not found
如下图的build删掉
还是报错,麻蛋

重新从git拉项目,再pod就好了,我擦

现在又出错,麻蛋
image.png

podfile文件

# Uncomment the next line to define a global platform for your project
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, min_ios_version_supported
prepare_react_native_project!

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end

use_frameworks!
inhibit_all_warnings!

#source 'https://github.com/CocoaPods/Specs.git'
#source 'https://cdn.cocoapods.org/'


post_install do |installer|
    react_native_post_install(
          installer,
          # Set `mac_catalyst_enabled` to `true` in order to apply patches
          # necessary for Mac Catalyst builds
          :mac_catalyst_enabled => false
        )
        __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['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'  # 最低适配iOS 12.0,
                        config.build_settings['SWIFT_VERSION'] = '5.0'
                        config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
                        config.build_settings['ENABLE_BITCODE'] = 'NO'
                end
  end
end

#公用的第三方
def common_pods

pod 'Reusable', '~> 4.1.1'                  # 表格cell复用
pod 'RxCocoa', '~> 5.1.1'                   # 响应式框架
pod 'Moya/RxSwift', '~> 14.0.0-beta.2'      # https://github.com/Moya/Moya # 网络抽象层
pod 'Moya-ObjectMapper/RxSwift', :git => 'https://github.com/khoren93/Moya-ObjectMapper.git', :branch => 'moya14'  # https://github.com/ivanbruel/Moya-ObjectMapper   # JSON 序列化
pod 'Kingfisher', '~> 7.2.0'                # 图片异步加载和缓存
pod 'IQKeyboardManagerSwift', '~> 6.5.9'    # 键盘处理
pod 'EmptyDataSet-Swift', '~> 5.0.0'        # 空数据占位
pod 'MJRefresh', '~> 3.5.0'                 # 上下拉刷新
pod 'MBProgressHUD', '~> 1.2.0'             # 弹出指示器
pod 'SnapKit', '~> 5.0.0'                   # autoLayout 布局
pod 'Localize-Swift', '~> 3.2.0'            # app 语言本地化 https://github.com/marmelroy/Localize-Swift

# 常用扩展工具(5.2.0)
pod 'SwifterSwift/SwiftStdlib'
pod 'SwifterSwift/Foundation'
pod 'SwifterSwift/UIKit'
pod 'SwifterSwift/CoreGraphics'
pod 'SwifterSwift/Dispatch'

pod 'Toast-Swift'

pod 'Cache', '5.2.0'  #缓存

pod 'KakaJSON'        #解析框架

# 本地依赖
#pod 'BRPickerView', :git => '/Users/qwqer/Movies/pod/brpicker-view' # 弹出选择框

end

workspace 'Move'

#用户端
target 'Customer' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  common_pods
  
  config = use_native_modules!
  
  use_react_native!(
     :path => config[:reactNativePath],
     # Hermes is now enabled by default. Disable by setting this flag to false.
     # Upcoming versions of React Native may rely on get_default_flags(), but
     # we make it explicit here to aid in the React Native upgrade process.
     :hermes_enabled => false,
     :fabric_enabled => false,
     # Enables Flipper.
     #
     # Note that if you have  enabled, Flipper will not work and
     # you should disable the next line.
     :flipper_configuration => FlipperConfiguration.disabled,
     # An absolute path to your application root.
     :app_path => "#{Pod::Config.instance.installation_root}/.."
   )
  
  project 'Application/Move.project'
  
  pod 'R.swift', '~> 6.1.0'                   # 资源管理(图片, font, color, VC, string)
    
  pod 'KeychainAccess', '~> 4.2.1'            # 钥匙串存储,用来存储token、用户名、密码等安全性比较高的数据
  pod 'DZNEmptyDataSet', '~> 1.8.1'           # 空数据占位视图
  pod "BSImagePicker", '~> 2.10.3'            # 图片选择器
  pod 'FloatingPanel', '~> 1.7.4'             # 可以悬浮的面板,支持各种手势操作
  pod 'CountryPickerView', '~> 3.1.3'         # 国际编码选择器
  pod 'JXPagingView/Paging', '~> 2.0.13'      # 嵌套 ScrollView
  pod 'JXPhotoBrowser', '~> 3.1.2'            # 图片浏览器
  #pod 'TTTAttributedLabel', '~> 2.0.0'        # 带事件的富文本
  pod 'IBAnimatable', '~> 6.1.0'              #xib 圆角,动画

  # Rx Extensions
  #pod 'RxDataSources', '~> 4.0'   # https://github.com/RxSwiftCommunity/RxDataSources
  #pod 'RxSwiftExt', '~> 5.0'      # https://github.com/RxSwiftCommunity/RxSwiftExt
  pod 'NSObject+Rx', '~> 5.0'     # https://github.com/RxSwiftCommunity/NSObject-Rx
  #pod 'RxGesture', '~> 3.0'       # https://github.com/RxSwiftCommunity/RxGesture
  pod 'Starscream', '~> 3.0.6' # websocket
  #pod 'RxCoreLocation' # 地图 rx

  pod 'Bugly', '~> 2.5.71'          # 异常上报

  pod 'LookinServer', :configurations => ['Debug']     # UI视图
  #pod 'MLeaksFinder', :configurations => ['Debug']  # 检查内存泄漏
  #pod 'CocoaDebug', :configurations => ['Debug']
  pod 'zhPopupController'

  pod 'IGListDiffKit' #列表框架
  pod 'IGListKit' #列表框架
  pod 'Swinject', '2.7.0' #依赖注入库
  pod 'SwinjectAutoregistration', '2.7.0'  #依赖注入库
  pod 'QMUIKit' #UI框架
  pod 'LifetimeTracker' #内存泄漏工具
  pod 'SwiftyJSON' #JSON解析
  pod 'JXSegmentedView', :git => 'https://gitee.com/bob_wei/jxsegmented-view.git' # 滑动选项视图
  pod 'TextAttributes'  # attributeString的封装使用
  pod 'YYText'
  pod 'Lantern'
  pod 'SwiftDate' # 时间工具类

  # 远程依赖
  pod 'BRPickerView', :git => 'https://gitee.com/bob_wei/brpicker-view.git' # 弹出选择框

  # 轮播图
  pod 'TYCyclePagerView'
  
  # 支付SDK
  pod 'AlipaySDK-iOS' ,'~> 15.6.8'
  pod 'WechatOpenSDK' , '~> 1.8.6'
  
  # 高德地图(地图、定位、搜索)
  pod 'AMap3DMap-NO-IDFA' ,'~> 9.3.1'
  pod 'AMapSearch-NO-IDFA' ,'~> 9.3.1'
  pod 'AMapLocation-NO-IDFA'
  
  # 穿山甲
  pod 'Ads-CN'
  
  # 滑块验证码
  pod 'CryptoSwift', '~> 1.0'
  pod 'HandyJSON', '~> 5.0.0-beta.1'
  
  # 相册
  #pod 'HXPHPicker'
  
  # 阿里云
  pod 'AliyunOSSiOS'
  
  pod 'Hero'

end

target 'FoundationExtension' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  common_pods
  
  pod 'YYText'
  #pod 'Hero'
  
  project 'FoundationExtension/FoundationExtension.project'

end

target 'Base' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  common_pods
  
  project 'Base/Base.project'

end

target 'GXDCache' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  common_pods
  
  project 'GXDCache/GXDCache.project'

end

target 'BaseUI' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  common_pods

  pod 'KeychainAccess', '~> 4.2.1'            # 钥匙串存储,用来存储token、用户名、密码等安全性比较高的数据

  project 'BaseUI/BaseUI.project'

end

target 'Resource' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  
  pod 'R.swift', '~> 6.1.0'                   # 资源管理(图片, font, color, VC, string)
  
  project 'Resource/Resource.project'

end

target 'Model' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  common_pods
  
  pod 'IGListKit' #列表框架
  
  project 'Model/Model.project'

end

target 'Networking' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  common_pods
  
  pod 'KeychainAccess', '~> 4.2.1'            # 钥匙串存储,用来存储token、用户名、密码等安全性比较高的数据
  
  project 'Networking/Networking.project'

end


文件主要在这里:


image.png
错误:
The 'Pods-Customer' target has transitive dependencies that include statically linked binaries: (Flipper-Boost-iOSX and Flipper-RSocket)
注释掉:
#:flipper_configuration => flipper_config,
但出现:
'react/bridging/Bridging.h' file not found'错误

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容