I've been using use_frameworks! directive so that I can use some dependencies on my project. If I comment that directive, I get a red message saying
Pods written in Swift can only be integrated as frameworks; this feature is beta. Add 'use_frameworks!' to your Podfile or target to opt into using it.
Today I decided to use Google Analytics for iOS but when running $pod install I get
The 'Pods-MyProject' target has transitive dependencies that include static binaries
Googling around I found out it is caused because of the use_frameworks! directive and I should remove it. So I'm between a wall and a sword, what can I do to be able to work with these libraries?
PS: We are required to manage dependencies using Cocoapods, so including it in a different way is not an option. Also, I don't have a bridging header in my project, but I'm still able to work with libraries using import MyDependency
Related
In order to implement Mapbox SDK, according to official docs (https://docs.mapbox.com/ios/maps/overview/#install-the-maps-sdk,
https://docs.mapbox.com/ios/navigation/overview/), adding Mapbox-iOS-SDK and MapboxNavigation through Cocoapods, always get error, shown bellow.
I thought this is related to the usage of sourcery or SwiftGen which are the parts of project or something else, but this happened on new, clean project also, where inserting SDKs was the first step.
Cleaned derived data for few times,
remove from Podfile versioning for that SDK (pod 'Mapbox-iOS-SDK', '~> 6.0.0' as pod 'Mapbox-iOS-SDK' )
even when SDK is added through CocoaPods, can't find frameworks to add into Link Binary With Libraries
even it says Copy Bundle Resources to be checked, couldn't find what to expect there
Note:
Also tried: successfully added Mapbox and MapboxMobileEvents directly into project, but as I found MapboxNavigation SDK could be implemented only through CocoaPods or Carthage, so I'm stuck here.
I would really appreciate for someone's help, who already have faced this problem.
Multiple commands produce '/Users/x/Library/Developer/Xcode/DerivedData/mbNavigationExample-ctztmwiegsuqkigkucoydhnnoaxc/Build/Products/Debug-iphoneos/mbNavigationExample.app/Assets.car':
1) Target 'mbNavigationExample' (project 'mbNavigationExample') has compile command with input '/Users/x/Desktop/mbNavigationExample/mbNavigationExample/Assets.xcassets'
2) That command depends on command in Target 'mbNavigationExample' (project 'mbNavigationExample'): script phase “[CP] Copy Pods Resources”
I've been working with React Native for about a year, and have always linked native modules either with react-native link or by manual linking, by dragging the .xcodeproj file to the Libraries folder and then dragging the .a file to the "Link Binary With Libraries" section of Build Phases. I'd heard of Cocoapods, and my project does include a Podfile (not sure where it came from), but it wasn't until recently that someone told me I HAD to use Cocoapods in order to link native modules, by doing cd ios + pod install etc.
What I Want To Know:
What's the difference between linking native modules the way I've done it all along, and doing it via Cocoapods? What's the essence of Cocoapods and how does it fit into React Native development vs regular linking?
For manually integrated module most cases you have to link some system files if library have some dependencies but for cocoa pod all dependencies liked automatically
For manually integrated module you need to update library manually but for cocoa pod you can it by just pod install command from terminal
In which case which one is better? when your library need update frequently you should choice cocoa pod but when you want to modify a cocoa pod library you would choice it to integrated manually.
Here is my situation:
I am using CocoaPods but I can't use the "use_frameworks!" directive as it is not compatible with ReactNative
I need to include another team's SDK, distributed as a .framework
This .framework depends on PureLayout, which is available through Pods
Hence:
I installed PureLayout through Pods.
I manually linked the other team's SDK dragging it into Embedded Binaries, as per their instructions
Build fails with error Module 'PureLayout' not found. It seems that the other team's framework isn't able to find the PureLayout module included through Pods.
How can I fix? Remember I can't use_frameworks! in Podfile. Thanks.
I have a very simple swift 3 pod library depending on Firebase pod. It has been created with pod lib create and the only line of code in the library is import Firebase. Still, Firebase does not seem to be detected.
-> FoobarLib (0.1.0)
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
- ERROR | [iOS] xcodebuild: ~/FoobarLib/Classes/Foobar.swift:1:8: error: no such module 'Firebase'
I suppose my .podspec file is not properly configured. I have tried a simple pod dependency with s.dependency Firebase and I have tried to embed the Firebase frameworks in my library. I have played with FRAMEWORK_SEARCH_PATHS, USER_HEADER_SEARCH_PATHS, SWIFT_INCLUDE_PATHS, but I never got something working.
My sample library is hosted on github and the full error log is available on Travis. Feel free to clone it, and test pod lib lint and pod install --project-directory=Example.
I saw this related cocoapods bug report involving cocoapods guys and firebase guys, but there is no working example in it.
What should I put in my .podspec file so:
pod install --project-directory=Example succeeds, and produces a valid XCode project. i.e. I can open it, compile it without further configuration.
pod lib lint succeeds, optionally
Even if you manage to get pod lib lint to pass, you'll run into issues integrating Firebase as a dependency of a dependency because it's currently vended as a static library. FirebaseUI works around this by distributing binaries instead of having CocoaPods build from source, but it's not without its own caveats (i.e. people who use FirebaseUI cannot also use another library that depends on Firebase and correctly resolve the version of Firebase that should be used). The issue you linked discusses this in more detail.
If you would really like to distribute a library that wraps Firebase through CocoaPods, you should follow the same approach, though it's worth noting that pod lib lint fails for FirebaseUI even though it ships anyway.
CocoaPods will soon (as of Oct 2017) add a rule that allows for static frameworks to be built on top of other static frameworks, including closed-source ones. This will make it much easier to build objc libs on top of other closed static objc libs, but Swift static library support is still in the works.
According to this tutorial, we should add use_frameworks! to Podfile in Swift project. But how to use third-party code in .m in the same project?
One possible way is,
Do NOT add use_frameworks! to Podfile
Import header in ...-Bridging-Header.h
Then, I can use third-party code in both .swift and .m file
But when I try to import header in ...-Bridging-Header.h, it just throw *.h file not found error, how to fix this issue?
Past
Up to CocoaPods 1.4.x (included), it was NOT possible to use CocoaPods with Swift code without use_frameworks!.
Present: 1.x.x and above
Nowadays, with CocoaPods 1.x.x (I verified it with 1.4.0), it's common to use use_frameworks! for both Swift and ObjC projects: it allows for a mix of the two languages in any way you want without issues:
You'll be able to use a Swift dependency in an Objective-C project.
You'll be able to use an Objective-C dependency in a Swift project.
Present: 1.5.x and above
Nowadays, CocoaPods 1.5.0 supports integrating swift pods as static libraries. Try it (sudo gem install cocoapods) and enjoy removing use_frameworks! from your Podfile.
Note that for iOS:
Apple requires Xcode 10.1 minimum, which is only well supported starting CocoaPods 1.6.0, so don't bother using older versions of CocoaPods.
Apple will require Xcode 11 minimum in April 2020, for which I would only use CocoaPods 1.7.5 or newer, together with xcodeproj 1.13.0 or newer.