繁体   English   中英

通过CocoaPods添加Pinterest链接器错误

[英]Pinterest Linker Error when added through CocoaPods

1)我已经做了在Pinterest的开发者网站上提供的所有步骤, 在这里

2)这是我的pod文件

 # Uncomment this line to define a global platform for your project
     platform :ios, ‘7.0’
    # Uncomment this line if you're using Swift
    # use_frameworks!

    target 'xyz.com' do
    pod "PinterestSDK", :git => "https://github.com/pinterest/ios-pdk.git"
    end
   target 'xyz.comTests' do

    end

3)当我没有 #import“ PDKPin.h”&以下代码运行时

[PDKPin pinWithImageURL:[NSURL URLWithString:imageUrl]
                       link:[NSURL URLWithString:shareUrl]
         suggestedBoardName:@""
                       note:productName
                withSuccess:^
     {
         NSLog(@"Succesful to pin");

     }
                 andFailure:^(NSError *error)
     {
         NSLog(@"Failed to pin");
     }];

它运行没有错误

4)但是当我添加上面的代码时,它会给出链接器错误

在此处输入图片说明

编辑:我已经在空白项目中尝试过,它工作正常。 但是我无法弄清楚旧项目中仍然存在哪些依赖关系。

重新开始

使用Xcode 7.1+,创建一个项目,运行pod install

target 'SO-34633492' do
    pod "PinterestSDK", :git => "https://github.com/pinterest/ios-pdk.git"
end

您可能在现有项目中存在不一致之处; 在弄清楚问题出在哪里可能会有所启发,但我建议您从头开始。

必须包含标题

如果不包含#import <PDKPin.h>则无法编译.m

〜/ SO-34633492 / SO-34633492 / ViewController.m:21:6:使用未声明的标识符“ PDKPin”

确实有效:

#import <PDKPin.h>
NSString * imageUrl = @"";
NSString * shareUrl = @"";
NSString * productName = @"";

[PDKPin pinWithImageURL:[NSURL URLWithString:imageUrl]
                   link:[NSURL URLWithString:shareUrl]
     suggestedBoardName:@""
                   note:productName
            withSuccess:^
 {
     NSLog(@"Succesful to pin");
 }
             andFailure:^(NSError *error)
 {
     NSLog(@"Failed to pin");
 }];

可能出错的事情

经过长时间的搜索和尝试,我找到了以下解决方案

  1. 我在其他链接器标志部分中更改了目标的构建设置。 我在其他链接器标志中添加了标志$(继承)

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM