Embed a framework in a cocoapod framework project - ios

I have an application which is using a library installing via Cocoapods.
In that library project, now I have embedded a framework and it build successfully.
Back to my application when I do pod install then build. The library pod show me error:
No such module 'embedded framework'
in the swift file which I used that framework.
I have research and try many solutions but still not work. How can I bring the embedded framework along with my library project?
Add link binaries:
Add copy files:
Still error in the main application when compile:

Go to your Xcode project General Tab. Check for Embedded Binaries.
Now, Add your missing lib. or framework here.
Check in screenshot below.
Clean and run the project.

Related

Cocoa Touch Framework with CocoaPods dependencies

I'm trying to create a Cocoa Touch Framework.
I created a Cocoa Touch Framework
I ran pod init
I added our own CocoaPod to this, which has some dependencies itself as well.
I ran pod install.
Now when I try to build the framework (I open the .xcodeproj) I get the following warnings for each dependency.
ld: warning: directory not found for option '-F/Users/jeroen/Library/Developer/Xcode/DerivedData/OurFramework-culynvrparvtfjbjlitmammotpkf/Build/Products/Debug-iphoneos/Alamofire'
I get the following errors:
ld: framework not found Alamofire
error: Resource "/Users/jeroen/Library/Developer/Xcode/DerivedData/OurFramework-culynvrparvtfjbjlitmammotpkf/Build/Products/Debug-iphoneos/FirebaseFirestore/gRPCCertificates-Firestore.bundle" not found. Run 'pod install' to update the copy resources script.
I expect that this is because the CocoaPod files are not copied to the right place. Is that correct?
What could I do to make this work anyway?
The reason I want to do this is the following:
I have a CocoaPods project which is a regular Xcode project with only Swift classes and some view controllers. We want to make this available as closed source. So I'm hoping that including this pod in a Cocoa Touch Framework would still make all public functions of its pods available to the user.
If there are other suggestions, they are welcome!
Thanks in advance.
The first point I got is you used .xcodeproj after pod installation. Please note that once you install pods there is one more file is created with an extension .xcworkspace you need to use this file to open project and your future work should be done in this file.
Okay, so all the problems I had with setting this up seemed to be Xcode-related.
Basically what I did to get this working is the following:
Create a Cocoa Touch Framework through Xcode's File > New > Project ....
Using terminal, navigate to the framework's root folder (the folder with the YourFramework.xcodeproj-file).
Run pod init.
Add the necessary CocoaPods to the Podfile.
Run pod install.
Make sure you close the YourFramework-project that's probably open in Xcode.
From here on my problems started occurring. Opening the YourFramework.xcworkspace worked, but in the left-side navigator of Xcode, I could only expand the Pods-project, not the Framework-project; it seemed to be empty. Building didn't work either.
To solve this (So, just the regular steps to solve Xcode problems):
Close Xcode.
Delete derived data.
Open the YourFramework.xcworkspace again.
Clean the build folder.
Now it maybe builds, or not. In my case it didn't and got 100s of problems related to the Swift language being unavailable. I created a framework without any source files, just imported CocoaPods. To solve this create a Swift file in the framework which imports at least Foundation.
Now it should build.

How to manually import third party Swift framework into Swift iOS project?

I am trying to import and use the OAuthSwift library in the Swift iOS project. I followed their directions:
Drag OAuthSwift.xcodeproj to your project in the Project Navigator.
Select your project and then your app target. Open the Build Phases panel.
Expand the Target Dependencies group, and add OAuthSwift framework.
import OAuthSwift whenever you want to use OAuthSwift.
After completing these steps, importing OAuthSwift using import OAuthSwift causes the error No such module 'OAuthSwift' and the project fails to build.
I have tried the following steps, based on a number of other SO questions about similar issues:
Clean and rebuild
Add the OAuthSwift framework to many different combinations of Build Phases > Target Dependencies, Build Phases > Link Binary With Libraries, Build Phases > Embed Frameworks, and General > Embedded Libraries
Set Build Settings > Search Paths > Framework Search Paths and Build Settings > Search Paths > Library Search Paths to $(SRCROOT) and recursive.
Verify that my deployment target matches the deployment target of the OAuthSwift Xcode project.
I have tested this using the latest version of OAuthSwift from their master branch using a git submodule, as well as manually downloading and importing each of the two latest tagged versions (0.6.0 and 0.5.2).
I have also created a brand new Xcode project, imported OAuthSwift as above, and encountered the same error.
Finally, I also tried importing a different Swift Framework (Alamofire), following the steps as stated on the README at https://github.com/Alamofire/Alamofire. This caused the same error as well: No such module 'Alamofire'.
I am using:
OSX 10.11.6
Xcode 7.3.1
Swift 2.2
I'm still fairly new to Xcode and the Swift module system, so any help or suggestions is appreciated.
Your life will be a lot easier if you import the framework using CocoaPods. If you haven't used them before, it's really easy once you get set-up. You use Ruby Gems on the command line to install CocoaPods (sudo gem install cocoapods) and then create a create a pod file using pod init. After this you modify it to include:
platform :ios, '8.0'
use_frameworks!
pod 'OAuthSwift', '~> 0.5.0'
Save the file and run pod install.
Once this is complete you will have to close out the Xcode project and use the newly created .xcworkspace project file (not the .xcodeproj) from here forward.
Here is a link to another post for a secondary reference.
How to install cocoapods?

Custom framework development with COCOA POD

I'm creating a custom framework which uses Cocoa Pod internally. After installing POD I cannot make use of framework using agreegate target.
I added framework project with my application project just by trag and drop it inside Application project and linked it using Aggregate Target. After installing POD with custom framework, I can not make use the above mentioned way to link framework with my aggregate project.
Thanks
If you are developping a standalone librairy, something that users will have to add manually in their project, you CANNOT use cocoapod in your librairy project. No way! You'll have to provide your users with an install procedure indicating all extra step (framework install, project settings modification, pods to install) they'll have to follow to get your framework up and running.
This is why nowaday people use dependency manager like cocoapods. It makes it easier for users to install their product and install automaticly the dependencies.
If you are planning to distribute your framework thru pod, then follow the recommanded step to create your project architecture and reference in the example project (that uses pods) your dependencies.

How to use openCV in iOS? I just can't import the framework correctly

How can I add opencv2 correctly to Xcode?
I just download from the website the opencv2.framework.zip,
and then I unzip the opencv2 ,finally appears opencv2.framework.
and then I build an xcode project, choose ios single view.
then I try to add opencv2.framework to the project
then I compile the project, It shows that:
what's happening here?I'm new here and I just can't figure out a solution. Thank you very much for your help!
I've put together a guide to use OpenCV using the .framework file (if you prefer it over cocoa pods as suggested above) you may have a look here. It works for both OpenCV2 iOS and the newer OpenCV3 iOS.
http://kurtjacobs.weebly.com/computer-vision/up-and-running-with-opencv-30-for-ios
Good luck!
You can download the opencv2 .framework, then in Xcode project, click the targets selected build phases. Click link Binary with libraries, click add other and select the .framework, clang.
Try and use Cocoapods to install it. If you haven't used Cocoapods before, it is a "CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects." More information is available on its website HERE.
To install OpenCV using Cocoapods, add pod 'OpenCV' to your pod file, and use the command pod install. Please refer to the OpenCV for iOS Cocoapods Readme page (https://cocoapods.org/pods/OpenCV) for more details.

cocoapods integration on existing workspace

I'm new to CocoaPods and was able to use it on some sample project.
Now I'm trying to integrate it into my current working project.
The project is a iOS application project which use target dependency on other some static library I've created which also uses another static library with dependency I created.
So basically it's 3 project nested in each other.
After init&install the Podfile on the main project I can't build the project
getting the error: Library not found for -IPods-MYAPPNAME.
Any ideas what should I do to integrate an existing project with many frameworks and dependencies to CocoaPods or is it a lost battle?

Resources