summaryrefslogtreecommitdiff
path: root/xmake/rules/xcode/application/xmake.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/rules/xcode/application/xmake.lua')
-rw-r--r--xmake/rules/xcode/application/xmake.lua109
1 files changed, 15 insertions, 94 deletions
diff --git a/xmake/rules/xcode/application/xmake.lua b/xmake/rules/xcode/application/xmake.lua
index 781ece19f..75cae682d 100644
--- a/xmake/rules/xcode/application/xmake.lua
+++ b/xmake/rules/xcode/application/xmake.lua
@@ -21,103 +21,24 @@
-- define rule: xcode application (TODO developing)
rule("xcode.application")
- -- we must set kind before target.on_load(), may we will use target in on_load()
- before_load(function (target)
-
- -- get app directory
- local targetdir = target:targetdir()
- local appdir = path.join(targetdir, target:basename() .. ".app")
- target:data_set("xcode.appdir", appdir)
-
- -- set target info for app
- target:set("kind", "binary")
- target:set("filename", target:basename())
- if is_plat("macosx") then
- target:set("targetdir", path.join(appdir, "Contents", "MacOS"))
- else
- target:set("targetdir", appdir)
- end
-
- -- add frameworks
- if is_plat("macosx") then
- target:add("frameworks", "AppKit")
- else
- target:add("frameworks", "UIKit")
- end
-
- -- register clean files for `xmake clean`
- target:add("cleanfiles", appdir)
- end)
-
- after_build(function (target)
-
- -- imports
- import("private.tools.codesign")
+ -- support add_files("*.storyboard")
+ set_extensions(".storyboard", ".xcassets")
- -- generate Info.plist
- local function _gen_info_plist(info_plist_file)
- io.gsub(info_plist_file, "(%$%((.-)%))", function (_, variable)
- local maps =
- {
- DEVELOPMENT_LANGUAGE = "en",
- EXECUTABLE_NAME = target:basename(),
- PRODUCT_BUNDLE_IDENTIFIER = "org.tboox." .. target:name(),
- PRODUCT_NAME = target:name(),
- PRODUCT_BUNDLE_PACKAGE_TYPE = "APPL", -- application
- CURRENT_PROJECT_VERSION = target:version() and tostring(target:version()) or "1.0",
- MACOSX_DEPLOYMENT_TARGET = get_config("target_minver")
- }
- return maps[variable]
- end)
- end
-
- -- get app directory
- local appdir = path.absolute(target:data("xcode.appdir"))
-
- -- get contents directory
- local contentsdir = appdir
- if is_plat("macosx") then
- contentsdir = path.join(appdir, "Contents")
- end
-
- -- copy PkgInfo to the contents directory
- os.cp(path.join(os.programdir(), "scripts", "PkgInfo"), contentsdir)
-
- -- copy resource files to the contents directory
- local srcfiles, dstfiles = target:installfiles(contentsdir)
- if srcfiles and dstfiles then
- local i = 1
- for _, srcfile in ipairs(srcfiles) do
- local dstfile = dstfiles[i]
- if dstfile then
- os.vcp(srcfile, dstfile)
- if path.filename(srcfile) == "Info.plist" then
- _gen_info_plist(dstfile)
- end
- end
- i = i + 1
- end
- end
+ -- we must set kind before target.on_load(), may we will use target in on_load()
+ before_load("load")
- -- do codesign
- codesign(appdir, target:values("xcode.codesign_identity") or get_config("xcode_codesign_identity"))
- end)
+ -- build *.storyboard and *.xcassets
+ on_build_file("build_file")
- on_install(function (target)
- local appdir = path.absolute(target:data("xcode.appdir"))
- local installdir = target:installdir()
- if not os.isdir(installdir) then
- os.mkdir(installdir)
- end
- os.vcp(appdir, installdir)
- end)
+ -- build *.app
+ after_build("build")
- on_uninstall(function (target)
- local appdir = path.absolute(target:data("xcode.appdir"))
- local installdir = target:installdir()
- os.tryrm(path.join(installdir, path.filename(appdir)))
- end)
+ -- package *.app to *.ipa (iphoneos) or *.dmg (macosx)
+ on_package("package")
+
+ -- install application
+ on_install("install")
- -- disable package
- on_package(function (target) end)
+ -- uninstall application
+ on_uninstall("uninstall")