4ntoine
4ntoine

Reputation: 20432

Cocoapod: ios app and osx test dependencies

I'm having iOS app and i'd like to test some code (interaction with the server which is not iOS-related) in osx test. I'm having 'App' project and 'App' ios target and 'AppTests' macosx targets.

My Podfile:

platform :ios, '8.0'

# ios app
target 'App' do

    ... (some ios dependencies)

    pod 'PocketSocket'
    pod 'ProtocolBuffers'

end

# osx tests
target 'AppTests' do

    pod 'PocketSocket'
    pod 'ProtocolBuffers'

end

Is it correct? I can build app for iOS, but i'm getting error for test. ProtocolBuffers and PocketSocket are targeted to ios not for osx:

"_OBJC_CLASS_$_ObjectivecDescriptorRoot", referenced from:
..
ld: symbol(s) not found for architecture x86_64

I can see in 'Pods' in Targets ProtocolBuffers target Base SDK is Latest iOS and same for PocketSocket target. Pods-AppTests target has dependency on PocketSocket and ProtocolBuffers targets so it tries to use object files that were compiled for ios for osx tests.

Update 1:

I've added platform for tests target and cocoapod create separate targets for osx and osx as expected:

# tests
target 'ArduinoCodeTests' do
    platform :osx, '10.10'

    pod 'PocketSocket'
    pod 'ProtocolBuffers'

end

However i'm still having linker errors:

>   "_OBJC_CLASS_$_ObjectivecDescriptorRoot", referenced from:

Upvotes: 2

Views: 128

Answers (1)

4ntoine
4ntoine

Reputation: 20432

It seems that it's CocoaPod bug.

It creates target Pods-AppTests which depends on Pods-AppTests-ProtocolBuffers and Pods-AppTests-PocketSocket as target dependencies. Then AppTests target depends on this target: "Link Binary with Libraries" has libPods-AppTests.a.

I had to add libPods-AppTests-ProtocolBuffers.a and libPods-AppTests-PockeSocket.a manually as their object files path were not added to '-L' when building.

Upvotes: 1

Related Questions