ld:找不到框架Stripe for architecture x86_64

时间:2022-09-02 15:16:44

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:

现在,每当我尝试编译Project B时,都会收到此错误:

ld: framework not found Stripe for architecture x86_64

ld:找不到框架Stripe for architecture x86_64

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

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

#import <Stripe/Stripe.h>

#import

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.framework is listed).

Xcode可以轻松找到Stripe.h。我也尝试将Stripe SDK直接添加到Project 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”)位于其下方。

ld:找不到框架Stripe for architecture x86_64

Here's the full error:

这是完整的错误:

ld:找不到框架Stripe for architecture x86_64

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

4 个解决方案

#1


13  

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 Libraries section.

在运行我的测试目标时,我在另一个框架中看到了同样的问题。我必须在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

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

#2


10  

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, simply be sure that framework is added into your framework.

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

#3


6  

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.

    添加“$(SRCROOT)/../ ..”(因为项目B在项目A内部生成两个文件夹)到“项目B”目标的“构建设置” - >“搜索路径”下的“框架搜索路径”。

  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.

    将Stripe SDK添加到Project B的框架中。第二步特别让我感到惊讶,因为Project B不直接依赖Stripe。

#4


3  

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

#1


13  

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 Libraries section.

在运行我的测试目标时,我在另一个框架中看到了同样的问题。我必须在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

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

#2


10  

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, simply be sure that framework is added into your framework.

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

#3


6  

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.

    添加“$(SRCROOT)/../ ..”(因为项目B在项目A内部生成两个文件夹)到“项目B”目标的“构建设置” - >“搜索路径”下的“框架搜索路径”。

  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.

    将Stripe SDK添加到Project B的框架中。第二步特别让我感到惊讶,因为Project B不直接依赖Stripe。

#4


3  

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