我知道这可能听起来有点奇怪,但我需要自动生成一个xcodeproj.基本上扫描文件系统并将某些文件添加到项目和特定目标.
这背后的主要原因是我在零IDE环境中工作.因此,我们有自己的构建系统,并且始终添加和删除源文件.
我可以使用"为任何添加的文件夹创建文件夹引用".但是,如果源文件不是任何目标的一部分,xcode将不会解析源文件.所以,没有符号,没有代码完成......
对我来说,我唯一的选择是用脚本"自动更新"我的xcodeproj ...
提前感谢您的投入!
我迭代iCal中的所有事件只获得今天的事件,但我认为这不是有效的.是否有功能/方法只能获得今天的活动?
tell application "iCal"
tell calendar "Lotus Notes"
set today to (current date)
set this_year to year of today
set this_month to month of today
set this_day to day of today
repeat with c in every event
set d to start date of c
set the_year to year of d
set the_month to month of d
set the_day to day of d
if (the_year = this_year) and (the_month = this_month) and (the_day = this_day) then
show c
end if
end …Run Code Online (Sandbox Code Playgroud) 我想自动将文件添加到从头创建的Xcode项目(通过另一个IDE)作为构建后步骤.我们的项目设置为调用在项目中生成相应文件引用的applescript,但是每次尝试将文件引用添加到项目都会失败.
核心问题似乎是这个错误:Xcode出错:工作区文档"project.xcworkspace"的项目"TestProject"的Xcode 3组ID"D82DCFB50E8000A5005D6AD8"的文件引用ID"DCDCC17E13819A8E004B4E75"不理解添加消息.
在这条线上:
add fileRef to first target of testProject
Run Code Online (Sandbox Code Playgroud)
其中fileRef是设置为新创建的文件引用的变量,testProject是设置为包含fileRef的项目的变量.
这是代码:
on run argv
-- Get the folder containing items to be added to the project
tell application "Finder"
set thisScript to path to me
set projectFolder to get folder of thisScript as string
set sourceFolder to projectFolder & "FilesToAdd:"
end tell
-- Get all the files that will be added to Xcode
tell application "System Events"
set filesToAddList to the name of every disk item of (sourceFolder …Run Code Online (Sandbox Code Playgroud) 我看到很多AppleScript的例子都是这样的
tell application "TextEdit"
activate
tell application "System Events"
keystroke "s"
end tell
end tell
Run Code Online (Sandbox Code Playgroud)
预期的结果是字母"s"将被输入到TextEdit中的活动文档中(假设至少有一个文档窗口).但它总是试图保存文档(为更改的文档做了它,如果它是新的则打开保存对话框).任何时候任何应用程序中的任何键都会发生同样的事情......
有没有人知道为什么系统事件总是发送"...使用{command down}"这样的击键?
如何告诉Safari在当前窗口的新选项卡中打开URL?
这与使用AppleScript的新Safari选项卡中的Open URL重复,但其答案不再适用于当前版本的Safari(5.1 on 10.6.8).选项卡已创建但为空:
tell front window of application "Safari"
make new tab with properties {URL:"http://www.stackoverflow.com"}
end tell
Run Code Online (Sandbox Code Playgroud)
如果您创建一个新的"文档"而不是URL,但这会打开一个窗口.
对于它的价值,我将此报告为Apple的一个错误.但是解决方法会很棒.
我需要确定用户是否在Mac上设置了非空密码.一切都会奏效:命令行调用,AppleScript,Carbon,Cocoa等.
我想告知用户他们是否设置了密码.
我有一个我正在使用AppleScript编写的应用程序将圣伯纳德重定向LaunchDaemon移动到当前用户的目录,以便用户可以访问家中的任何网站,但让他们在回到学校之前将其放回原处.这样做的原因是,在学校,iPrism阻止学校不希望你去的任何网站,但是当学生在家时,圣伯纳德LaunchDaemon阻止了相同的网站,我认为没有必要这样做.
无论如何,我想在一个对话框中添加一个进度条,该对话框显示删除应用程序的shell脚本的输入.谁知道怎么做?
(我也想要没有任何按钮display dialog "Removing..." buttons "",而只是有进度条.这可能吗?)
这是代码:
display alert "You may have to restart your computer after using this tool!" buttons {"Ok"} default button 1
set question to display dialog "RMR (Remove My Redirect)
Are you unable to go to a website at home because of that annoying St. Bernard Redirect?
If the answer is Yes, then RMR is your solution! Simply Choose Remove to remove it, and Replace to put it back." buttons {"Remove", "Replace", "Erase …Run Code Online (Sandbox Code Playgroud) 根据Apple的Developer Docs,Library全局允许导入已编译的脚本,以便它们可以在一个当前脚本中用作库.这个工作,如果你是做类似下面的代码就好了myLibName.scpt位于~/Library/Script Libraries:
myLib = Library('myLibName');
myLib.myLibMethod() // Works just fine
Run Code Online (Sandbox Code Playgroud)
但是,文档还声称可以导出一个环境变量 - OSA_LIBRARY_PATH包含一串:分隔的路径 - Library()然后在继续它的默认路径之前推迟到该路径列表:~/Library/Script Libraries.雅知道,就像bash环境变量一样Path.以下是相关的文档; 它描述了路径层次结构:
脚本作为脚本库的基本要求是它的位置:它必须是以下文件夹之一中"脚本库"文件夹中的脚本文档.搜索库时,将按列出的顺序搜索位置,并使用第一个匹配的脚本:
- 如果引用该库的脚本是一个bundle,则该脚本的bundle资源目录.这意味着脚本可以与他们使用的库打包和分发.
- 如果运行脚本的应用程序是一个bundle,那么应用程序的bundle资源目录.这意味着脚本应用程序("applet"和"drops")可以与它们使用的库打包和分发.它还使运行脚本的应用程序能够提供这些脚本使用的库.
- 环境变量OSA_LIBRARY_PATH中指定的任何文件夹.这允许使用库而无需在其中一个常用位置安装它.此变量的值是以冒号分隔的路径列表,例如/ opt/local/Script Libraries:/ usr/local/Script Libraries.与其他库位置不同,OSA_LIBRARY_PATH中指定的路径完全按原样使用,不附加"脚本库".在OS X v10.11及更高版本中受支持.
- 用户主目录中的Library文件夹,〜/ Library.这是安装库供单个用户使用的位置,是库开发期间的推荐位置.
- 计算机库文件夹,/ Library.此处的库可供计算机的所有用户使用.
- 网络库文件夹,/ Network/Library.位于此处的库可用于网络上的多台计算机.
- 系统库文件夹,/ System/Library.这些是OS X提供的库.
- 应用程序的bundle库目录中的任何已安装的应用程序包.这允许分发与应用程序关联的库,或创建仅用于分发库的应用程序.在OS X v10.11及更高版本中受支持.
问题是它不起作用.我已经尝试OSA_LIBRARY_PATH通过我的.zshrc文件导出变量 - 全局- 然后通过脚本编辑器和osascript可执行文件运行上面的示例脚本.什么都行不通; 我收到"找不到文件"错误.我找到了这个帖子 - 参与者放弃了在线的希望 ; 它没有解释太多.有什么想法吗?
在一个有点相关的说明中, …
多年来我一直在使用以下AppleScript在iTerm2中打开vim中的txt文件,但是自iTerm 2.9.2(又名iTerm3)以来它已经被打破了.任何人都可以建议如何更新这个AppleScript,以便它再次工作?
on run {input, parameters}
if (count of input) > 0 then
tell application "System Events"
set runs to false
try
set p to application process "iTerm"
set runs to true
end try
end tell
tell application "iTerm"
activate
if (count of terminals) = 0 then
set t to (make new terminal)
else
set t to current terminal
end if
tell t
tell (make new session at the end of sessions)
exec command ("vim \"" & POSIX path of …Run Code Online (Sandbox Code Playgroud) 我刚刚完成了macOS Mojave的全新安装(尽管重新安装了许多零碎的组件),并且在运行bash脚本时遇到了一个奇怪的错误,该脚本随后又通过运行了AppleScript osascript。osascript -e即使实际命令似乎已完成,传递给的任何命令似乎也会产生相同的错误。
例如 $ osascript -e 'say "hello"'
错误是:
2018-12-03 22:35:26.301 osascript [39652:590470] isPrefsCreateCacheFromEnabledAndDefaultInputSources-无法从GetInputSourceEnabledPrefs中找到任何内容,请使用defaultASCIIKeyLayoutDict = {type = mudict dict,count = 3,
entry =>
0:{contents =“ InputSourceKind” } = {内容=“键盘布局”}
1:{内容=“键盘布局ID”} = {值= +2,类型= kCFNumberSInt64Type}
9:{内容=“键盘布局名称”} =英式
}
通过ScriptEditor应用程序运行相同的命令可以正常工作。
使用系统bash,在安装时配置了一个键盘(英语)。
任何人都有相同的问题或想法是什么问题?
applescript ×10
macos ×3
objective-c ×2
xcode ×2
add ×1
automation ×1
bash ×1
cocoa ×1
dialog ×1
file ×1
icalendar ×1
iterm2 ×1
macos-carbon ×1
osascript ×1
progress ×1
progress-bar ×1
safari ×1
target ×1
terminal ×1
vim ×1