I am trying to create a framework out of the app that is using Google maps now.
This is my FuelMap framework podspec
target 'FuelMap' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'GoogleMaps'
end
podspec:
Pod::Spec.new do |s|
...
s.dependency 'GoogleMaps'
s.dependency 'Google-Maps-iOS-Utils'
end
Then, I have a regular project which has this pod file
target 'Mock' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'FuelMap', :path => './FuelMap'
end
Since the regular project is using use_frameworks
I keep running into this error whenever I do pod install
The 'Pods-Mock' target has transitive dependencies that include static binaries:
Is there a work around, so that I can have the library file from GoogleMap Ios statically in the touch framework and then add them as a reference in the pod spec file. So the error would be avoid?
Related
Using the swift package manager, I have a swift package included in my project and I would only like it to be available in the test target and ui test target. How can I choose the target which has access to the swift package?
the easiest way would be to use cocoapods
your podfile would look like this
# Uncomment the next line to define a global platform for your project
platform :ios, '13.0'
target 'MyApp' do
# Comment the next line if you don't want to use dynamic frameworks
#use_frameworks!
#These are the main app frameworks
pod 'Alamofire'
# Pods for MyApp
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
# here would be your testing frameworks
pod 'MyTestFramework'
end
target 'MyAppUITests' do
# Pods for testing
# and here your UI tests framework
end
end
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?
I'm embedding frwkproject.xcodeproj product (frwkproject.framework) in the mainproject.xcodeproj project.
I am trying to use Firebase Library in the frwkproject.framework only. Using this cocoa pods:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
workspace 'frwkproject.xcworkspace'
abstract_target 'Shows' do
pod 'Toaster'
target 'frwkproject' do
project 'frwkproject/frwkproject.xcworkspace'
pod 'Firebase/Core'
pod 'Firebase/Crash'
end
target 'mainproject' do
project 'mainproject/mainproject.xcodeproj'
end
end
In the mainproject project I have imported the framework with:
import frwkproject
And this error appears: "Missing required module Firebase"
Importing the cocoa pods library in both projects avoids this problem. Like this:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
workspace 'frwkproject.xcworkspace'
abstract_target 'Shows' do
pod 'Toaster'
pod 'Firebase/Core'
pod 'Firebase/Crash'
target 'frwkproject' do
project 'frwkproject/frwkproject.xcworkspace'
end
target 'mainproject' do
project 'mainproject/mainproject.xcodeproj'
end
end
But Firebase will crash when imported in both project.
Is it possible to implement Firebase in the framework project only?
Ok, got exactly the same problem. Here is how I've resolved it:
added
pod 'Firebase/Core'
in a child project pod target
added
pod 'GoogleToolboxForMac'
pod 'nanopb'
in a main project pod target (these are dynamic pod dependencies of Firebase)
added recursive $(SRCROOT)/Pods/Firebase in main target Build Settings -> Header Search Paths (got that idea from here).
Hope that helps!
I have an existing project written in Objective C which contains private pods. I am writing a new private pod in swift language and need to integrate with existing objective C project as i have to go with Mix and Match approach. When I give "pod install" command i am getting below error
"[!] Pods written in Swift can only be integrated as frameworks; add
use_frameworks! to your Podfile or target to opt into using it. The
Swift Pod being used is: XXXXXNetworkManagerSwift"
Here "XXXXXNetworkManagerSwift" is a new pod written in Swift language. It is a framework template.
Existing private pods are written using static lib templates.
My podfile is as below where i am using XXXXXNetworkManagerSwift as a dependency
Podfiile:-
source 'https://github.com/xxxx/ios-specs.git'
source 'https://github.com/cocoaPods/Specs.git'
platform :ios, ‘8.0’
use_frameworks!
target 'XXXXFoundationFramework' do
podspec :path => 'XXXFoundationFramework.podspec'
end
I have a project in Swift where I use some libraries. When I run on the simulators or on the physical device, it runs perfectly. But by the time I try to archive the project to send it to the store, I receive the following error message:
ld: library not found for -lFirebase
The problem is when I use the XLForm library, which was the last modification I have done to my Podfile.
I am using the .xcworkspace since I started using the CocoaPods, and I have never had any problem before.
My Podfile:
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!
pod 'Firebase', '= 2.5.0'
pod 'Google/CloudMessaging'
pod 'Google'
pod 'Google/Analytics'
pod 'XLForm', '~> 3.0'
target 'Dimmi' do
end
target 'DimmiTests' do
end
target 'DimmiUITests' do
end
The XLForm library does not depends on any other library or framework. Also, I tried to install it manually with no success.
You need to create a bridging header file and import the Objective-C framework through it.
Create a new header file and name it in the following pattern:
ProjectName-Bridging-Header.h
Then add your framework header to it
#import Framework.h
Then add the bridging header to your build settings under Objective-C Bridging Header.