天天看點

iOS 多target配置,pod配置

target配置

1.直接複制原有的​

​target​

​​ 選擇​

​Duplicate Only​

​,然後改名

2.修改新​

​target​

​​對應的​

​Scheme​

​​

​Edit Scheme​

​​ -> 選擇 ​

​XXX Copy​

​​ -> 底部​

​Manage Scheme​

​​ -> 選中(底部的) ​

​XXX Copy​

​​,再點選一下,即可修改,建議與 ​

​Target​

​ 同名

3.修改新​

​target​

​​對應的​

​info.plist​

​​ 先在左側檔案目錄删除(移除引用) ​

​XXX copy-info.plist​

​​,再在工程根目錄建立一個與 ​

​Target​

​​ 同名的檔案夾,把 ​

​XXX.plist​

​​ (修改個新名字)放入其中,再從(新的​

​target​

​​)​

​Build Setting​

​​ -> ​

​info.plist File​

​​ 設定路徑:​

​新檔案名/新名字.plist​

​ 即可導入

4.修改​

​budleID​

5.定義新​

​target​

​​的宏

​​

​Build Setting​

​​ -> 輸入 ​

​macros​

​​ -> 定義​

​Debug​

​​,​

​Release​

​兩個環境的宏

pod 配置

  • 方式一
# 使用關鍵字abstract_target,使用多個target共享同一個pod,這裡是common_pod
abstract_target 'common_pod' do
    pod 'AFNetworking'
    
    # targetA 單獨擁有
    target 'targetA' do
        pod 'Masonry'
    end
    
    # targetB 單獨擁有    
    target 'targetB' do
        pod 'SDWebImage'
    end
end      
  • 方式二
# 共同的pod
def commonPods
    pod 'Masonry', '~> 1.1.0'
end

# targetA
target 'targetA' do
    commonPods
    pod 'AFNetworking', '~> 3.2.1'
end

# targetB
target 'targetB' do
    commonPods
    pod 'YYModel'
end      

繼續閱讀