xmake v2.3.3 发布, 新增 iOS/MacOS Framework 和 App 构建支持 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
waruqi

xmake v2.3.3 发布, 新增 iOS/MacOS Framework 和 App 构建支持

  •  
  •   warqi
    waruqi 2020 年 4 月 28 日 1648 次点击
    这是一个创建于 2188 天前的主题,其中的信息可能已经有所发展或是发生改变。

    xmake 是一个基于 lua 的现代化 C/C++构建工具,通过简洁明了的语法来描述项目构建。

    这个版本主要是对内置的构建规则做了些扩展,新增了相关规则来实现对 iOS/MacOS 相关 App 应用程序项目、Framework 和 Bundle 程序的构建支持。

    并且支持 App 签名,也提供了相关工程模板来快速创建应用程序,另外此版本还对 Qt 的开发构建也做了不少改进,增加对 Qt5.14.0 新版本 sdk 的支持,对 android 的打包部署支持上也改进了不少。

    处理之外,xmake 还提供了一个特殊的xmake.cli构建 rule,通过集成 libxmake engine 库,来扩展开发基于 xmake 引擎的程序,比如:做个定制版的 xmake,也可以基于此写点 lua 脚本程序。

    构建 iOS/MacOS 程序

    构建 App 应用程序

    用于生成*.app/*.ipa 应用程序,同时支持 iOS/MacOS 。

    target("test") add_rules("xcode.application") add_files("src/*.m", "src/**.storyboard", "src/*.xcassets") add_files("src/Info.plist") 

    创建工程

    我们也可以通过模板工程快速创建:

    $ xmake create -t xcode.macapp -l objc test $ xmake create -t xcode.iosapp -l objc test 

    编译

    $ xmake f -p [iphoneos|macosx] $ xmake [ 18%]: compiling.xcode.release src/Assets.xcassets [ 27%]: processing.xcode.release src/Info.plist [ 72%]: compiling.xcode.release src/Base.lproj/Main.storyboard [ 81%]: compiling.xcode.release src/Base.lproj/LaunchScreen.storyboard [ 45%]: ccache compiling.release src/ViewController.m [ 63%]: ccache compiling.release src/AppDelegate.m [ 54%]: ccache compiling.release src/SceneDelegate.m [ 36%]: ccache compiling.release src/main.m [ 90%]: linking.release test [100%]: generating.xcode.release test.app [100%]: build ok! 

    配置签名

    对于 iOS 程序,默认会检测系统先用可用签名来签名 app,当然我们也可以手动指定其他签名证书:

    $ xmake f -p iphoneos --xcode_codesign_identity='Apple Development: [email protected] (T3NA4MRVPU)' --xcode_mobile_provision='iOS Team Provisioning Profile: org.tboox.test --xcode_bundle_identifier=org.tboox.test' $ xmake 

    如果每次这么配置签名觉得繁琐的话,可以设置到xmake global全局配置中,也可以在 xmake.lua 中对每个 target 单独设置:

    target("test") add_rules("xcode.application") add_files("src/*.m", "src/**.storyboard", "src/*.xcassets") add_files("src/Info.plist") add_values("xcode.bundle_identifier", "org.tboox.test") add_values("xcode.codesign_identity", "Apple Development: [email protected] (T3NA4MRVPU)") add_values("xcode.mobile_provision", "iOS Team Provisioning Profile: org.tboox.test") 

    那如何知道我们需要的签名配置呢?一种就是在 xcode 里面查看,另外 xmake 也提供了一些辅助工具可以 dump 出当前可用的所有签名配置:

    $ xmake l private.tools.codesign.dump ==================================== codesign identities ==================================== { "Apple Development: [email protected] (T3NA4MRVPU)" = "AF73C231A0C35335B72761BD3759694739D34EB1" } ===================================== mobile provisiOns===================================== { "iOS Team Provisioning Profile: org.tboox.test" = "<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>AppIDName</key> <string>XC org tboox test5</string> <key>ApplicationIdentifierPrefix</key> <array> <string>43AAQM58X3</string> ... 

    我们也提供了其他辅助工具来对已有的 ipa/app 程序进行重签名,例如:

    $ xmake l utils.ipa.resign test.ipa|test.app [codesign_identity] [mobile_provision] [bundle_identifier] 

    其中,后面的签名参数都是可选的,如果没设置,那么默认会探测使用一个有效的签名:

    $ xmake l utils.ipa.resign test.ipa $ xmake l utils.ipa.resign test.app "Apple Development: [email protected] (T3NA4MRVPU)" $ xmake l utils.ipa.resign test.ipa "Apple Development: [email protected] (T3NA4MRVPU)" iOS Team Provisioning Profile: org.tboox.test" org.tboox.test 

    运行应用程序

    目前仅支持运行 macos 程序:

    $ xmake run 

    效果如下:

    生成程序包

    如果是 iOS 程序会生成 ipa 安装包,如果是 macos 会生成 dmg 包( dmg 包生成暂时还在开发中)。

    $ xmake package output: build/iphoneos/release/arm64/test.ipa package ok! 

    我们也提供了辅助工具,来对指定 app 程序进行打包:

    $ xmake l utils.ipa.package test.app output.ipa [iconfile.png] 

    安装

    如果是 iOS 程序会安装 ipa 到设备,如果是 macos 会安装 app 到 /Applications 目录。

    $ xmake install 

    我们也提供了辅助工具,来对指定 ipa/app 程序安装到设备:

    $ xmake l utils.ipa.install test.app $ xmake l utils.ipa.install test.ipa 

    卸载

    !> 目前仅支持 macos 程序卸载

    $ xmake uninstall 

    构建 Framework 库程序

    target("test") add_rules("xcode.framework") add_files("src/*.m") add_files("src/Info.plist") 

    我们也可以通过模板工程快速创建:

    $ xmake create -t xcode.framework -l objc test 

    构建 Bundle 程序

    target("test") add_rules("xcode.bundle") add_files("src/*.m") add_files("src/Info.plist") 

    我们也可以通过模板工程快速创建:

    $ xmake create -t xcode.bundle -l objc test 

    xmake.cli 程序

    关于这块,主要还是方便我个人自己用来写一些基于 xmake engine 的 lua 程序,当然用户也可以用来扩展定制自己的 xmake 版本。现在 xmake 开放了 libxmake 开发库,我们可以通过:

    add_requires("libxmake") target("test") add_rules("xmake.cli") add_files("src/*.c") add_packages("libxmake") 

    来快速集成 libxmake 库做定制化开发。

    定制化扩展 xmake

    一个典型的例子就是,我们可以用 xmake.cli 快速编译构建出 xmake 自身,并且用户可以在此基础做二次开发,相关例子代码见:myxmake

    add_rules("mode.debug", "mode.release") add_requires("libxmake") target("xmake") add_rules("xmake.cli") add_files("src/*.c") if is_plat("windows") then add_files("src/*.rc") end add_packages("libxmake") 

    只需要自己在 main 函数里面调用 libxmake 接口创建自己的 xmake engine 就行了:

    #include <xmake/xmake.h> tb_int_t main(tb_int_t argc, tb_char_t** argv) { return xm_engine_run("xmake", argc, argv, tb_null, tb_null); } 

    lua 脚本程序开发

    我们可以利用 xmake.cli 快速写一些基于 lua 的 xmake engine 的命令行小工具,利用 xmake 内置的各种 modules,来开发一些原型程序。

    基于此,我写了个独立完整的小项目,可以参考下:luject, 一个静态注入动态库的工具。

    大致的项目结构非常简单:

    luject - src - lni -- main.c -- lua -- main.lua 

    其中,lni 目录用于通过 c/lua 交互,利用丰富的 c/c++程序库对 lua 接口进行扩展,而 lua 目录用于通过 lua 脚本来快速现程序逻辑,下面是 luject 的 xmake.lua 构建描述:

    set_xmakever("2.3.3") add_rules("mode.debug", "mode.release") add_requires("libxmake", "lief") if is_plat("windows") then if is_mode("release") then add_cxflags("-MT") elseif is_mode("debug") then add_cxflags("-MTd") end add_cxxflags("-EHsc", "-FIiso646.h") add_ldflags("-nodefaultlib:msvcrt.lib") end target("luject") add_rules("xmake.cli") add_files("src/lni/*.cpp") set_languages("c++14") add_packages("libxmake", "lief") add_installfiles("res/*", {prefixdir = "share/luject/res"}) includes("tests") 

    编译安装非常简单,只需要:

    xmake xmake install 

    我们也可以直接加载运行:

    xmake run 

    虽然跟 python/ruby 这种完整庞然大物和生态没法比,xmake.cli 主要还是对于一些习惯 lua 语法的用户快速写一些小脚本程序,并且提供一种通过 c 快速扩展接口的能力。

    后期,我会在lanoox项目组专门放置自己平时写的一些 xmake.cli 程序。

    更新内容

    新特性

    • #727: 支持为 android, ios 程序生成.so/.dSYM 符号文件
    • #687: 支持编译生成 objc/bundle 程序
    • #743: 支持编译生成 objc/framework 程序
    • 支持编译 bundle, framework 程序,以及 mac, ios 应用程序,并新增一些工程模板
    • 支持对 ios 应用程序打包生成 ipa 文件,以及代码签名支持
    • 增加一些 ipa 打包、安装、重签名等辅助工具
    • 添加 xmake.cli 规则来支持开发带有 xmake/core 引擎的 lua 扩展程序

    改进

    • #750: 改进 qt.widgetapp 规则,支持 qt 私有槽
    • 改进 Qt/android 的 apk 部署,并且支持 Qt5.14.0 新版本 sdk
    目前尚无回复
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2904 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 41ms UTC 14:32 PVG 22:32 LAX 07:32 JFK 10:32
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86