行业知识
iOS 开发入门 - 快速编写一个弹框动态库 dylib
2026-11-09 12:00:26
来源:互联网转载
安装 Xcode 打开 App Store 搜索:Xcode 下载安装
打开 终端 运行安装:Xcode 命令行工具
xcode-select --install
打开 终端 运行安装:Homebrew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
打开 终端 运行安装:Idid
brew install ldid
打开 终端 运行安装:TheOS
sudo git clone --recursive https://github.com/theos/theos.git /opt/theos
打开 终端 运行安装:MonkeyDev
sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/AloneMonkey/MonkeyDev/master/bin/md-install)"
打开 Xcode 软件 创建新项目
Team 没有选项的按下图操作:
选择 Apple ID
输入您的 Apple ID 以及密码
回归正题、创建项目 下一步【选择创建到那个文件夹】
创建新项目成功
设置最低运行系统
暂时用不着、 直接注释
创建新文件
创建成功
导入 UIKit 框架
#import
使用 __attribute__((constructor)) 让程序加载时自动调用这个函数,这种构造函数在程序启动时会被自动执行,无需显式调用。
static void __attribute__((constructor)) tests(void) {} 使用 Grand Central Dispatch (GCD) 在程序中将任务异步派发到主队列执行
dispatch_async(dispatch_get_main_queue(), ^{}); 使用 UIAlertController 创建一个简单的弹出框
UIWindow *window = [UIApplication sharedApplication].keyWindow;UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"弹框标题" message:@"弹框内容" preferredStyle:UIAlertControllerStyleAlert];[alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];[[window rootViewController] presentViewController:alert animated:YES completion:nil];
完事、编译
哦豁,报错 查看原因与解决
点击查看原因
原因 UIKit 框架 忘记添加了、添加一下
搜索 UIKit 并添加
顺便把MonkeyDev删除了吧,以下红框内的 【已设置 SSH 链接的跳过】
继续编译、编译成功
查看编译后的 dylib 文件
完事,手工。
上一篇:服务器怎么更改图标样式?
下一篇:高温环境下怎么使用服务器?