通过 CocoaPods 添加时出现 Pinterest 链接器错误
Pinterest Linker Error when added through CocoaPods
1)我已经完成了 Pinterest 开发者网站上给出的所有步骤 here
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)但是当我添加上面的代码时它给出了链接器错误
Edit: I have tried it in blank project it works fine. But I am unable
to figure out what all the dependencies still there in old project.
重新开始
使用Xcode 7.1+,新建一个新的项目,运行 pod install
:
target 'SO-34633492' do
pod "PinterestSDK", :git => "https://github.com/pinterest/ios-pdk.git"
end
您现有的项目中可能存在不一致;虽然找出问题所在可能很有启发性,但我建议您从头开始。
必须包含headers
你不能编译你的 .m
而不包括 #import <PDKPin.h>
:
~/SO-34633492/SO-34633492/ViewController.m:21:6: Use of undeclared identifier '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");
}];
可能出错的地方
经过长时间的搜索和尝试
我找到了以下解决方案
- 我已经更改了目标的构建设置
其他链接器标志部分。
我在其他链接器标志
中添加了标志 $(inherited)
1)我已经完成了 Pinterest 开发者网站上给出的所有步骤 here
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)但是当我添加上面的代码时它给出了链接器错误
Edit: I have tried it in blank project it works fine. But I am unable to figure out what all the dependencies still there in old project.
重新开始
使用Xcode 7.1+,新建一个新的项目,运行 pod install
:
target 'SO-34633492' do
pod "PinterestSDK", :git => "https://github.com/pinterest/ios-pdk.git"
end
您现有的项目中可能存在不一致;虽然找出问题所在可能很有启发性,但我建议您从头开始。
必须包含headers
你不能编译你的 .m
而不包括 #import <PDKPin.h>
:
~/SO-34633492/SO-34633492/ViewController.m:21:6: Use of undeclared identifier '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");
}];
可能出错的地方
经过长时间的搜索和尝试 我找到了以下解决方案
- 我已经更改了目标的构建设置 其他链接器标志部分。 我在其他链接器标志 中添加了标志 $(inherited)