[英]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");
}];
可能出错的事情
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.