1. 下载 xcode(略):

    # 下载地址
    https://developer.apple.com/download/more/
    # 兼容性查询
    https://xcodereleases.com/
    # xcode 图标/启动图片生成器
    http://file.job520.net/macos/xcode/icongenerator.dmg
  2. 创建新项目:

    1. 选择 Create a new Xcode project:
    2. 选择 Single View App:
    3. 输入项目名称,选择开发语言(Object-C):
    4. 选择存储路径:
  3. 设置 项目名称:

  4. 设置 项目图标:

    1. 制作图标(略):
    2. Assets.xcassets >> AppIcon 中填充图标:
  5. 设置 启动图片:

    1. Assets.xcassets 右侧空白处右键,点击 App Icons & Launch Images >> New ios Launch Image,创建启动图片栏:
    2. 制作启动图片(略):
    3. Assets.xcassets >> LaunchImage 中填充图片:
    4. AppDelegate.m 中设置启动动画时间:
       // 设置启动动画展示3秒
       [NSThread sleepForTimeInterval:3.0];
       [_window makeKeyAndVisible];
  6. 运行 h5项目:

    1. 将 h5项目 拖入到 xcode 中:
    2. 修改 ViewController.m,运行网页:
      #import <WebKit/WebKit.h>
      ...
       // 1. 加载网页
       WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height - 20)];
       NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://google.com"]];
       [webView loadRequest:request];
       [self.view addSubview:webView];
    3. 修改 ViewController.m,运行本地 h5文件:
      #import <WebKit/WebKit.h>
      ...
       // 2. 加载本地 h5 文件
       WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height - 20)];
       NSString *mainBundlePath = [[NSBundle mainBundle] bundlePath];
       NSString *basePath = [NSString stringWithFormat:@"%@/www",mainBundlePath];
       NSURL *baseUrl = [NSURL fileURLWithPath:basePath isDirectory:YES];
       NSString *htmlPath = [NSString stringWithFormat:@"%@/index.html",basePath];
       NSString *htmlString = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil];
       [webView loadHTMLString:htmlString baseURL:baseUrl];//加载
       [self.view addSubview:webView];
  7. 使用 safari 调试 webview(确保 模拟器 的版本和 mac上 safari 的版本一致)(略)

  8. 打包(无开发者账号):

    1. Prefernces >> Accounts 中添加 Apple IDs(非开发者):
    2. 点击 Manage Certificates...,添加一个 ios Development 证书:

    3. 项目名 >> General 中修改 Bundle IdentifierTeam 选项:
    4. 确保 设备 选择的是 Generic ios Device
    5. 选择 Product >> Archive,进行打包:

文档更新时间: 2024-04-20 10:57   作者:lee