菜鸟教程小白 发表于 2022-12-12 14:52:32

ios - 架构 x86_64 的 1159 个重复符号


                                            <p><p>我最近在使用 <code>react-native-maps</code> 时遇到了一个奇怪的问题。尝试通过 xcode 编译应用程序时,出现以下错误</p>

<pre><code>...
ld: 1159 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
</code></pre>

<p> <a href="https://pastebin.com/kJABwBwN" rel="noreferrer noopener nofollow">Whole stacktrace</a> </p>

<p>到目前为止,我已经尝试了所有方法。例如这些帖子 <a href="https://stackoverflow.com/questions/24298144/duplicate-symbols-for-architecture-x86-64-under-xcode" rel="noreferrer noopener nofollow">first</a> <a href="https://stackoverflow.com/questions/26303782/duplicate-symbols-for-architecture-arm64/26303957" rel="noreferrer noopener nofollow">second</a> </p>

<p>这是我的 Podfile:</p>

<pre><code>platform :ios, &#39;9.0&#39;
source &#39;https://github.com/CocoaPods/Specs.git&#39;

target &#34;__APP_NAME__&#34; do
react_native_path = &#34;../node_modules/react-native&#34;
pod &#34;yoga&#34;, :path =&gt; &#34;#{react_native_path}/ReactCommon/yoga&#34;
pod &#39;React&#39;, path: &#39;../node_modules/react-native&#39;, :subspecs =&gt; [
&#39;Core&#39;,
&#39;RCTActionSheet&#39;,
&#39;RCTGeolocation&#39;,
&#39;RCTImage&#39;,
&#39;RCTLinkingIOS&#39;,
&#39;RCTNetwork&#39;,
&#39;RCTSettings&#39;,
&#39;RCTText&#39;,
&#39;RCTVibration&#39;,
&#39;RCTWebSocket&#39;
]

pod &#39;GoogleMaps&#39;

pod &#39;Firebase/Core&#39;, &#39;~&gt; 5.3.0&#39;
pod &#39;Firebase/Messaging&#39;, &#39;~&gt; 5.3.0&#39;

end

post_install do |installer|
installer.pods_project.targets.each do |target|
    if target.name == &#39;react-native-google-maps&#39;
      target.build_configurations.each do |config|
      config.build_settings[&#39;CLANG_ENABLE_MODULES&#39;] = &#39;No&#39;
      end
    end
    if target.name == &#34;React&#34;
      target.remove_from_project
    end
end
end
</code></pre>

<p>我还尝试使用在 react-native-maps 存储库的自述文件中指定的完全相同的 Podfile(结果相同),并尝试删除 <code>-ObjC</code> 标志来自 <code>Other Linker Flags</code> 并导致应用程序构建,但是当我尝试启动它时,它在 main.m 文件中因 <code>Thread 1: signal SIGABRT</code> 而崩溃。
<a href="/image/wxAKs.png" rel="noreferrer noopener nofollow"><img src="/image/wxAKs.png" alt="Thread 1: signal SIGABRT"/></a> </p>

<h1>编辑:</h1>

<p>在安装 <code>react-native-maps</code> 之前我已将我的 git repo 恢复为重新安装了所有节点模块并尝试重新安装所有 pod(我运行了 <a href="https://gist.github.com/mbinna/" rel="noreferrer noopener nofollow">this</a> 和 <code>rm - rf ~/.cocoapods/repos/master && pod setup && pod install</code>) 然后尝试在 xcode 中重建项目,但仍然出现相同的错误。我的播客文件</p>

<pre><code>platform :ios, &#39;9.0&#39;
source &#39;https://github.com/CocoaPods/Specs.git&#39;

target &#34;_APP_&#34; do
pod &#39;yoga&#39;, :path =&gt; &#39;../node_modules/react-native/ReactCommon/yoga/Yoga.podspec&#39;
pod &#39;React&#39;, path: &#39;../node_modules/react-native&#39;, :subspecs =&gt; [
    &#39;Core&#39;,
    &#39;RCTActionSheet&#39;,
    &#39;RCTAnimation&#39;,
    &#39;RCTGeolocation&#39;,
    &#39;RCTImage&#39;,
    &#39;RCTLinkingIOS&#39;,
    &#39;RCTNetwork&#39;,
    &#39;RCTSettings&#39;,
    &#39;RCTText&#39;,
    &#39;RCTVibration&#39;,
    &#39;RCTWebSocket&#39;
]

pod &#39;Firebase/Core&#39;, &#39;~&gt; 5.3.0&#39;
pod &#39;Firebase/Messaging&#39;, &#39;~&gt; 5.3.0&#39;
end
</code></pre>

<p>我现在想知道,我的项目出了什么问题?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>所以,经过大约一整天的调试,我找到了应用程序无法构建的原因。如果我在发布此答案之前没有解决它@Christos Koninis 评论会让我找到问题的根本原因。我再次查看日志,发现我一直在使用 <code>React</code> 的两个实例。一个来自 <code>node_modules/</code>,一个来自 <code>ios/pods/</code>。我缺少的是我的 Podfile 中的这个:</p>

<pre><code>post_install do |installer|
installer.pods_project.targets.each do |target|
    if target.name == &#34;React&#34;
      target.remove_from_project
    end
end
end
</code></pre>

<p> <a href="https://github.com/react-native-community/react-native-svg/issues/621#issuecomment-371639854" rel="noreferrer noopener nofollow">Credits</a> </p>

<p>最后我的 Podfile 看起来像这样:</p>

<pre><code>platform :ios, &#39;9.0&#39;

target &#34;_APP_&#34; do
rn_path = &#39;../node_modules/react-native&#39; # This path is likely to be `../node_modules/react-native` in your own project.
rn_maps_path = &#39;../node_modules/react-native-maps&#39; # This path is likely to be `../node_modules/react-native-maps` in your own project.

# See http://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies
pod &#39;yoga&#39;, path: &#34;#{rn_path}/ReactCommon/yoga/yoga.podspec&#34;
pod &#39;React&#39;, path: rn_path, subspecs: [
    &#39;Core&#39;,
    &#39;CxxBridge&#39;,
    &#39;DevSupport&#39;,
    &#39;RCTActionSheet&#39;,
    &#39;RCTAnimation&#39;,
    &#39;RCTGeolocation&#39;,
    &#39;RCTImage&#39;,
    &#39;RCTLinkingIOS&#39;,
    &#39;RCTNetwork&#39;,
    &#39;RCTSettings&#39;,
    &#39;RCTText&#39;,
    &#39;RCTVibration&#39;,
    &#39;RCTWebSocket&#39;,
]

# React Native third party dependencies podspecs
pod &#39;DoubleConversion&#39;, :podspec =&gt; &#34;#{rn_path}/third-party-podspecs/DoubleConversion.podspec&#34;
pod &#39;glog&#39;, :podspec =&gt; &#34;#{rn_path}/third-party-podspecs/glog.podspec&#34;
pod &#39;Folly&#39;, :podspec =&gt; &#34;#{rn_path}/third-party-podspecs/Folly.podspec&#34;

   # react-native-maps dependencies
   pod &#39;react-native-maps&#39;, path: rn_maps_path
   pod &#39;react-native-google-maps&#39;, path: rn_maps_path# Remove this line if you don&#39;t want to support GoogleMaps on iOS
   pod &#39;GoogleMaps&#39;# Remove this line if you don&#39;t want to support GoogleMaps on iOS
   pod &#39;Google-Maps-iOS-Utils&#39; # Remove this line if you don&#39;t want to support GoogleMaps on iOS

# Firebase
pod &#39;Firebase/Core&#39;, &#39;~&gt; 5.3.0&#39;
pod &#39;Firebase/Messaging&#39;, &#39;~&gt; 5.3.0&#39;



end

post_install do |installer|
installer.pods_project.targets.each do |target|
    if target.name == &#39;react-native-google-maps&#39;
      target.build_configurations.each do |config|
      config.build_settings[&#39;CLANG_ENABLE_MODULES&#39;] = &#39;No&#39;
      end
    end
    if target.name == &#34;React&#34;
      target.remove_from_project
    end
end
end
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 架构 x86_64 的 1159 个重复符号,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/52168666/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/52168666/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 架构 x86_64 的 1159 个重复符号