2

I've added a share extension to my Nativescript app, and this extension needs a Pod.

So I need to modify the Podfile of the Nativescript app to target my share extension too with the required Pod, something like this:

target :MyApp do
    platform :ios, '8.0'
    use_frameworks!

    pod 'AFNetworking', '~> 2.0'
    pod '...'
end

target :MyExtension do
    use_frameworks!

    pod 'AFNetworking', '~> 2.0'
end

post_install do |installer_representation|
    installer_representation.pods_project.targets.each do |target|
        if target.name.start_with? "Pods-MyExtension"
            target.build_configurations.each do |config|
                config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'AF_APP_EXTENSIONS=1']
            end
        end
    end
end

The problem here is that every time I run the project, the Podfile is overwritten by Nativescript.

So, there's a way to "block" the Podfile for prevent Nativescript overrides it, or maybe a "hook" for adding custom content to the Podfile after Nativescript Podfile generation?

How can I proceed with this?

Thanks.

Anjali Shah
  • 720
  • 7
  • 21
Macarthurval
  • 178
  • 11
  • Which PodFile you are talking about, your application / plugin can have it's own PodFile, you are not suppose to modify anything within platforms directory. – Manoj Mar 04 '20 at 05:12
  • @Manoj I'm not talking about a plugin, but an app extension, and I'm almost certain that an app extension can't have an independent Podfile. So I need somehow to modify the app Podfile at build time. – Macarthurval Mar 04 '20 at 05:42

1 Answers1

5

In order to modify the Podfile that is generated in the platforms folder at build time you can add a Podfile in the App_Resources/iOS folder.

The Podfile in the App_Resources/iOS folder will be merged with the Podfile that is generated in the platforms folder.

agritton
  • 1,250
  • 11
  • 15