Cocoapods如何将同一目标分享给其他多个目标

时间:2017-07-11 11:29:44

标签: cocoapods podfile

我只在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

1 个答案:

答案 0 :(得分: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