I just started tinkering with cocoapods to manage dependencies of my iOS Projects. Currently I am trying to integrate unit tests using GHIOSUnit. I followed all their instructions and tried their sample tests and it all worked like charm.
However, problems start when I start using my actual project files for testing.
I am using AFNetworking for client server comms and whenever I access my sharedClient called 'CRLClient', a wrapper for AFHTTPClient, it gives me undefined symbols errors.
Undefined symbols for architecture armv7:
"_OBJC_METACLASS_$_AFHTTPClient", referenced from:
_OBJC_METACLASS_$_CRLClient in CRLClient.o
"_OBJC_CLASS_$_AFJSONRequestOperation", referenced from:
objc-class-ref in CRLClient.o
"_OBJC_CLASS_$_AFHTTPClient", referenced from:
_OBJC_CLASS_$_CRLClient in CRLClient.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The pod file for managing dependencies looks like this
workspace 'Storyboards.xcworkspace'
platform :ios, '5.0'
pod 'AFNetworking', '1.1.0'
target :UnitTests, :exclusive => true do
pod 'GHUnitIOS', '0.5.6'
end
The actual project target builds fine and works with AFNetworking perfectly.
P.S. I am required to add all the files to be tested to be added to the UnitTest Target as well. Then what does adding 'Target Dependency' in build phases do?
In short,
By using
target :UnitTests, :exclusive => true do
pod 'GHUnitIOS', '0.5.6'
end
You're saying that the only library you want to be linked to the UnitTests
target is GHUnit
mainly saying you don't want AFNetworking
to be linked as well. The problem is it looks like you're also importing your AFHTTPClient
subclass into UnitTests
where it can't find the AFNetworking components it's trying to link to.
To fix this you should be able to remove the exclusive call
target :UnitTests do
pod 'GHUnitIOS', '0.5.6'
end
With this you will link GHUnit
only to your UnitTests
target but will link AFNetworking
to both. "The target will by default include the dependencies defined outside of the block, unless the :exclusive => true option is given." (from here)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With