0

我仅在 target3 中使用 react-native 作为属于 target1 的框架, target1 有一个 target2 副本。然后,如何将 target3 共享给 target1 和 target2。自爆的 Podfile 是错误的The target 'target3' is declared twice for the project 'Target3/Target3.xcodeproj'.

target 'target1' do
  use_frameworks!

  target 'target3' do
    use_frameworks!

    react_native_path = 'node_modules/react-native/'
    pod 'React', :path => react_native_path, :subspecs => [
    'Core',
    'BatchedBridge',
    ]
  end
end

target 'target2' do
  use_frameworks!

  target 'target3' do
    use_frameworks!

    react_native_path = 'node_modules/react-native/'
    pod 'React', :path => react_native_path, :subspecs => [
    'Core',
    'BatchedBridge',
    ]
  end
end
4

1 回答 1

0

惊人的!当我搜索另一个 Cocoapods 问题时,我无意中得到了灵感。

// with your own workspace
workspace 'myApp.xcworkspace' 

// declare the project path you will add blew
project 'Project1.xcodeproj'
project 'Project2.xcodeproj'

// abstract_target with any target name as you like
abstract_target 'target' do 

  target 'Project1' do
    use_frameworks!
    project 'LessChat-iOS.xcodeproj'
    pod 'Alamofire'
 end

 target 'Project2' do
   use_frameworks!
   project 'Project2.xcodeproj'
   pod 'SwiftyJSON'
  end
end

以上,希望对你有帮助= =

更多细节或类似情况见https ://stackoverflow.com/a/43739900/5557953

谢谢@Johannes Fahrenkrug

于 2017-08-17T07:40:41.440 回答