网络知识 娱乐 Flutter开发的plugin中引用的url_launcher升级后,plugin的podspec文件的修改

Flutter开发的plugin中引用的url_launcher升级后,plugin的podspec文件的修改

自己开发的plugin中引用了url_launcher,在plugin升级到null safe后,需要把plugin中引用的url_launcher从5.7.0升级到6.0.20。在升级后,Flutter 工程在run时,在pod install时报插件依赖的url_launcher找不到。

先说最后的解决方案:

在插件的podspec文件中:flutter_plugin_sample/ios/flutter_plugin_sample.podspec

把原来的

s.dependency 'url_launcher'

改成

s.dependency 'url_launcher_ios'

原因是url_launcher从5.7.0升级到6.0.20后,url_launcher的结构发生了变化。

5.7.0的iOS代码在库本身,

6.0.20的iOS代码则不在库本身了,而是引用了url_launcher_ios。

6.0.20库的pubspec.yaml如下:

flutter:

        plugin:

                platforms:

                        android:

                                default_package: url_launcher_android

                        ios:

                                default_package: url_launcher_ios

所以在Xcode工程中能看到的库从 url_launcher 变成了 url_launcher_ios了。

所以如果自己开发的plugin引用了url_launcher,那以在plugin的ios/xxx.podspec中,

需要把对url_launcher的此用改为url_launcher_ios:

原来的 s.dependency 'url_launcher'

改成 s.dependency 'url_launcher_ios'

发现很多plugin在升级到null safe后,工程的结构和url_launcher发生了同样的变化。