xcode ld:未找到架构 x86_64 的 Stripe 框架

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34798741/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:26:01  来源:igfitidea点击:

ld: framework not found Stripe for architecture x86_64

iosobjective-cxcodexcode7stripe-payments

提问by Lane Rettig

I have an iOS component which relies on the Stripe iOS SDK, Project A. I included the Stripe SDK in Project A in Xcode and it compiles fine.

我有一个 iOS 组件,它依赖于Stripe iOS SDK,项目 A。我在 Xcode 的项目 A 中包含了 Stripe SDK,它编译得很好。

However, I'm building another project in Xcode which relies on this component, Project B. I added Project A to Project B's libraries. Project A relies on project B but does not rely directly on the Stripe SDK.

但是,我正在 Xcode 中构建另一个项目,该项目依赖于该组件,即项目 B。我将项目 A 添加到项目 B 的库中。项目 A 依赖项目 B,但不直接依赖 Stripe SDK。

Now, whenever I try to compile Project B, I get this error:

现在,每当我尝试编译项目 B 时,都会出现此错误:

ld: framework not found Stripe for architecture x86_64

ld: framework not found Stripe for architecture x86_64

This line (inside Project A) seems to trigger the error:

这一行(在项目 A 内)似乎触发了错误:

#import <Stripe/Stripe.h>

#import <Stripe/Stripe.h>

Xcode has no trouble finding Stripe.h. I tried adding the Stripe SDK directly to Project B as well. I've double and triple-checked the Build Phases -> Link Binary With Libraries section for all targets (Stripe.frameworkis listed).

Xcode 可以轻松找到Stripe.h. 我也尝试将 Stripe SDK 直接添加到项目 B。我已经对所有目标的 Build Phases -> Link Binary With Libraries 部分进行了两次和三次检查(Stripe.framework已列出)。

I added the Stripe framework manually, so then I also tried adding it with Cocoapods instead, but that also didn't work.

我手动添加了 Stripe 框架,然后我也尝试使用 Cocoapods 添加它,但这也不起作用。

Please help!

请帮忙!

Here's the project structure for Project B ("example"), with Project A ("RCTFBLogin") below it.

这是项目 B(“示例”)的项目结构,其下方是项目 A(“RCTFBLogin”)。

enter image description here

在此处输入图片说明

Here's the full error:

这是完整的错误:

enter image description here

在此处输入图片说明

I'm using Xcode 7.2 and the most recent version of the Stripe SDK (6.0.0). The same Stripe framework code works fine in another project.

我使用的是 Xcode 7.2 和最新版本的 Stripe SDK (6.0.0)。相同的 Stripe 框架代码在另一个项目中运行良好。

Thanks.

谢谢。

Update: I added "$(SRCROOT)/../.." (since Project B lives two folders deep inside Project A) to "Framework Search Paths" under Build Settings -> "Search Paths" for the Project B target and it began compiling successfully. However, I now get this error when running:

更新:我将“ $(SRCROOT)/../..”(因为项目 B 位于项目 A 内部深处的两个文件夹中)添加到项目 B 目标的“构建设置”->“搜索路径”下的“框架搜索路径”,并且它开始成功编译。但是,我现在在运行时收到此错误:

ld: warning: Auto-Linking supplied '/Users/rettig/wip/react-native-facebook-login.2/Stripe.framework/Stripe', framework linker option at /Users/rettig/wip/react-native-facebook-login.2/Stripe.framework/Stripe is not a dylib
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_Stripe", referenced from:
      objc-class-ref in libRCTFBLogin.a(RCTFBLogin.o)
ld: symbol(s) not found for architecture x86_64

采纳答案by Lane Rettig

I had to do two things to get this working:

我必须做两件事才能让它工作:

  1. Add "$(SRCROOT)/../.." (since Project B lives two folders deep inside Project A) to "Framework Search Paths" under Build Settings -> "Search Paths" for the Project B target.

  2. Add the Stripe SDK to Project B's frameworks as well. This second step in particular surprised me because Project B does not rely directly upon Stripe.

  1. 将“$(SRCROOT)/../..”(因为项目 B 位于项目 A 内部的两个文件夹深处)到项目 B 目标的“构建设置”->“搜索路径”下的“框架搜索路径”。

  2. 也将 Stripe SDK 添加到项目 B 的框架中。这第二步让我特别惊讶,因为项目 B 并不直接依赖于 Stripe。

回答by Adam Johns

I was seeing this same issue with another framework while running my test target. I had to add the framework to my test target(not only my normal target) under Build Phases > Link Binary With Librariessection.

在运行我的测试目标时,我在另一个框架中看到了同样的问题。我不得不将框架添加到我的测试目标(不仅是我的正常目标)下Build Phases > Link Binary With Libraries

Carthage has more info about the issue I saw: https://github.com/carthage/carthage#adding-frameworks-to-unit-tests-or-a-framework

Carthage 有关于我看到的问题的更多信息:https: //github.com/carthage/carthage#adding-frameworks-to-unit-tests-or-a-framework

回答by Honey

Did you run into this issue when you ran your test cases?

您在运行测试用例时遇到过这个问题吗?

So this is how my podfile looks like:

所以这就是我的 podfile 的样子:

def shared_pods
    pod ‘GoogleMaps', '~> 1.13.0'
    pod ‘SwiftyJSON', '~> 2.3.2'
    pod ‘Alamofire', '~> 3.2.1'
    pod ‘MGSwipeTableCell'
end

target 'projectName' do
   shared_pods
end

So then I added this to podfile:

然后我将其添加到 podfile 中:

target ‘ProjectTests' do
    pod ‘Nimble', ‘~> 4.0.0'
    pod 'Quick'
end

What I also needed to do was:

我还需要做的是:

target ‘ProjectTests' do
    shared_pods // I needed to add this line as well. Since this line included the needed 'MGSwipeTableCell' framework 
    pod ‘Nimble', ‘~> 4.0.0'
    pod 'Quick'
end

So a possible reason would be that in your podfile you didn't add them correctly, just be sure that the framework is added into the necessary targets.

因此,一个可能的原因是在您的 podfile 中您没有正确添加它们,只需确保将框架添加到必要的目标中即可。

回答by Brooks DuBois

Noticed this problem while switching some dependencies from pods to carthage. Similar to Honey's answer, I was able to get around this error modifying the podfile.

在将一些依赖项从 pod 切换到 carthage 时注意到了这个问题。与 Honey 的回答类似,我能够通过修改 podfile 来解决这个错误。

Turns out all I had to add was the test target. Then run 'pod install', and it will link your test target to your the frameworks generated by your pods.

原来我必须添加的只是测试目标。然后运行“pod install”,它会将您的测试目标链接到您的 pod 生成的框架。

target 'Project' do
  use_frameworks!

  //pods here normally

  target 'ProjectTests' do
   //nothing in here
  end
end