我对Cordova很新,我想知道是否有办法调整Cordova / Ionic生成的平台代码,而不会妨碍开发过程。
具体要求是将Facebook SDK集成到iOS应用程序,以支持Facebook Mobile App Install广告。集成很简单:只需要添加一行代码即可
AppDelegate.m中的application:didFinishLaunchingWithOptions:
并将Facebook iOS框架添加到Xcode项目中。
目前整个plaforms目录都从源代码管理中排除,因为它是由Cordova在构建期间生成的。如果我要调整AppDelegate.m,我将不得不将其添加到源代码管理中。那么Ionic应用程序的后续更改是否会导致与Xcode项目的合并冲突?如何在不破坏过程的情况下将我的小更改集成到Xcode项目中?
注意:我确实在寻找插件作为解决方案,但我找到的插件来自with complications of its own。看来科尔多瓦无论如何都不会在application:didFinishLaunchingWithOptions:
中提供钩子。
答案 0 :(得分:12)
You should create your own plugin instead of making changes into the AppDelegate.m
You can listen the UIApplicationDidFinishLaunchingNotification
on the pluginInitialize
an put the code there
- (void)pluginInitialize
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(finishLaunching:) name:UIApplicationDidFinishLaunchingNotification object:nil];
}
- (void)finishLaunching:(NSNotification *)notification
{
// Put here the code that should be on the AppDelegate.m
}
The plugin.xml need the onload true to call the pluginInitialize
<feature name="yourPluginName">
<param name="ios-package" value="yourPluginClass" />
<param name="onload" value="true" />
</feature>
答案 1 :(得分:1)
答案 2 :(得分:0)
您可以添加app appate文件,与www文件夹中的文件不同,该更改不会消失。您可以在Xcode项目文件夹中进行更改。