Search code examples
iosreact-nativetwittercocoapodsreact-native-ios

React-native-twitter-signin: ios Undefined symbols for architecture x86_64,Edit: attempt made to log in without a valid twitter kit url scheme


I'm following those steps to be able to use the package in ios and no luck. It works fine in android:

https://github.com/GoldenOwlAsia/react-native-twitter-signin#prerequisites

Then I'm adding the twitter 3 sdk with cocoa pods:

https://github.com/twitter/twitter-kit-ios/wiki/Installation

The full error is

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_Twitter", referenced from:
      objc-class-ref in libRNTwitterSignIn.a(RNTwitterSignIn.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I linked that library. I installed the cocoapod Twitter 3 sdk but I'm still getting the build error.

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'app' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for app

  pod 'Firebase/Core'
  pod 'Firebase/Auth'
  pod 'TwitterKit'

  target 'appTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

My AppDelegate.m is:

#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>

// **********************************************
// *** DON'T MISS: THE NEXT LINE IS IMPORTANT ***
// **********************************************


// IMPORTANT: if you're getting an Xcode error that RCCManager.h isn't found, you've probably ran "npm install"
// with npm ver 2. You'll need to "npm install" with npm 3 (see https://github.com/wix/react-native-navigation/issues/1)

#import <Firebase.h>
#import "RCCManager.h"
#import <TwitterKit/TWTRKit.h>

#import <React/RCTRootView.h>


@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIRApp configure];

  [[FBSDKApplicationDelegate sharedInstance] application:application
                           didFinishLaunchingWithOptions:launchOptions];

  [[Twitter sharedInstance] startWithConsumerKey:@"dasdasdasasd" consumerSecret:@"dsadasdadasdasd"];


  NSURL *jsCodeLocation;
#ifdef DEBUG
  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  self.window.backgroundColor = [UIColor whiteColor];
  [[RCCManager sharedInstance] initBridgeWithBundleURL:jsCodeLocation launchOptions:launchOptions];

  return YES;
}

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(NSDictionary<NSString *,id> *)options {

  BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application
                                                                openURL:url
                                                      sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                                             annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
                  ];

  BOOL handledT = [[Twitter sharedInstance] application:application openURL:url options:options];
  // Add any custom logic here.
  return handled || handledT;
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
  [FBSDKAppEvents activateApp];
}

@end

My build phases:

enter image description here

My build settings for architectures:

enter image description here

My info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>CFBundleURLTypes</key>
  <array>
    <dict>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>twitterkit-XXXXXX</string>
        </array>
      </dict>
    </array>
    <key>LSApplicationQueriesSchemes</key>
    <array>
      <string>twitter</string>
      <string>twitterauth</string>
    </array>

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fbXXXX</string>
            </array>
        </dict>
    </array>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fb-messenger-share-api</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
    </array>
    <key>NSCameraUsageDescription</key>
    <string>Camera Permissions</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Gallery Permissions</string>
    <key>UIAppFonts</key>
    <array>
        <string>Ionicons.ttf</string>
    </array>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>App</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string></string>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>localhost</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
        <!--Include to allow subdomains-->
        <key>NSIncludesSubdomains</key>
        <true/>
        <!--Include to allow HTTP requests-->
        <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
        <true/>
        <!--Include to specify minimum TLS version-->
        <key>NSTemporaryExceptionMinimumTLSVersion</key>
        <string>TLSv1.1</string>
            </dict>
        </dict>
    </dict>
    <key>FacebookAppID</key>
    <string>XXXXXXXX</string>
    <key>FacebookDisplayName</key>
    <string>MyApp</string>
</dict>
</plist>

Already tried to clean the project, update the TwitterKit cocoapod,clean build folder with going to options and holding the alt button but nothing works. Any help on what could be the problem??


Solution

  • I fixed it....The solution in my case to the second problem that I mention on the comments to Pritish Vaidya of twitter complaining about me trying to login wihtout a URL scheme was that I had to unify duplicated keys on the info.plist since facebook and twitter they both have url schemes and you can't duplicate the entries, you have to put it all in the same array under one key and I also unified LSApplicationQueriesSchemes into one. As you can see in the plist above is duplicated for both entries. So the two entries now in unified format would be:

    <key>CFBundleURLTypes</key>
      <array>
        <dict>
          <key>CFBundleURLSchemes</key>
          <array>
            <string>twitterkit-key</string>
            <string>fbkey</string>
            </array>
          </dict>
        </array>
      <key>LSApplicationQueriesSchemes</key>
        <array>
        <string>twitter</string>
        <string>twitterauth</string>
            <string>fbapi</string>
            <string>fb-messenger-share-api</string>
            <string>fbauth2</string>
            <string>fbshareextension</string>
        </array>