2017-07-11 31 views
0

我只在target3中使用react-native,作爲框架屬於target1,target1有target2副本。那麼,如何將target3分享給target1 & target2。自爆Podfile是錯誤與The target 'target3' is declared twice for the project 'Target3/Target3.xcodeproj'.Cocoapods如何將相同的目標共享到其他多個目標

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 

回答

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 

以上所有,希望它可以幫助你= =

更詳細或similiar情況看https://stackoverflow.com/a/43739900/5557953

感謝@Johannes Fahrenkrug

相關問題