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

喜欢而已 提交于 2019-12-24 05:11:32

问题


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:

  • Everything builds just fine if I don't reference any of the Cocoapods in the latter two targets.
  • However, when I try to use one of the pods (XCGLogger in this case), I get linker errors.
  • I checked the build phases, and found that Embed Pods Frameworks was missing from both targets, so I manually added it.
  • After doing this and cleaning, deleting derived data, the problem still exists.

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.

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'

回答1:


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...




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/32368665/cocoapods-not-linking-correctly-for-3rd-4th-target-xcode-7-beta-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!