CocoaPods: an effective solution for installing the same pod in multiple targets, cocoapodspod

Source: Internet
Author: User

CocoaPods: an effective solution for installing the same pod in multiple targets, cocoapodspod

One of the exciting features of Xcode7 is the ability to perform native UI testing (thanks to Apple), so when I develop a new Xcode 7/Swift 2 project, I put the focus on this. In the unit test process, Quick and Nimble are really comfortable to use, so I also want to use these class libraries in the UI test.

Using CocoaPods to install Quick and Nimble is simple, but the problem is that you just want to install Quick and Nimble to the test target.

A bad habit but effective solution

The initial method is to place Quick and Nimble in the two targets of Podfile respectively:

# Podfileplatform :ios, '9.0'use_frameworks!# My other podstarget 'MyTests' do    pod 'Quick', '0.5.0'    pod 'Nimble', '2.0.0-rc.1'endtarget 'MyUITests' do    pod 'Quick', '0.5.0'    pod 'Nimble', '2.0.0-rc.1'end

I don't like Quick and Nimble. I will repeat them twice here. Every time I update the version, I have to modify it in two places.

Incorrect Solution

Later, I Googled and found that I needed to use link_with. I think all the databases below link_with will be applied to the target I specified:

# Podfileplatform :ios, '9.0'use_frameworks!# My other podslink_with 'MyTests', 'MyUITests'pod 'Quick', '0.5.0'pod 'Nimble', '2.0.0-rc.1'

As a result, I fully understand link_with and how it works. In addition to test targets, Quick and Nimble are also installed in the main target of my app.

Elegant solution

Solution:

# Podfileplatform :ios, '9.0'use_frameworks!# My other podsdef testing_pods    pod 'Quick', '0.5.0'    pod 'Nimble', '2.0.0-rc.1'endtarget 'MyTests' do    testing_podsendtarget 'MyUITests' do    testing_podsend

I forgot that Podfile is actually a ruby file! Thanks @ NeoNacho for saving me one day!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.