Я создаю библиотеку React Native Cocoapod, которая использует преимущественно swift.
Мне трудно получить правильную комбинацию podspec и podfile, чтобы избежать предупреждений о переопределении во время выполнения
Подфайл моего приложения
install! 'cocoapods', :deterministic_uuids => false
platform :ios, '11.0'
use_modular_headers!
target 'chowchow' do
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'ART',
'CxxBridge', # Include this for RN >= 0.47
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
'RCTText',
'RCTImage',
'RCTNetwork',
'RCTWebSocket', # Needed for debugging
'RCTAnimation', # Needed for FlatList and animations running on native UI thread
'RCTActionSheet',
'RCTLinkingIOS',
]
# Explicitly include Yoga if you are using RN >= 0.42.0
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
# React's third party deps podspec link
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec', :modular_headers => false
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec', :modular_headers => false
# pod 'google-cast-sdk'
# React Community
pod 'react-native-async-storage', :path => '../node_modules/@react-native-community/async-storage', :modular_headers => false
pod 'react-native-netinfo', :path => '../node_modules/@react-native-community/netinfo', :modular_headers => false
# Fabric & Crashlytics
pod 'Firebase/Core', :modular_headers => false
pod 'Fabric', :modular_headers => false
pod 'Crashlytics', :modular_headers => false
# Fast image
pod 'react-native-fast-image', :path => '../node_modules/react-native-fast-image', :modular_headers => false
# Node modules
pod 'ReactNativeNavigation', :path => '../node_modules/react-native-navigation', :modular_headers => false
pod 'TouchID', :path => '../node_modules/react-native-touch-id', :modular_headers => false
pod 'RNKeychain', :path => '../node_modules/react-native-keychain', :modular_headers => false
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons', :modular_headers => false
pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info', :modular_headers => false
pod 'RNMyLibrary', :path => '../node_modules/react-native-my-library'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
# https://github.com/facebook/react-native/issues/20492
# The following is needed to ensure the "archive" step works in XCode.
# It removes React & Yoga from the Pods project, as it is already included in the main project.
# Without this, you'd see errors when you archive like:
# "Multiple commands produce ... libReact.a"
# "Multiple commands produce ... libyoga.a"
targets_to_ignore = %w(React yoga)
if targets_to_ignore.include? target.name
target.remove_from_project
end
end
end
Подспец моей библиотеки
require "json"
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
Pod::Spec.new do |s|
s.name = "RNMyLibrary"
s.version = package["version"]
s.summary = package["description"]
s.description = <<-DESC
RNMyLibrary
DESC
s.homepage = "https://github.com/brenwell/RNMyLibrary"
s.license = "UNLICENSED"
s.author = { "author" => "author@domain.cn" }
s.platform = :ios, "11.0"
s.source = { :git => "https://github.com/brenwell/RNMyLibrary.git", :tag => "#{s.version}" }
s.source_files = "ios/**/*.{h,m,swift}"
s.resource_bundles = {
'TrackModel' => ["ios/RNMyLibrary/Track.xcdatamodeld"]
}
s.requires_arc = true
s.dependency "google-cast-sdk", '4.3.0'
s.dependency "CocoaHTTPServer"
s.dependency "React"
end
Error
Error while loading Swift module:
D-MediaStore: /Users/brenwell/Library/Developer/Xcode/DerivedData/my-library-axsmrqxaoagdyfbmkmhxgjoxfini/Build/Products/Debug-iphonesimulator/RNMyLibrary/Swift Compatibility Header/RNMyLibrary-Swift.h:172:9: note: while building module 'React' imported from /Users/brenwell/Library/Developer/Xcode/DerivedData/my-library-axsmrqxaoagdyfbmkmhxgjoxfini/Build/Products/Debug-iphonesimulator/RNMyLibrary/Swift Compatibility Header/RNMyLibrary-Swift.h:172:
@import React;
^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "React-umbrella.h"
^
/Users/brenwell/Dev/native/my-library/ios/Pods/Headers/Public/React/React-umbrella.h:36:9: note: in file included from /Users/brenwell/Dev/native/my-library/ios/Pods/Headers/Public/React/React-umbrella.h:36:
#import "React/RCTBridge.h"
^
error: /Users/brenwell/Dev/native/my-library/ios/Pods/Headers/Public/React/React/RCTBridge.h:106:1: error: duplicate interface definition for class 'RCTBridge'
@interface RCTBridge : NSObject <RCTInvalidating>
^
/Users/brenwell/Library/Developer/Xcode/DerivedData/my-library-axsmrqxaoagdyfbmkmhxgjoxfini/Build/Products/Debug-iphonesimulator/include/React/RCTBridge.h:106:12: note: previous definition is here
@interface RCTBridge : NSObject <RCTInvalidating>
^
И это повторяется для каждого React Import. У кого-нибудь есть идеи