TealShift
TealShift

Reputation: 962

Using Parse's iOS SDK pod subspecs

I'm trying to use the new(?) CocoaPods subspec for Parse's FacebookUtils framework.

The readme for the pod says:

If you wish to use the Facebook or Twitter utils or ParseUI, you can now leverage Cocoapods 'subspecs'

ruby pod 'Parse/FacebookUtils' pod 'Parse/TwitterUtils' pod 'Parse/UI'

Note that in this case, the Parse framework will contain all headers and classes, so you just have to use:

swift import Parse

objc @import Parse;

And importing the main Parse classes works this way. However, the subspecs FacebookUtils and UI are not recognized by the Xcode compiler!

It simply says "PFFacebookUtils" is an undeclared identifier.

Note: I am using use_frameworks! at the top of the podfile which results in Pods_PROJECT.framework in my "Link Binary With Libraries" list.

I'm kind of lost here and would really appreciate some help.

UPDATE:

I figured out that the issue seems to be my podfile section for an iMessage extension:

target 'MyApp' do
  pod 'Parse/UI'
  pod 'Parse/FacebookUtils'
end

target 'iMessage App' do
    pod 'Parse/Core'
end

Somehow this results in a successful compilation, but a crash on startup with the error:

dyld: Symbol not found: _OBJC_CLASS_$_PFFacebookUtils
Referenced from: .../myapp.app/myapp
Expected in: .../MyApp/Frameworks/Parse.framework/Parse

When adding the FacebookUtils subspec to the iMessage extension, the crash goes away and all is well... except FacebookUtils contains references (UIApplication) that are not allowed in extensions. >:U

Upvotes: 0

Views: 254

Answers (1)

Alexander Vasenin
Alexander Vasenin

Reputation: 12953

The crash is caused by CocoaPods script Pods-YourProject-frameworks.sh installing Parse-Core-FacebookUtils-TwitterUtils/Parse.framework and Parse-Core/Parse.framework to the exact same location, effectively overwriting the former

install_framework "${BUILT_PRODUCTS_DIR}/Parse-Core-FacebookUtils-TwitterUtils/Parse.framework"
install_framework "${BUILT_PRODUCTS_DIR}/Parse-Core/Parse.framework"

I solved it by adding the following run script before CocoaPods run script

/usr/bin/sed -i '' '/Parse-Core\/Parse.framework/d' "${PODS_ROOT}/Target Support Files/Pods-YourProjectName/Pods-YourProjectName-frameworks.sh"

This removes the offending lines from CocoaPods script and solves the crash.

Note: remove -Core part that if you use pod 'Parse' instead of pod 'Parse/Core'.

Upvotes: 1

Related Questions