在 Nativescript 应用程序中修改 Podfile

Mac*_*val 2 ios nativescript share-extension podfile

我已在我的Nativescript应用程序中添加了一个共享扩展,该扩展需要一个 Pod。

因此,我需要修改 Nativescript 应用程序的 Podfile,以使用所需的 Pod 来定位我的共享扩展,如下所示:

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
Run Code Online (Sandbox Code Playgroud)

这里的问题是,每次运行项目时,Podfile 都会被 Nativescript 覆盖。

那么,有一种方法可以“阻止”Podfile 以防止 Nativescript 覆盖它,或者可能有一个“钩子”用于在 Nativescript Podfile 生成后向 Podfile 添加自定义内容?

我该如何继续?

谢谢。

agr*_*ton 5

为了修改构建时在平台文件夹中生成的 Podfile,您可以在 App_Resources/iOS 文件夹中添加 Podfile。

App_Resources/iOS 文件夹中的 Podfile 将与在platforms 文件夹中生成的 Podfile 合并。