2017-04-13 67 views
2

我在尝试将分段分析与React Native包装库(react-native-segment-analytics)相集成。核心Segment iOS库已添加为Pod(使用use_frameworks!);我将SegmentAnalytics.xcodeproj放入Libraries/的包装库。iOS库无法找到标头

我运行到该错误是

.../node_modules/react-native-segment-analytics/ios/SegmentAnalytics/Classes/SegmentAnalytics.m:7:9: fatal error: 'Analytics/SEGAnalytics.h' file not found

有问题的行是

#import <Analytics/SEGAnalytics.h>

Libraries

SEGAnalytics.h

我很有信心,这是不是特定于细分市场,但我为了以防万一而将其留在这里。

标题在项目中可用。事实上,我可以将这个相同的#import添加到项目根目录下的源文件中,并且解决问题。唯一的区别是我可以看出,包装库是一个嵌入式xcodeproj。

我一直在砸我的脑袋,似乎每一个试图解决这个问题的Xcode配置选项,包括尝试不同的标题搜索路径和框架搜索路径,试图添加段库作为一个链接的二进制文件,即使将输入从<>更改为“”语法。

任何帮助表示赞赏。

编辑:使用图书馆:

EDIT2:增加了一些文字,试图澄清段VS的反应,本机段的分析库。

https://github.com/segmentio/analytics-ios

https://github.com/charlires/react-native-segment-analytics

回答

0

尝试使用安装instructions从这个库的开发者:

Installation

  1. Download and install the npm package by running npm install --save react-native-segment-io-analytics
  2. In your Podfile, add pod "Analytics" to your project and run pod install in your ios folder
  3. Inside Xcode (make sure you've opened your .xcworkspace file), go to the project navigator and right click Libraries -> Add Files to [your project's name].
  4. Go to node_modules -> react-native-segment-io-analytics -> and choose the RNSegmentIOAnalytics.xcodeproj file. Make sure your project links to libAnalytics.a and libRNSegmentIOAnalytics.a (The libraries should be listed under "Build Phases -> Link Binary With Libraries").

也许,你已经错过了一些步骤。

+0

使用的库是https://github.com/charlires/react-native-segment-analytics(在原始文章中更新)。我从添加包装为Pod的RN改为嵌入xcodeproj,因为我们的项目本身包含React Native(而不是Cocoapod),并且我们遇到了其他依赖性问题,而没有为“React”添加Pod。 – dpalmer

+0

对我而言,仍然不清楚一件事:您已经将SegmentAnalitics添加为项目依赖项,并且您已将react-native-segment-analytics添加为pod依赖项?或相反亦然?因为在你的第一个截图中,SegmentAnalitics是项目依赖项。 –

+0

它读起来有点不可思议。我将更新原始文章,但是SegmentAnalytics.xcodeproj === react-native-segment-analytics,Analytics === Segment的iOS库。 – dpalmer

0

经过大量的试验和错误之后,我无法连接图书馆,并且无法看到Segment Analytics Pod文件依赖关系。我最终删除了我们在项目中链接的所有第三方模块,并将它们全部添加为CocoaPods。这极大地简化了我们的iOS项目文件(不再管理对搜索页眉路径或链接库/框架的更改)。

值得一提:

  • 切换到通过的CocoaPods所有RN的依赖拉动需要将大部分的React Subspecs的把事情的工作和以前一样。
  • 我在此迁移中遇到了缓存地狱。 tl; dr清除所有node_modules,Pods,派生数据和iOS构建文件夹。
  • 我不得不在Podfile中注释掉use_frameworks!。否则,我碰到fatal error: 'React/RCTBridgeModule.h' file not found错误。谷歌搜索导致死胡同。