如何在不安装 Fabric.app 的情况下在 iOS 上使用 Twitter 的框架?

How do I use Twitter's Frameworks on iOS without installing Fabric.app?

我正在开发一个应用程序,它需要比内置 Twitter.framework 允许的更详细地与 Twitter 集成。

Twitter 使用 Fabric.app 发布他们的 API,这很难升级框架。

我只想包含 Fabric.app 将包含在我的项目中的框架,并跳过他们使用 "easy integration solution" 创建的所有设置麻烦。做什么?

我认为目前不可能,因为 Twitter 购买了 crashlytics,而 crashlytics 需要 fabric,我们也有类似的担忧,看起来 TwitterKit 也使用 Fabric 来启动会话。

根据这里https://docs.fabric.io/ios/twitter/twitterkit-setup.html#integrate-with-your-app

必须打这个电话;

[[Twitter sharedInstance] startWithConsumerKey:@"your_key" consumerSecret:@"your_secret"];
[Fabric with:@[[Twitter class]]];

而且您不知道 Fabric.m 中发生了什么,但头文件需要 Twitter 进行初始化

/**
 *  Fabric Base. Coordinates configuration and starts all provided kits.
 */
@interface Fabric : NSObject

/**
 * Initialize Fabric and all provided kits. Call this method within your App Delegate's `application:didFinishLaunchingWithOptions:` and provide the kits you wish to use.
 *
 * For example, in Objective-C:
 *
 *      `[Fabric with:@[[Crashlytics class], [Twitter class], [Digits class], [MoPub class]]];`
 *
 * Swift:
 *
 *      `Fabric.with([Crashlytics.self(), Twitter.self(), Digits.self(), MoPub.self()])`
 *
 * Only the first call to this method is honored. Subsequent calls are no-ops.
 *
 * @param kitClasses An array of kit Class objects
 *
 * @return Returns the shared Fabric instance. In most cases this can be ignored.
 */
+ (instancetype)with:(NSArray *)kitClasses; 

这里是来自 Crashlytics 和 Fabric 的 Mike。

如果您想在没有 Fabric.app 的情况下安装 Fabric 的任何部分,您可以通过 Cocoapods 前往此处的网络入门:https://fabric.io/kits/ios/twitterkit/install

实际上,将以下内容添加到您的 podfile 中:

pod 'Fabric'
pod 'TwitterKit'

然后运行pod install

添加 运行 脚本构建阶段,其中 API 密钥和构建密码将在登录上述页面时提供。

"${PODS_ROOT}/Fabric/run" <API_KEY> <Build_secret> 

然后将您的 API 密钥和 Twitter 消费者密钥和秘密添加到您的 info.plist:

<key>Fabric</key>
  <dict>
    <key>APIKey</key>
    <string>API_KEY</string>
    <key>Kits</key>
    <array>
      <dict>
        <key>KitInfo</key>
        <dict>
          <key>consumerKey</key>
          <string>Consumer Key</string>
          <key>consumerSecret</key>
          <string>Consumer Secret</string>
        </dict>
        <key>KitName</key>
        <string>Twitter</string>
      </dict>
    </array>
  </dict>

然后初始化工具包,在您的应用程序的委托中推荐:

#import <Fabric/Fabric.h>
#import <TwitterKit/TwitterKit.h>

[Fabric with:@[[Twitter class]]];