Zaphod
Zaphod

Reputation: 1417

Cocoapods not linking correctly for 3rd, 4th target (Xcode 7 beta 6)

I'm having a problem with Cocoapods and Xcode 7 beta 6: I have a project with three different test targets (tests, UITests, IntegrationTests). My pods seem to be working just fine with the first target ("tests") but the other targets are having problems:

Screenshot is attached that shows the linker error. Again this only happens if I try to use the XCGLogger in the latter two targets. It works fine in the first target.

Linker error on some targets

Just to be thorough... here's the Podfile I'm using:

platform :ios, "8.0"
use_frameworks!

target 'Glimpulse' do
  pod "SwiftSpinner", :git => 'https://github.com/zbeckman/SwiftSpinner.git'
  pod 'XCGLogger', :git => 'https://github.com/DaveWoodCom/XCGLogger.git', :branch => 'swift_2.0'
  pod 'GRValidation', '~> 0.2'
end

target 'GlimpulseTests' do
  pod "SwiftSpinner", :git => 'https://github.com/zbeckman/SwiftSpinner.git'
  pod 'XCGLogger', :git => 'https://github.com/DaveWoodCom/XCGLogger.git', :branch => 'swift_2.0'
  pod "Nimble", :git => 'https://github.com/Quick/Nimble.git', :branch => 'swift-2.0'
  pod "Quick", :git => 'https://github.com/zbeckman/Quick.git', :branch => 'swift-2.0'
  pod 'GRValidation', '~> 0.2'
#  pod "SwiftCheck", :git => 'https://github.com/zbeckman/SwiftCheck.git', :branch => 'swift-develop'
end

target 'GlimpulseUITests' do
  pod "SwiftSpinner", :git => 'https://github.com/zbeckman/SwiftSpinner.git'
  pod 'XCGLogger', :git => 'https://github.com/DaveWoodCom/XCGLogger.git', :branch => 'swift_2.0'
  pod "Nimble", :git => 'https://github.com/Quick/Nimble.git', :branch => 'swift-2.0'
  pod "Quick", :git => 'https://github.com/zbeckman/Quick.git', :branch => 'swift-2.0'
  pod 'GRValidation', '~> 0.2'
#  pod "SwiftCheck", :git => 'https://github.com/zbeckman/SwiftCheck.git', :branch => 'swift-develop'
end

target 'GlimpulseIntegrationTests' do
  pod "SwiftSpinner", :git => 'https://github.com/zbeckman/SwiftSpinner.git'
  pod 'XCGLogger', :git => 'https://github.com/DaveWoodCom/XCGLogger.git', :branch => 'swift_2.0'
  pod "Nimble", :git => 'https://github.com/Quick/Nimble.git', :branch => 'swift-2.0'
  pod "Quick", :git => 'https://github.com/zbeckman/Quick.git', :branch => 'swift-2.0'
  pod 'GRValidation', '~> 0.2'
#  pod "SwiftCheck", :git => 'https://github.com/zbeckman/SwiftCheck.git', :branch => 'swift-develop'
end

link_with 'GlimpulseUITests'
link_with 'GlimpulseIntegrationTests'

Upvotes: 2

Views: 1126

Answers (3)

Kaps
Kaps

Reputation: 1

Cocoapods 0.38.2 has problem with xcode 7 as said above. i have faced this problem and fixed it by downgrading the the cocoapods version to 0.35.0. use gem uninstall cocoapods in terminal to uninstall.

Upvotes: 0

Zaphod
Zaphod

Reputation: 1417

Aha. Ok, I think I figured it out, after much pain and suffering with deleting, recreating, pod installing, and repeating... and fiddling with Xcode targets. My findings:

Cocoapods 0.38.2 does not like Xcode 7 beta 6's new "iOS UI Testing Bundle" target type.

The main problem is evident when setting up the new target and running pod install. The install appears to run fine but if you look at the build phases, the Embed pods frameworks phase is missing. However, if I manually create this phase (adjusting the paths as appropriate for the target), it does build.

BUT... Something weird still happens. The errors shown above (regarding linking for the current architecture) still occur. And here's the strangest part: If I change the target to use 'Build for active architecture only: NO' then everything works just fine. I don't get this last bit, because the pods should only be built for the current architecture. However... if the integration is whacked then... OK, who knows, maybe it gets fixed in the next Cocoapods release.

One other disappointing discovery: The new UI Test target type does not appear to support the @testable feature. Bummer. Hope they add that into the final release of Xcode 7...

Upvotes: 2

Duck
Duck

Reputation: 36003

Just use this format for your Podfile:

source 'https://github.com/CocoaPods/Specs.git'

target 'firstTarget', :exclusive => false do
platform :ios, '7.0'
pod 'SwiftSpinner', '~> 0.7'
pod 'XCGLogger', '~> 2.3'
pod 'Nimble', '2.0.0-rc.3'
pod 'Quick', '~> 0.6'
pod 'GRValidation', '~> 0.2'
end

... repeat for every target

Find the pod syntaxes at cocoapods.org.

Upvotes: 0

Related Questions