How to add a framework to iOS library project? - ios

I have very little experience in native iOS development but my current job is to wrap some specific native iOS framework to use it in React Native.
Preliminary data: common React Native tools generate an empty iOS library project and an example iOS app project that utilizes this library.
First I've tried to add the needed framework directly to the example app using CocoaPods - and it works fine, the framework became a part of linked libPods.a file, then if I add
#import MyTargetFramework;
to AppDelegate.m I can access different methods of the framework from it.
Next I switched to my iOS library project, applied the same setup (created a Podfile, added the same pod MyTargetFramework to it), then added the same #import MyTargetFramework to *.m file - but got a build error:
Module 'MyTargetFramework' not found
Also I've noticed that there is no libPods.a for iOS library project, all the pods are merged to a Pods.framework instead.
So my question is - what am I doing wrong? Why does it work for iOS app project, but not for iOS library project? How can I properly link my target framework to my own iOS library? I've already spent some time googling, but found nothing about app vs lib differences from this point.

Related

Integrate Firebase Crashlytics (beta) SDK in iOS project without PODS

I am integrating FrirebaseCrashlytics SDK in tvOS and iOS without cocopods. I downloaded their xcFramework. But I can't use the xcFramework as the project is not compatible so I drag and drop ios-armv7_arm64 framework to project and added Firebase.h and module.modulemap (my project uses both objc and swift). Also, I specified the Firebase.h in the bridging header. I get below error when I build.
Showing Recent Errors Only
/Users/xxxxx/Code/ios/tvOSApplications/App/App/Firebase.h:15:9: 'FirebaseCore/FirebaseCore.h' file not found
Showing Recent Errors Only
/Users/xxxxx/Code/ios/tvOSApplications/App/App/App-tvOS-Bridging-Header.h:27:9: Could not build module 'Firebase'
Multiple problems to address (based on instructions in the README at the base of the distribution:
The zip distribution requires Xcode 11 which supports xcframeworks
The zip distribution only supports iOS. tvOS is only distributed via CocoaPods
All Firebase installations require the xcframeworks in the Analytics folder to also be installed.
I am able to get firebasecrashlytic .framework files without cocopods using Carthage. I copied files to project and it works in iOS project. I am looking for a similar solution for tvOS
Recently I had a similar requirement of supporting Firebase on both iOS and tvOS. As the frameworks are available only on iOS and not on tvOS. I could not integrate Frameworks. So the solution I followed is adding of Source files provided in https://github.com/firebase/firebase-ios-sdk corresponding to the required modules that are needed for enabling Firebase Crashlytics.
This solution worked for me and able to see the crashes. Let me know if you need more information
I got Firebase Crashlytics working for tvOS without Cocoapods or XCFramework bundles. Basically, you just need to bring over the source files, set the header search paths, and set all the required preprocessor macros. You can read the story here.
Thanks for the hint Gangadhar!

Could adding a framework to an iOS project block/hide access to other files in the project?

After adding the Dropbox SDK Framework to my Xcode project (iOS) my project fails to build due to errors shown in image 1 below:
Prior to adding the Dropbox Framework, or reverting to the previous commit, results in the project building and running with out issue. I have also tested the same Dropbox SDK Framework package in a seperate demo project to ensure it is not corrupted - and that demo project builds and runs just fine, accessing the Dropbox SDK as expected.
Is it possible that the Dropbox SDK Framework is hiding or blocking access to the GLKit Framework within my main project?
Or is there something else at play here? The second error shown in screenshot claims the bridging header also 'Failed to import' which is an error I have not seen before, usually it is 'not found'.
The Dropbox SDK Framework is being added by drag-and-dropping into Xcode and checking the copy if needed box. Immediately after adding the Dropbox SDK Framework the project no longer builds and reports these errors.
I am answering my own question for anyone else who might have similar problems. While I did not find the root cause of the problem, I did get around it with the following solution.
I ended up removing all third party frameworks from my project which were:
ResearchKit Framework
Dropbox SDK Framework
Charts Framework
And in addition I removed all the XCode supplied frameworks from the project in the left hand file list: 'Project Title -> General -> Linked Frameworks and Libraries'
I then installed and setup CocoaPods with the project, and used CocoaPods to install and manage my third party frameworks (ResearchKit, Dropbox SDK and Charts)
The project is now able to build and run successfully and has access to the GLKit framework along with all other XCode supplied frameworks, bridging header and Dropbox SDK.
I assume this issue was due to a setting in XCode that was preventing access to GLKit after the Dropbox SDK had been added, and using CocoaPods to manage the integration of the third party frameworks skirted this issue.
If anyone has any further insight I'd be very interested to hear you explanation.

How to install Fabric.IO for a iOS iPhone app built using ionic?

Recently, I have managed to try out Fabric.IO with a iOS iPhone app project built using native iOS framework in Swift.
That worked successfully.
I then attempted to try out Fabric.IO for another iOS app built using ionic.
What I tried
I created a new xcodeworkspace.
I ran ionic build ios which generated a brand new xcodeproj file.
I installed Fabric
I then added the Run Script Build Phase
I installed Crashlytics and then added the lines of code under AppDelegate.m
Then I incurred nearly 20 errors after that.
My questions
is it possible to use Fabric.IO for an iOS iPhone app built using ionic?
if possible, how do I get past the 20 over errors I have incurred?
Those are C++ library symbols; you need to link against the following libraries and frameworks:
libc++
libz
SystemConfiguration.framework
Security.framework
Which can be added via Link with Libraries and Frameworks.

iOS Framework which can support iOS7

I have very simple requirement for my iOS SDK
-Support iOS 7 and above.
-Include some swift code to my SDK
Problems:
-With iOS 8, Xcode allowed us to develop cocoa touch frameworks, but they can only be run on iOS 8 and above.
-If I create a static library, I cannot include swift code.
-I was using using Real Framework, but Real Framework does not get installed with Xcode 7.
So, What does a poor developer do ?
You can always have an alternative distribution method for your SDK for users that are targeting iOS 7.
You can offer an SDK in a single concatenated file, that is simply merging all your project source files, which user can drop into project tree and compile together with all the other source files. This applies only when you have either Swift-only or Objective-C only SDK
If SDK user uses workspaces, he may embed your SDKs .xcodeproj directly in his project
Anyway both methods require source code distribution as the user needs to compile the code from within his project. Dependency maintenance is also more difficult.
For a reference you can check how it is done in:
https://github.com/SwiftyJSON/SwiftyJSON
It is a Swift library, but integration with iOS 7 based projects is the same.
I could not find any solution for this. I compromised:
I am NOT using swift code.
I am distributing static library (.a file and a .h header file) instead of a framework. (this is to support iOS 7)

Xcode won't archive Swift iOS app with a Swift framework as a separate target. How can this be fixed?

I have an iOS app that I've created using Swift. Since I have a widget in my project and I want to share code between my widget and my app, I have a Swift framework also as part of my project. I can successfully build my app. First I have to build the framework, then I can build the app. However, when I try to archive the app for distribution, it fails with two errors.
module.modulemap: Header '{My Framework Name}-Swift.h' not found.
Could not build Objective-C module '{My Framework Name}'.
I have three targets in my app, an app, widget, and framework.
The framework has a collection of Swift files, as well as an Objective-C header with these contents:
#import <UIKit/UIKit.h>
FOUNDATION_EXPORT double XScheduleKitVersionNumber;
FOUNDATION_EXPORT const unsigned char XScheduleKitVersionString[];
My Mac is running OS X 10.10.2. Xcode is version 6.3. My app is for iOS 8.0+. The full content of the project I'm working on is open-source and available at https://github.com/Cin316/X-Schedule.
I have run into this frustrating problem before myself. It seems that with pure Swift framework targets the Objective-C header file causes intermittent or strange build errors (Xcode bug?). It seems counter-intuitive but part of the solution at least is to either change the header file from public to project or simply remove it from the build target. I wish I had a better explanation as to why this works!
I have forked your project and created a build (that works on my machine at least) here: https://github.com/acwright/X-Schedule
Hope this helps!

Resources