下载 xcode(略):
# 下载地址 https://developer.apple.com/download/more/ # 兼容性查询 https://xcodereleases.com/ # xcode 图标/启动图片生成器 http://file.job520.net/macos/xcode/icongenerator.dmg
创建新项目:
- 选择 Create a new Xcode project:
- 选择 Single View App:
- 输入项目名称,选择开发语言(Object-C):
- 选择存储路径:
- 选择 Create a new Xcode project:
设置 项目名称:
设置 项目图标:
- 制作图标(略):
- 在
Assets.xcassets >> AppIcon
中填充图标:
设置 启动图片:
- 在
Assets.xcassets
右侧空白处右键,点击App Icons & Launch Images >> New ios Launch Image
,创建启动图片栏: - 制作启动图片(略):
- 在
Assets.xcassets >> LaunchImage
中填充图片: - 在
AppDelegate.m
中设置启动动画时间:// 设置启动动画展示3秒 [NSThread sleepForTimeInterval:3.0]; [_window makeKeyAndVisible];
- 在
运行 h5项目:
- 将 h5项目 拖入到 xcode 中:
- 修改
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];
- 修改
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];
- 将 h5项目 拖入到 xcode 中:
使用 safari 调试 webview(确保 模拟器 的版本和 mac上 safari 的版本一致)(略)
打包(无开发者账号):
- 在
Prefernces >> Accounts
中添加Apple IDs
(非开发者): - 点击
Manage Certificates...
,添加一个ios Development
证书: - 在
项目名 >> General
中修改Bundle Identifier
、Team
选项: - 确保
设备
选择的是Generic ios Device
: - 选择
Product >> Archive
,进行打包:
- 在
文档更新时间: 2024-04-20 10:57 作者:lee