Include file in Podfile - ios

I have an app that consists of many modules which are linked using cocoapods. The linked modules are detected at runtime. Now I want to be able to add and remove modules from the buildserver. What I need to do now is remove or add dependencies to the Podfile before installing.
I think it would be very nice if I could write the depencies in a separate file per target and include those in the Podfile. That way I don't need to modify the Podfile when building. I'm looking for something like the #include preprocessor directive in C but I learned that the include and require functions in ruby work much different. My best success so far was to try loadbut it fails with Invalid 'Podfile' file: undefined method 'pod' for main:Object..
Is there any possibility to include a file?

Not sure if this is supported or not, but it does work if you create a function in your module file which is called from the main Podfile.
Podfile:
platform :ios, '9.0'
use_frameworks!
load 'ModulePods.rb'
abstract_target 'CommonPods' do
module_pods
pod 'SAMKeychain'
target 'Target' do
pod 'RealmSwift
end
end
ModulePods.rb:
def module_pods
pod 'ReachabilitySwift', '4.1.0'
end

Related

Argument list too long: recursive header expansion failed

I have a React Native application that did compile absolutely fine.
After installing react-native-sentry and automatically linking via react-native link, I am faced with this problem:
Showing Recent Issues
Argument list too long: recursive header expansion failed at /Users/dan/Sites/app/node_modules/react-native-intercom/iOS/../../../ios/Pods/React/node_modules/exit-hook.
This error occurred after I ran pod install
Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'app' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for app
pod 'AppCenterReactNativeShared', '~> 1.4.0'
pod 'SentryReactNative', :path => '../node_modules/react-native-sentry'
platform :ios, '9.0'
target 'appTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'app-tvOS' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for app-tvOS
target 'app-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
I've not modified the RNIntercom project at all, this problem always occurs after I try to install a new library via cocoa.
I ran into a similar issue and had to go in and remove a few header search paths, as described here:
https://facebook.github.io/react-native/docs/0.60/troubleshooting#argument-list-too-long-recursive-header-expansion-failed
Argument list too long: recursive header expansion failed
In the
project's build settings, User Search Header Paths and Header Search
Paths are two configs that specify where Xcode should look for #import
header files specified in the code. For Pods, CocoaPods uses a default
array of specific folders to look in. Verify that this particular
config is not overwritten, and that none of the folders configured are
too large. If one of the folders is a large folder, Xcode will attempt
to recursively search the entire directory and throw above error at
some point.
To revert the User Search Header Paths and Header Search Paths build
settings to their defaults set by CocoaPods - select the entry in the
Build Settings panel, and hit delete. It will remove the custom
override and return to the CocoaPod defaults.

Pods with multiple targets getting error?

Alright, Ive seen this problem in a lot of places but I cant find a clear solution - they all seem to be pretty convoluted. I am trying to add pods to a Message Extension. I get this error when doing the following and running pod install - this happens as soon as opening and trying to run the workspace:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'LaunchPack' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for LaunchPack
pod 'lottie-ios'
end
target 'MessagesExtension' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for MessagesExtension
pod 'lottie-ios'
end
Here I pod to both targets and per solutions like https://www.bountysource.com/issues/35748866-missing-embed-pods-build-phase-for-messages-extension-target I have manually added the library (Lottie) to the Link Binaries with Libraries section of BOTH targets:
The link above describes "The issue can be fixed by ensuring that the framework is weakly linked and manually adding a "Run Script" build phase for the -frameworks.sh script"
however I don't understand what they mean by that. Where I can I link the framework other than where I have already?
How can I add pods to my MessageExtension?
I have faced the same issue when adding pods for multiple targets what I did was uninstalled and deleted all the pods file first. Then create multiple targets and after that add the pod file and installed it and works fine for me.

Including a pod inside a framework target: file not found

I'm using framework targets (for better code reuse and IB_Designables), and I've already had a framework target working perfectly. I've decided to move some other classes to a framework target too.
I've set up the pods (just a single one in this case), but whenever I try to include the pod I'm getting not found error.
No change if I try to use the modules approach too:
The problem is that I've already got another framework too, with the same settings (cross checked all the compiler settings/linker flags/build phases etc) and that framework has no issue importing its pods.
Here is my podfile (TUComponents is the working on, TUModels is the failing one):
[...]
target 'TUComponents' do
pod 'AHKNavigationController'
pod 'TTTAttributedLabel'
use_frameworks!
end
target 'TUModels' do
pod 'JSONModel'
use_frameworks!
end
Even weirder; Xcode has no problem code-completing importing the JSONModel/JSONModel.h header (or JSONModel in case of module #import). But when I try to compile, it fails.
What might be wrong with my configuration?
UPDATE: If I give up using frameworks in pods and use regular old static library, and set allow non-modular includes in frameworks to YES, I can build. But I have no idea why I can't build when using Pod frameworks.
Maybe try solution from: https://www.natashatherobot.com/cocoapods-installing-same-pod-multiple-targets/
platform :ios, '9.0'
use_frameworks!
# My other pods
def testing_pods
pod 'JSONModel'
end
target 'TUComponents' do
pod 'AHKNavigationController'
pod 'TTTAttributedLabel'
testing_pods
end
target 'TUModels' do
testing_pods
end
From iOS - Build fails with CocoaPods cannot find header files :
Make sure your Podfile includes link_with on targets missing a config file. Cocoapods only sets the first target by default otherwise. e.g.
platform :osx, '10.7'
pod 'JSONKit', '~> 1.4'
link_with 'Pomo', 'Pomo Dev', 'Pomo Tests'
Restarting Xcode fixed it for me
The following steps worked in my case:
Quit the Xcode n Simulator
Delete Drived data
Again open your project
Clear it

I added pods to an existing file, and it made another project in my workspace

I added pods to an existing workspace and now I have 2 of the same project in my workspace (Both projects ending in IOS). If I delete either one, I lose all references to the project.
Here is what the project tree looks like and the pods file. Anyone have any insight?
This is how the podfile should be
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'Demo8' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'FBSDKCoreKit', '~> 4.16'
end
This is no requirement to specify workspace externally until there is any requirements.

Effectively use a library included with CocoaPods

This is my first attempt with CocoaPods. So far so good, I've been able to include a library create the first workspace with the library that I needed. This is my podfile:
platform :ios, '8.0'
use_frameworks!
target 'SDK-auth' do
pod 'AFOAuth2Manager', '~> 2.2'
end
Now I'm trying to use the AFOAuth2Manager lib inside my project and here is my question... what I've to do to include it? Currently I'm writing something like
#import AFOAuth2Manager;
but I receive this error: Could not build module AFOAuth2Manager
Is this the right way to include the module? or am I doing anything wrong?

Resources