前言

这个纯粹就是个人的总结,若果有疑问请留言

环境配置

  1. xcode 我用的是当前最新的版本 (13.4.1)
  2. uni-app 提供的sdk (去官方下载) 链接 https://nativesupport.dcloud.net.cn/AppDocs/download/ios
  3. hbuilderx (3.5.3)

tip :版本不一样不会有太大的问题

创建插件项目以及配置项目的文件

请见官方文章,说的很清晰,我只说一下文章中没有提到的东西和实际开发中遇到问题,本人不是原生开发,不喜勿喷

https://nativesupport.dcloud.net.cn/NativePlugin/course/ios

  1. 创建插件Framework
  2. 导入查检项目到HBuilder-uniPluginDemo
  3. 配置HBuilder-uniPluginDemo
  4. 确认下支持的版本,现在一般的三方提供的sdk都是支持ios9以及上,这一点文章中没有提到的

页面跳转问题

文章中也有给出结论
https://nativesupport.dcloud.net.cn/NativePlugin/course/ios?id=q-%e5%a6%82%e4%bd%95%e8%b7%b3%e8%bd%ac%e5%8e%9f%e7%94%9f-uiviewcontroller 直接使用这个方法就可以

// 获取当前显示的 UIViewController
+ (UIViewController *)dc_findCurrentShowingViewController {
    //获得当前活动窗口的根视图
    UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController;
    UIViewController *currentShowingVC = [self findCurrentShowingViewControllerFrom:vc];
    return currentShowingVC;
}
+ (UIViewController *)findCurrentShowingViewControllerFrom:(UIViewController *)vc
{
    // 递归方法 Recursive method
    UIViewController *currentShowingVC;
    if ([vc presentedViewController]) {
        // 当前视图是被presented出来的
        UIViewController *nextRootVC = [vc presentedViewController];
        currentShowingVC = [self findCurrentShowingViewControllerFrom:nextRootVC];

    } else if ([vc isKindOfClass:[UITabBarController class]]) {
        // 根视图为UITabBarController
        UIViewController *nextRootVC = [(UITabBarController *)vc selectedViewController];
        currentShowingVC = [self findCurrentShowingViewControllerFrom:nextRootVC];

    } else if ([vc isKindOfClass:[UINavigationController class]]){
        // 根视图为UINavigationController
        UIViewController *nextRootVC = [(UINavigationController *)vc visibleViewController];
        currentShowingVC = [self findCurrentShowingViewControllerFrom:nextRootVC];

    } else {
        // 根视图为非导航类
        currentShowingVC = vc;
    }

    return currentShowingVC;
}

使用方法
我的建议是写一个uiviewcontroller类别,命名为CurrentViewController也可以随意,这样就不用每次使用的时候都去写一遍了,在h文件中吧dc_findCurrentShowingViewController这个方法抛出就可以了,使用的时候只需要调用dc_findCurrentShowingViewController这个方法即可

// viewController  这个可以用作跳转的viewConteroller 即可
 UIViewController * viewController  = [UIViewController dc_findCurrentShowingViewController];

自定义基座

  1. control.xml文件 添加 debug=“true” syncDebug=“true” 正式去掉
  2. 在原生工程里找到info.plist文件并增加一项(安装文件的一个设置)
  3. 打印log 在项目中 Build Phases ——> Link Binary With Libraries 中添加 liblibLog.a 在skd->libs文件夹下
    5. 自定义基座一定是使用的开发证书,并且一定要不运行其他东西,模式也要设置成debug模式

引入文件或者静态库

只需要把文件拖入即可,xcode会自动引入的,拖动的时候注意,一定要选择复制 和 此项目即可

uniapp 运行Android基座 启动页配置 uniapp自定义基座教程_.net