The problem:
I have a dynamic framework, which uses Firebase added by cocoapods. And I also have the App, which uses this dynamic framework. But when I try to build the project I got error Missing required module Firebase.
I tried the following:
remove derived data + clean
re-install pods
add 'Import paths' to the build settings (in this case I got error 'Library not loaded' in runtime)
My podfile:
target 'Project' do
...
end
target 'Framework' do
pod 'Firebase/Core'
pod 'Firebase/Auth'
end
The Framework is added to Embedded binaries and Linked Frameworks and Libraries.
For anyone still having this issue, doing this solved it for me.
Add this to your test target build settings.
HEADER_SEARCH_PATHS = "${SRCROOT}/Pods/Firebase/CoreOnly/Sources"
Full discussion can be found on firebase GitHub issues.
you can find HEADER_SEARCH_PATHS in Test Target > Build Settings > Search Paths > Header Search paths.
Just incase you cant find HEADER_SEARCH_PATHS in Build Settings, click the ALL button to show all settings.
Add the following to your test target:
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Firebase/CoreOnly/Sources"
That’s in test target > Build Settings > Header Search Paths.
After adding test target, running:
pod install
and add to:
HEADER_SEARCH_PATHS = $(inherited)
fixed for me.
On Framework Search Path pod put all pod projects path automatically.
Of course, to podfile added this after last pod name:
target 'TestTargetName' do
inherit! :search_paths
end
Nothing did help to me until
target 'TestTargetName' do
pod 'Firebase/Storage'
end
I'm not sure what firebase does so I can't run tests (tests do not depend on firebase at all)
Related
I'm trying to integrate Firebase into my app, but as soon as I'm building it after I thought I finished my install I get:
Redefinition of module 'Firebase'
as well as
Could not build Objective-C module 'SwiftOverlayShims'
which I have no idea what that means but I'm assuming its a result of the first.
My podfile looks like this:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'app' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'Firebase/Auth'
# Pods for app
end
So I don't think theres anything conflicting there. I saw a solution that told me to go into my Header Search Path and see if my project had multiple Firebase directories, but I have no custom paths, so that wasn't it. Any insight?
EDIT: Here is the exact display from my errors
Uncommenting the platform line in my podfile and changing it to iOS 10.0 did get rid of the error saying "Could not build Objective-C module 'Firebase'" So we have made some progress.
Here is the path when selecting "previously defined here"
From what I can tell, it is only giving me one location. Selecting the redefinition error just gives me the relative path of module.modulemap , so I am assuming that is referring to the same thing. I am also getting multiple warnings like this
Skipping duplicate build file in Copy Files build phase: /Users/me/Library/Developer/Xcode/DerivedData/app-elgcucdextsnzqbtlznbqeulbfks/SourcePackages/artifacts/Firebase/FirebaseAnalytics.xcframework/ios-arm64_i386_x86_64-simulator/FirebaseAnalytics.framework
as well as a couple other frameworks in the ios-arm64_i386_x86_64-simulator directory, so maybe that has something to do with it.
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!
Did anyone managed to integrate FBSDKCoreKit to a custom swift framework with cocoapods (or alternate method)?
When I do this (experiment 1):
target 'MyFramework' do
project 'MyFrameWork/MyFramework.xcodeproject'
pod 'FacebookSDK', :modular_headers => true
end
target 'MyApp' do
workspace 'MyWorkspace.xcworkspace'
project 'MyApp/MyApp.xcodeproj'
inherit! :complete
target :MyAppTests
target :MyAppUITests
end
I get No such module 'FBSDKCoreKit' when compiling the framework (same applies when setting modular_headers => false.
I have also tested use_frameworks! as follows: (experiment 2):
target 'MyFramework' do
project 'MyFrameWork/MyFramework.xcodeproject'
use_frameworks!
pod 'FacebookSDK'
end
target 'MyApp' do
workspace 'MyWorkspace.xcworkspace'
project 'MyApp/MyApp.xcodeproj'
inherit! :complete
target :MyAppTests
target :MyAppUITests
end
But then I get this error:
dyld: Library not loaded: #rpath/Bolts.framework/Bolts
Referenced from: /private/var/containers/Bundle/Application/***/MyApp.app/Frameworks/MyFramework.framework/MyFramework
Reason: image not found`.
Note: When I add the FacebookSDK to MyApp (with use_frameworks!) it works, but then, I can't make use of it from within MyFramework (hence useless to me).
I finally found another way to do that, so I dropped Cocoapods.
I stumbled upon the fact that Facebook publishes a Swift package (https://swiftpackageregistry.com/facebook/facebook-ios-sdk).
So I proceeded as follows:
removed pod 'FacebookSDK' from my pod file;
added the above mentioned package for my framework.
And voila!
This is not a duplicate question.
I have been using realm for a long time. Recently I am getting the error of "No such module RealmSwift". But this is happening only in release target scheme not in build target scheme. Is there any particular reason as to why it is not working only in release? I have seen this question at a lot of places but none of those solutions worked for me.
My podfile looks similar to this:
# Uncomment the next line to define a global platform for your project
platform :ios, '12.0'
#use_modular_headers!
inhibit_all_warnings!
def shared_pods
pod 'RealmSwift'
end
target ‘************’ do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for ************
shared_pods
target '************Tests' do
inherit! :search_paths
# Pods for testing
end
end
target '************UITests' do
inherit! :search_paths
# Pods for testing
# shared_pods
end
This is more of a troubleshooting step than a direct answer since I duplicated your issue.
You've been using Realm a while so you know this but for future readers, ensure that any file where you're using RealmSwift includes
import RealmSwift
I just tried your podfile on a new project and am getting weird behavior as well. I replaced your podfile with the following 5 lines and it works correctly.
project 'Realm Test.xcodeproj'
target 'Realm Test' do
use_frameworks!
platform :osx, '10.13'
pod 'RealmSwift'
end
That was a macOS project but it worked equally well with an iOS project. On that project I uncommented #platform :ios, '12.0'
I think this is the issue
inherit! :search_paths
That lets the target know about the search paths but does not link them in. I would suggest changing that to
inherit! :complete
Which appears to be working in my project.
Oh - for completness, I ran into this once as well and the solution was
add the parent path of RealmSwift.framework (i.e., the containing
directory) to your framework search paths.
This is a common Realm bug which occurs in Xcode after pod install. Clean and Build the project once, the bug should go away!
I have a Swift project with some local frameworks that are linked with the main app. One of the frameworks requires a CocoaPod that the main project also requires elsewhere. Obviously I'd only like one copy. That seems to work fine, but the unit tests are getting confused. This is a slightly simplified version of the Podfile:
platform :ios, '11.0'
inhibit_all_warnings!
use_frameworks!
# The main app target
target 'TheApp' do
pod 'Instabug'
target 'TheAppTests' do
inherit! :search_paths
pod 'OHHTTPStubs/Swift'
end
end
# A framework target that's linked by TheApp
target 'Logging' do
pod 'Instabug'
target 'LoggingTests' do
inherit! :search_paths
end
end
I believe I'm supposed to nest the test targets inside their subject. TheApp imports Logging. Both import Instabug. TheAppTests has a host application of TheApp. LoggingTests has not host application.
I get Pods-TheApp, Pods-TheAppTests, and Pods-Logging the way I expect. Sometimes I get Pods-LoggingTests and sometimes I get Pods-Logging-LoggingTests. (This turns out to be tied to the inherit setting. If it's not set, then I get Pods-Logging-LoggingTests; if it is set to search_paths then I get Pods-LoggingTests.)
I'm often getting errors that Instabug isn't copied into the LoggingTest bundle, or I get errors that Instabug has been processed twice. The app itself seems to work fine. It's just that unit tests fail. (There are several other local frameworks that don't have any dependencies, and I don't list them in the Podfile.)
Note that all the framework targets live in one xcodeproj.
I suspect I'm just writing the Podfile incorrectly. Is there a canonical way to handle local (non-pod) frameworks that have their own tests and their own dependencies that match the app's?
This is CocoaPods 1.7.0. I had the same issue with 1.6.2.
I faced the same issue and I personally found it much easier to manage pods in a linear way and creating helper methods for referring each pod. This way when you share a pod among projects, you update the pod version only in one place:
platform :ios, '11.0'
inhibit_all_warnings!
use_frameworks!
##
## Group pods
##
def alamofire_pods
pod 'Alamofire', ~> '4.0'
end
def snapkit_pods
pod 'SnapKit', '~> 4.0'
end
#
# Now, lets create all subprojects and main project pod dependencies
#
target 'MySubproject' do
project 'rel_path_to/subproject.xcodeproj'
alamofire_pods
target 'MySubproject Tests' do
inherit! :complete
end
end
# Following same pattern for all other subprojects
target 'MainProject' do
project 'Mainproject.xcodeproj' # path to main project
snapkit_pods
alamofire_pods
target 'Mainproject Unit Tests' do
end
end
target 'Mainproject UI Tests' do
# specific pods for your UI Test
end
This approach worked the best and helped with running also subproject tests in the project.
Rule of thumb, also always make sure to remove old pod references from your project. That was causing issues in my case and throwing errors when building for unit tests I believe for subprojects. Cocoapods doesn't clean the old pod target references from your project's build phase.
Note pod install shouldn't change the pod target name if you don't change anything in your podfile.
You can create abstract targets that your real targets inherit from, thereby having 2 sets of dependencies, some of which are shared.
This is what I do:
project "NSScreencast/NSScreencast.xcodeproj"
use_frameworks!
abstract_target "NSScreencast-Base" do
pod "Kingfisher"
pod "R.swift"
target "NSScreencast" do
platform :ios, "11.0"
pod "AppCenter"
pod "FXReachability"
pod "Colorkit"
pod "SVProgressHUD"
pod "1PasswordExtension"
pod "OneSignal", ">= 2.6.2", "< 3.0"
pod "Reveal-SDK", :configurations => ["Debug", "Debug-LocalServer"]
end
target "OneSignalNotificationServiceExtension" do
platform :ios, "11.0"
pod "OneSignal", ">= 2.6.2", "< 3.0"
end
target "NSScreencastTV" do
platform :tvos, "10.0"
end
end
This allows me to use the shared pods in multiple targets (here, iOS and tvOS) and have specific ones for each target as well.
Does this solve your problem?