How to use FMDB with cocoapods and swift? - swift

It looks like cocoapods supports FMDB:
pod 'FMDB/FTS'
But even after creating a bridging header I get the following error:
cocoapods bridging header error: 'FMDB.h' file not found
What's up?

Turns out I also needed to add a header search path.
In your target's settings (not project settings) navigate to Build Settings -> Header Search Paths and add the following non-recursive path:
"${PODS_ROOT}/FMDB/src/fmdb"

Related

XCFramework "Cannot load underlying module"

I've built an SDK as an XCFramework, which shares dependencies with the app that uses it. When I build, I'm getting:
...SDK.swiftmodule/arm64-apple-ios.swiftinterface:20:8: Cannot load underlying module for...
This occurs in the Compile Swift Sources action and the break is in the import MySharedDepedency statement in the swiftinterface file
As stated, the SDK in the project as an xcframework bundle. MySharedDependency is fulfilled with cocoapods. use_modular_headers is set in the Podfile, it's modulemap is included in the linker flags (by cocoapods).
Its DOES work if I use the use_frameworks! flag in the Podfile but only with dynamic linkage and for internal politics reasons, I need this to work with static linkage. If I add the :linkage => :static argument, I get the same error as with no use_frameworks! call
I've tried changing the order of the linked frameworks in Build Phases (so that the pods are linked before the SDK framework). I've tried adding recursive header/framework/module search paths everywhere I can find a MyDependency.modulemap...
Yes, I've cleaned caches, deintegrated, clean installed, erased deriveddata, restarted xcode, my machine, ...
Argh! Thanks for any help...
I had the same exactly the same scenario and the same problem
I solved using #_implementationOnly in every file from my xcframework's code like:
#_implementationOnly import Alamofire
After that just rebuild your XCFramework, clean and build your app's project.
It works like a charm without use_frameworks!

Why I cant import the library that in swift file after installing the the dependency in Cocoapods?

I already install this library, XLPagerTabStrip via Cocoapod. My pod file is look like this,and already hit pod install in terminal.
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'MyProject' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for MyProject
pod 'XLPagerTabStrip', '~> 8.0'
end
So everything is completed install,but when I want to import the library in Swift file,it giving an error ->> No such module 'XLPagerTabSript'.
I read a lot of question about this,which mention add the file path of the library to
Build Setting -> Search Paths -> User Header Search Paths. I also already did,but still giving the same error.
What I add in User Header Search Path is something like this:
${SRCROOT}/Users/Myname/Desktop/MyProject/Pods/XLPagerTabStrip
After adding the file path,I clean the project,build the project again,the tried to add in import XLPagerTabStrip to one of my swift file,the error still the same.
Can somebody let me know what is problem actually? Cause I beginner in Ios development,I totally no idea what I doing wrong.
I end up solve it by update my Xcode vesion and insert the file path of the library in inside
Build Setting -> Search Paths -> Framework Search Paths -> (Add the
file path of the library here)
By this I can import the library in swift file without any warning

<CocoaLumberjack/CocoaLumberjack.h> file not found in bridging file

I have a workspace with multiple targets and mixed development with SWIFT and Objective-C. After installing CocoaLumberjack with CocoaPods:
pod 'CocoaLumberjack/Swift'
I can use it my project without any problems. All my targets get compiled except Test target. When I run tests I get "build failed" error within the bridging header file
<CocoaLumberjack/CocoaLumberjack.h> file not found
at:
#import <CocoaLumberjack/CocoaLumberjack.h>
Do you have any ideas how to fix the issue? Thanks!

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.

iPhone libxml2 not found during build

I currently got some errors with libxml2 in my iPhone project. This was working before, after making some changes in my build properties building failed. (libxml2.dylib is added in the build phases)
#import <libxml/tree.h>
#import <libxml/parser.h>
#import <libxml/xmlstring.h>
#import <libxml/xpath.h>
#import <libxml/xpathInternals.h>
I've added the following items to the Build Settings:
Other Linker Flags: -lxml2
Header Search Paths: /usr/include/libxml2
I've tried adding them to the project and targets (at the same time, and switching between them) without any difference.
I also tried adding the following to the Header Search Path:
${SDKROOT}
${SDK_DIR}
Both with no result.
Building fails for:
iPhone device
iPhone and iPad emulator
Anyone have an idea?
I'm using the GData Objective-C client library: http://code.google.com/p/gdata-objectivec-client/
I'm compiling the source files directly into my project and followed all the steps that are given in the wiki. When manually importing the libxml headers again, XCode suggests the following:
#import <libxml2/libxml/tree.h>
Which doesn't work either.
Add ${SDKROOT}/usr/include/libxml2 as a header search path instead of only ${SDKROOT}.
Watch out that you all build targets that need libxml get the extra search path. If you add the path to your project's build settings, all its targets will inherit it and there shouldn't be a problem.
Add libxml2.dylib in Build Phases.
Add TFHpple.m, TFHppleElement.m, XpathQuery.m to Build Phases (Compile Sources).
Add Other Linker Flags: -lxml2 Header Search Paths: ${SDK_DIR}/usr/include/libxml2
in PROJECT --> Build Phases and in TARGETS --> Build Phases.