Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include file in Podfile

Tags:

ios

cocoapods

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?

like image 783
iCaramba Avatar asked Dec 18 '22 14:12

iCaramba


1 Answers

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
like image 176
Anders Avatar answered Jan 04 '23 11:01

Anders