How to import Twitter Fabric Kit into my iOS Static Framework

ios
fabric

#1

I am creating an iOS static framework
I want to integrate Login with Twitter into my Framework.
To do this I have downloaded and installed Twitter Fabric Tool, from which I will install the ‘Twitter’ Kit.

The problem that I’m facing is that if I select my iOS Static
Framework Project and click on ‘Next’ button in the Fabric interface, it
gives an error message like ‘This Xcode project does not have any Mac
or iOS targets’. Here’s a screenshot of what I’m seeing in the Fabric Interface

What needs to be done if I want to integrate this into my Static iOS Framework.
Has anyone worked on this before and faced similar issue.
Any insights into this would be really helpful.


#2

Thanks for reaching out on this @Mitesh, are you planning on distributing your framework to third parties or is this only for your own projects?


#3

Thanks you So much for reply my question.
I am planning to distribute for Customers, Client will download Framework from Company Website and they will use that Framework to build their own company application but social login will be done from Framework only.


#4

Thanks for confirming @Mitesh, so our onboarding flow on Fabric.app does expect an actual app, not a framework. You might have an easier time for the instructions here: https://fabric.io/kits/ios/twitterkit/install Then you’d want to have a dependency on those libraries, also you’d need to remove any reference to the Fabric Twitter Consumer Key and Secret in the info.plist, and instead have the app’s use either a wrapper - TwitterKitWrapper(key, secret) or [[Twitter sharedInstance] startWithConsumerKey:@"your_key" consumerSecret:@"your_secret"];

An example of another dev with a similar approach is here: https://github.com/393385724/DDSocial


#5

Hey @bonnell

thanks for the help.
I have tried implementing TwitterKit Framework without Fabric, although, what seems to happen is that I get an error when compiling my Project.
This is the error message that I get
ld: ‘/Users/Test/Documents/TestFrameworkDemo/TestFrameworkDemo/Framwork/TwitterKit.framework/TwitterKit(TWTRTweetViewSizeCalculator.o)’ does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Like I said, I’ll be providing this Framework to our clients, so I cannot assume that they will have the bit code enabled for their project.

Is there any setting or code that I can write so that I can use this Framework and not get this error message. Or is there any Framework available that I can use without Fabric and does not have this Bitcode constraint.


#6

Hey @Mitesh,

That error means that your app is setup for Bitcode, but the framework is not. Just disable Bitcode here:


#7

Hey @bonnell

Thanks a lot.


#8

Hey @bonnell

I appreciate for your response , I have successfully integrated twitter kit framework by disabling Bit-code, But when i run this application on device it opens twitter login window and it is working fine but if twitter app is installed on device so it does not open system app so how to define login behaviour in code so it checks if twitter app installed then it will redirect to app otherwise it open normal web view login.

So can you please help me or provide twitter-kit framework which can help me to identify login behaviour…

Thanks A lot…


#9

Hey @Mitesh,

Information on how to control which login methods is listed in our documentation here: https://docs.fabric.io/apple/twitter/log-in-with-twitter.html#log-in-with-twitter

Quoting from it:

The SDK first attempts to leverage system Twitter accounts, via Accounts.framework. If that fails, it
falls back to presenting an OAuth flow. After successful authentication, the SDK automatically saves the account to iOS system accounts and the TWTRSession will contain a token, secret, username, and user ID of the user. If authentication fails, the error will be non-nil.

Developers can have more control over which methods are used for logging in to Twitter by using the TWTRLoginMethod enum defined in Twitter.h along with the [Twitter logInWithMethods:completion:] method. By default, Twitter Kit will choose log in methods in the following order [System Account] -> [SFSafariViewController] -> [UIWebView]. With the TWTRLoginMethod enum, the developer can choose which methods to use when providing the user with the ability to log in using Twitter.

In order to use the SFSafariViewController log in method, the SafariServices.framework must be added to your app. User authentication is required for any API request that requires a user context, for example: sending a Tweet or Following another User.


#10

Hey @bonnell

Thank a lot for support,

We have discussed in above “First Thread” i am creating framework and i am not able to use fabric kit so i used old TwitterKit framework and it contain only two method for login Window for twitter:

    • (void)logInWithCompletion:(TWTRLogInCompletion)completion;
    • (void)logInWithViewController:(UIViewController *)viewController completion:(TWTRLogInCompletion)completion;

So there is no Loginwithmethod option like we have in fabric so is there any solution or framework that i can use and set login window for system app.