How to add Cocoa pod dependency to custom framework swift - swift

I am using GVRSDK library pod in my custom framework but if i add this some other project target its not getting import. I am using module map because the library was not getting import in custom framewotk
error: using bridging header with framework target is unsupported.
Compilation Error due to adding private header in umbrella header Include of non modular header inside framework module .
Next i added Module Map File it got imported in Framework swift file. If i
import it in some other swift target it throwing error module not found.

You should speciafied in your Podfile for which target you wanna install your pods
target 'FrameworkName' do
use_frameworks!
pod 'GVRSDK'
end
After that you can add the framework to your app from Build Phases -> Embed Frameworks

Related

Framework import into Swift + Expo cocoapod doesn't find the header

So I have an expo project, which is my main root. I have some native code nested into the project written in Swift and the Expo Module lib. All works fine until I try to import a Framework into it that sits inside the native module.
ExpoApp (with podfile)
NativeModule in swift - (with podspec)
Framework containing header files written in objectC
When I run expo run:ios I get the following error:
#import <XFramework/XDefines.h>
| ^ 'XFramework/XDefines.h' file not found
In the framework I have an umbrella header that imports all the headers with the same namespaces address. This error is coming from one of the other headers.
Is this something that I can set in the NativeModule's podspec?
Tried to add USER_HEADER_SEARCH_PATHS to the podspec in the NativeModule.

Swift Package Manager (package successfully added, but Module not found)

I'm new in Swift. I want to create iOS app that can connect to PostgreSQL database. First I found library https://github.com/vapor/postgresql.git that should be added to my project via Swift Package Manager. Using tutorial I added required library to my project successfully (File -> Swift Packages -> Add Package Dependency):
list of added packages from SPM
But when I try to import this module into my view controller, Xcode shows error that module is not found:
not found
I tried several times to rebuild my project, created new project just for testing this issue. Also I found information about build phases and added this lib as a dependency:
build phases
But I still get error: "No such module PostgreSQL".
Can anyone help me?
I found solution by myself. I compiled C static library "libpq" (can be found in PostgreSQL sources) and added it to my swift project. Included this library by adding special bridging header file. Finally I got what I wanted.
P.S. If someone what to repeat, he or she should know: static C library must be compiled for iOS device architecture (and also in iOS simulator architecture which differs from iOS device arch.).

How to create a React-Native framework using Swift

I have a react native component written in Swift, and I want to extract it as a framework so other project/people can use it easily.
First I created a new iOS project Foo, added a framework target,
then added source files. Finally, I built it.
It failed because:
Bar.swift:[lineNumber]: Use of unresolved identifier 'RCTConvert'
RNBarManager.swift:[lineNUmber]: Use of undeclared type 'RCTViewManager'
Attempt 1:
I ran react-native link, but nothing changed.
Attempt 2:
Drag React.xcodeproj to Foo project and add libReact.a to Link
Binary With Libraries.
Add $(SRCROOT)/../node_modules/react-native/React to Header Search Paths.
But it doesn't work. The error still remains.
Attempt 3:
I was thinking maybe Swift doesn't recognize these files.
So I added Foo-Bridging-Headers.h like I did in a React-Native App, which contains the following code:
#import "React/RCTBridge.h"
#import "React/RCTViewManager.h"
#import "React/RCTUIManager.h"
#import "React/UIView+React.h"
#import "React/RCTBridgeModule.h"
I also added Foo-Bridging-Headers.h to Build Settings->Swift Compiler - General->Object-C Bridging Header,
Still I got an error.
using bridging headers with framework targets is unsupported
It seems bridging headers are not allowed here.
Attempt 4:
I tried to add these imports to Foo.h,
but got an error again.
Foo.h:21:9: Include of non-modular header inside framework module 'Foo'
What should I do to compile successfully?
This seems like an issue with the cocoa pods required for linking React to your project.
Try running pod install in your project directory using terminal and then try to build.
The linking happens in the hosting app, and not in the framework you've made. That will just need the headers.

How to link CocoaImageHashing pod with Swift project (dyld: Library not loaded)

I'm trying to use the CocoaImageHashing pod from a Swift project so that I can do some perceptual hashing for image duplicate detection.
I setup the workspace following the CocoaPods instructions and attempted to run the default Hello World swift file.
dyld: Library not loaded: #rpath/CocoaImageHashing.framework/Versions/A/CocoaImageHashing
Referenced from: /Users/sarge/Library/Developer/Xcode/DerivedData/PHashTest-cdongczzcrynrfclysczwalanrlq/Build/Products/Debug/PHashTest
Reason: image not found
(lldb)
My Podfile is:
platform :osx, '10.12'
target 'PHashTest' do
use_frameworks!
pod 'CocoaImageHashing', :git => 'https://github.com/ameingast/cocoaimagehashing.git'```
end
I tried commenting out the use_frameworks! line in case this was some kind of dynamic library problem. I then get a build error.
Framework not found CocoaImageHashing
My General > Linked Frameworks and Libraries does include the CocoaImageHashing framework. I see Xcode building files from it during a build.
Is there something I have to do to get the CocoaImageHashing pod to build the dynamic library that Swift expects? Or do I need to not use Swift because CocoaImageHashing has to be included dynamically.
(I'm very unfamiliar with Swift so I don't know what to look for)
You should include the framework at General -> Embedded Binaries as well.

Static framework linked to Cocoapod not found in Main project

I'm trying to add a static framework (Moya) to my private Cocoapod project through Carthage.
My goal is to include Moya as a static framework in my private Cocoapod (SwiftModel) and use Moya as well in my main project (as SwiftModel has a dependency to it).
I've added Moya to my framework by doing the following steps:
link framework in podspec file
s.vendored_frameworks = 'SwiftModel/Carthage/Build/iOS/Moya.framework'
add Moya to private framework (Link Binary With Libraries)
So inside my Pods project it looks like this:
Trying to add the path to "Framework Header Search Path" did not made any changes. I've tried to add it in the main project and in pods project.
When just building the private pod everything works fine and Moya is recognized. However if I want to build the main project (that includes my private pod) I'm always getting this error:
framework not found Moya for architecture arm64
As your error states that
framework not found Moya for architecture arm64
It means that Moya is not available for arm64 architecture, but your main project has following architectures;- arm64, armv7, armv7s. Remove the arm64 from your main project's valid architecture.
Also try to add -Objc in other link flags.
Try adding libz to the link library section of you project
iOS Support matrix:-