6
votes

enter image description hereUsing Pinterest's iOS SDK via Cocoapods and a bridging header, works fine in my app.

Created new target -> action extension in my project. Have tried linking PDK framework in Linked Frameworks and Libraries, have tried adding a separate bridging header file in the extension, but Xcode crashes not being able to find it.... Any ideas on how to import it?

podfile:

platform :ios, '9.0'

pod "PinterestSDK", :git => "[email protected]:pinterest/ios-pdk.git"

pod "PINRemoteImage"

pod "GBDeviceInfo"

pod 'FBSDKCoreKit'



xcodeproj '/Users/garysabo/Dropbox/Xcode Projects/pinFixer2/pinFixer2.xcodeproj'

bridging header:

#import "PinterestSDK.h"
#import "PDKPin.h"
#import "PDKBoard.h"
#import "PDKImageInfo.h"
#import "PDKResponseObject.h"
#import "PDKClient.h"
#import "PDKModelObject.h"
#import "PDKUser.h"
1
Your question is confusing me. If you are using cocoapods, there is no need to bridge the header files. Can you dump your Podfile here? - Naresh
sure, just added - GarySabo
When you create an extension, it adds a target to your Xcode project. Cocoapods by default only sets up the first target it sees. You'll need to add a target "[name]" do ... end section in your Podfile. However, that still might not work, depending on whether or not the Pinterest SDK library is marked as "safe for extensions". - Dave Weston
thanks @DaveWeston but I want 2 targets right, my app and my extension, can I do that? - GarySabo
Yes, you can have two target sections in your Podfile, just make sure you're using the correct name for each. You can have different pods in each target, or the same. Cocoapods will do the best it can to deduplicate. - Dave Weston

1 Answers

5
votes

Check this pod file code as example, this pod file have 2 targets the app and the extension.

platform :ios, '9.0'
use_frameworks!
workspace 'MyWorkSpaceApp'

target 'MyApp' do

       pod 'SwiftyUserDefaults'
       pod 'Alamofire', '~> 4.0'
       pod 'AlamofireImage', '~> 3.1'
       #pod 'AlamofireNetworkActivityIndicator', '~> 2.0'
       #pod "youtube-ios-player-helper", "~> 0.1.6"
       #pod 'Alamofire-SwiftyJSON'
       pod 'SwiftyJSON', '~> 3.0.0'
       #pod 'SlideMenuControllerSwift'
       pod 'UIColor_Hex_Swift', '~> 3.0.2'
       #pod 'ALLoadingView', :git => 'https://github.com/ALoginov/ALLoadingView.git', :branch => 'swift3'
       pod 'SDWebImage', '~>3.8'
       #pod 'SwiftSpinner', :git => 'https://github.com/icanzilb/SwiftSpinner.git', :branch => 'swift3'
       #pod 'SideMenu'
       #pod 'Fabric'
       #pod 'Crashlytics'
       #pod 'IQKeyboardManagerSwift', '4.0.6'
       #pod 'AELog'
       #pod 'TestFairy'
       #pod "AwesomeCache", "~> 5.0"
       #pod 'Deviice'
       #pod 'MKDropdownMenu'
       #pod "HanekeSwift", :git => 'https://github.com/Haneke/HanekeSwift.git', :branch => 'feature/swift-3'
       pod 'OneSignal', '~> 2.4'

       post_install do |installer|
        puts("Update debug pod settings to speed up build time")
        Dir.glob(File.join("Pods", "**", "Pods*{debug,Private}.xcconfig")).each do |file|
            File.open(file, 'a') { |f| f.puts "\nDEBUG_INFORMATION_FORMAT = dwarf" }
        end
    end

       target 'MyAppExtension' do 
           pod 'OneSignal', '~> 2.4'
       end

end

I hope this helps you, best regards