当前位置:首页 » 编程软件 » commandb编译

commandb编译

发布时间: 2023-05-14 08:56:37

Ⅰ Sub3 运行 python command+b 没反应

安装sublime text3后,按Ctrl+b无法运行python文件。

解决方法:

打开sublime ->戚逗胡 tools -> build system ->new build system,在打开的新tab页面添加如下内容:

command +s保存到目录(Sublime Text3/Packages/User,保高拦存时的默认目录),可任意命指槐名(建议python3),但后缀名不能更改。

然后在tools→build system中选择添加的项,通过command +b命令即可运行Python文件。

Ⅱ Delphi的命令行编译命令

Borland出品的Delphi,有着闪电般的编译速度,但是在界面控件使用较多、工程项目较大的时候,编译一个工程仍需要一段时间,打开庞大的Delphi IDE,也需要时间。其实,在一个工程开发结束,调试完成之后的Release编译,完全可以用命令行来执行,因为Delphi的编译器参数不像C++编译器那样复杂。

笔者把Delphi联机手册中关于命令行编译(command-line compiler)的几篇主题作了翻译,希望对Delphi开发人员有帮助。

目录
1. Command-line compiler
命令行编译器
2. Command-line compiler options
命令行编译器选项
3. Compiler directive options
编译器指令选项
4. Compiler mode options
编译模式选项
5. DCC32.CFG file
编译器配置文件DCC32.CFG
6. Debug options
调试选项
7. Directory options
目录选项
8. IDE command-line options
IDE命令行选项
9. Generated files
几个IDE自动生成的文件介绍

Command-line compiler
命令行编译器
Delphi's command-line compiler (dcc32.EXE) lets you invoke all the functions of the IDE compiler (DELPHI32.EXE) from the DOS command line (see IDE command-line options. Run the command-line compiler from the DOS prompt using the syntax:
Delphi’s命令行编译器(dcc32.exe)允许你从DOS命令行方式(参照:IDE命令行选项)实现IDE编译器(delphi32.exe)的所有功能。用DOS命令运行命令行编译器语法如下:
dcc32 [options] filename [options]
dcc32 [选项] [文件名] [选项]
where options are zero or more parameters that provide information to the compiler and filename is the name of the source file to compile. If you type dcc32 alone, it displays a help screen of command-line options and syntax.
零或多个参数给编译器提供信息,文件名指定需要编译的源文件名。如果你单独输入dcc32,它会显示一个关于命令行编译的选项和语法的屏幕。
If filename does not have an extension, the command-line compiler assumes .dpr, then .pas, if no .dpr is found. If the file you're compiling to doesn't have an extension, you must append a period (.) to the end of the filename.
如果文件名没有扩展名,命令行编译器会查找扩展名为.dpr的同名文件,如果找不到,则查找扩展名为.pas的同名文件。如果你的源文件确实没有扩展名,你需要在文件名的末尾添加(.)。
If the source text contained in filename is a program, the compiler creates an executable file named filename.EXE. If filename contains a library, the compiler creates a file named filename.DLL. If filename contains a package, the compiler creates a file named filename.BPL. If filename contains a unit, the compiler creates a unit file named filename.dcu.
如果指定的源文件是一个工程文件,编译器会创建一个扩展名为.EXE的同名可执行文件。如果指定的源文件是一个库文件,编译器创建一个扩展名为.DLL的同名动态链接库文件。如果指定的源文件是一个包文件,编译器会创建一个扩展名为.BPL的同名包。如果指定的源文件是一个单元文件,编译器会创建一个扩展名为.dcu的目标代码文件。
You can specify a number of options for the command-line compiler. An option consists of a slash (/) or immediately followed by an option letter. In some cases, the option letter is followed by additional information, such as a number, a symbol, or a directory name. Options can be given in any order and can come before or after the file name.
你可以为命令行编译器指定多个参数。一个参数包含一个破折号“-”(或“/”)和紧跟着的一个选项字符构成。通常情况下,选项字符后面会跟一些附加的信息,如一个数字、一个符号、一个目录等。选项可以是任意顺序并且可以在源文件名前面或后面。

Command-line compiler options
命令行编译选项
The IDE lets you set various options through the menus; the command-line compiler gives you access to these options using the slash (/) delimiter. You can also precede options with a hyphen (-) instead of a slash (/), but those options that start with a hyphen must be separated by blanks. For example, the following two command lines are equivalent and legal:
IDE允许你使用菜单来设置各种编译选项,而命令行编译器允许你使用字符“/”作为分隔符来设定这些编译选项。你也可以使用连字符“-”来代替“/”,但是用“-”引出的参数之间必须用空格隔开。例如,下面两个命令都是等同的也是合法的:
DCC -IC:\DELPHI -DDEBUG SORTNAME -$R- -$U+
DCC /IC:\DELPHI/DDEBUG SORTNAME /$R-/$U+
The first command line uses hyphens with at least one blank separating options. The second uses slashes and no separation is needed.
第一个编译命令用“-”引出参数,且参数之间有多个空格分隔。第二个编译命令用“/”引出参数,参数之间不必要分隔。
The following table lists the command-line options. In addition to the listed options, all single-letter compiler directives can be specified on the command line, as described in Compiler directive options.
下列表中列出所有的命令行参数。在附加的选项列表中,所有的单字符编译器指令都可以在命令行编译中使用,详情请参照:编译器指令。
Option Description
选项 描述
Aunit=alias 设置单元别名
B 编译所有单元
CC 编译控制台程序
CG 编译图形界面程序
Ddefines 编译条件符号定义
Epath 可执行文件输出路径
Foffset 查找运行期间错误
GD 生成完整.Map文件
GP 生成.Map文件Public段
GS 生成.Map文件Segment段
H 输出提示信息
Ipaths 文件包含路径
J 生成.Obj目标文件
JP 生成C++类型.Obj目标文件
Kaddress Set image base address
LEpath 包.BPL文件输出路径
LNpath .dcp文件输出路径
LUpackage 使用运行期间包列表
M 编译有改动的源文件
Npath dcu/dpu文件输出目录
Opaths .Obj文件(汇编目标代码文件)路径
P 按8.3格式文件名查找
Q 安静模式
Rpaths 资源文件(.RES)路径
TXext 目标文件扩展名
Upaths 单元文件路径
V 为Turbo Debugger生成调试信息文件
VN 以.Giant格式生成包含命名空间的调试信息文件(将用于C++Builder)
VR 生成调试信息文件.rsm
W 输出警告信息
Z Disable implicit compilation
$directive Compiler directives
--Help 显示编译选项的帮助。同样的,如果你在命令行单独输入dcc32,也会显示编译选项的帮助。
--version 显示产品名称和版本

Compiler directive options
编译器指令选项
Delphi supports the compiler directives described in Compiler directives. The $ and D command-line options allow you to change the default states of most compiler directives. Using $ and D on the command line is equivalent to inserting the corresponding compiler directive at the beginning of each source file compiled.
Delphi支持用编译器指令关键字描述的编译器指令。使用“$”和“D”命令行选项可以改变所有的默认编译器状态。用“$”和“D”命令行选项等同于在源文件的前面添加编译器指令。
Switch directive option
编译器指令选项开关
The $ option lets you change the default state of all of the switch directives. The syntax of a switch directive option is $ followed by the directive letter, followed by a plus (+) or a minus (-). For example:
“$”允许你改变每一种编译器指令默认状态。编译器指令的语法是“$”后紧跟一个指令字符,再跟一个“-”或“+”。例如:
dcc32 MYSTUFF -$R-
compiles MYSTUFF.pas with range-checking turned off, while:
不使用边界检查编译MYSTUFF.pas单元:
dcc32 MYSTUFF -$R+
compiles it with range checking turned on. Note that if a {$R+} or {$R-} compiler directive appears in the source text, it overrides the -$R command-line option.
使用界面检查编译MYSTUFF.pas单元。如果将编译器指令{$R+}或{$R-}添加到源文件的开始,它将覆盖从命令行传入的参数。
You can repeat the -$ option in order to specify multiple compiler directives:
你可以用多个“$”来指定多个编译器指令,如:
dcc32 MYSTUFF -$R--$I--$V--$U+
Alternately, the command-line compiler lets you write a list of directives (except for $M), separated by commas:
命令行编译器允许作用逗号分隔的编译器指定列表,如:
dcc32 MYSTUFF -$R-,I-,V-,U+
只需要用一个“$”符号。
Only one dollar sign ($) is needed.
注意,因为$M的格式不一样,你不能在逗号分隔的指令列表中使用$M
Note that, because of its format, you cannot use the $M directive in a list of directives separated by commas.
Conditional defines option
条件编译选项
The -D option lets you define conditional symbols, corresponding to the {$DEFINE symbol} compiler directive. The -D option must be followed by one or more conditional symbols separated by semicolons (;). For example, the following command line:
“-D”选项允许你定义一个编译条件,符合你用{$DEFINE symbol}定义的编译器指令。“-D”选项后必须跟随一或多个用分号分隔的编译条件符号,如下命令:
dcc32 MYSTUFF -DIOCHECK;DEBUG;LIST
defines three conditional symbols, iocheck, debug, and list, for the compilation of MYSTUFF.pas. This is equivalent to inserting:
定义了三个编译条件符号:IOCHECK,DEBUG,LIST,用于MYSTUFF.pas单元中。这等同于在源文件中插入以下语句:
{$DEFINE IOCHECK}
{$DEFINE DEBUG}
{$DEFINE LIST}
at the beginning of MYSTUFF.pas. If you specify multiple -D directives, you can concatenate the symbol lists. Therefore:
如果你指定了多个“-D”选项,你可以联接它们,如下:
dcc32 MYSTUFF -DIOCHECK-DDEBUG-DLIST

is equivalent to the first example.
等同于第一个例子。

Compiler mode options
编译模式选项
A few options affect how the compiler itself functions. As with the other options, you can use these with either the hyphen or the slash format. Remember to separate the options with at least one blank.
有几个选项能影响编译器自身的功能。像其它选项一个,你可以使用“/”或“-”的格式。别忘了用至少一个空格分隔这些选项。
Make (-M) option
选项(-M)
The command-line compiler has built-in MAKE logic to aid in project maintenance. The -M option instructs command-line compiler to check all units upon which the file being compiled depends. Using this option results in a much quicker compile time.
命令行编译器使用构造逻辑的方式来维护工程。“-M”选项指示编译器检查所有与编译文件相关联的文件。用这个参数会导致编译时间增大。
A unit is recompiled under the following conditions:
一个源文件在下列情况下会重新编译:
The source file for that unit has been modified since the unit file was created.
源文件被创建以来被修改过;
用“$I”指令包含的任何文件,用“$L”包含的任何.Obj文件,或用“$R”关联的任何资源文件.Res,比源文件中的要新;
Any file included with the $I directive, any .OBJ file linked in by the $L directive, or any .res file referenced by the $R directive, is newer than the unit file.
The interface section of a unit referenced in a uses statement has changed.
单元接口部分interface的uses段有改动。
Units compiled with the -Z option are excluded from the make logic.
在单元编译时指令“-Z”在构造逻辑期不被接受。
If you were applying this option to the previous example, the command would be:
如果你在上一个例子中使用这个指令,编译命令就应该是:
dcc32 MYSTUFF -M
Build all (-B) option
编译所有 选项(-B)
Instead of relying on the -M option to determine what needs to be updated, you can tell command-line compiler to update all units upon which your program depends using the -B option. You can't use -M and -B at the same time. The -B option is slower than the -M option and is usually unnecessary.
用于取代要知道哪些单元需要更新-M的选项,你可以使用-B选项来更新所有你的程序中关联的单元。你不能在程序中同时使用-M和-B。选项-B比-M速度更慢,而且它并不是必需的。
If you were using this option in the previous example, the command would be
如果你在前一个例子中使用这个参数,编译命令就应该是:
dcc32 MYSTUFF -B
Find error (-F) option
查找错误 选项(-F)
When a program terminates e to a runtime error, it displays an error code and the address at which the error occurred. By specifying that address in a -Faddress option, you can locate the statement in the source text that caused the error, provided your program and units were compiled with debug information enabled (via the $D compiler directive).
当一个程序由于运行期间错误而终止时,它会显示一个错误号和错误地址在错误发生时。用-Faddress选项来指定错误地址,你在源文件中能找到引发错误的位置,如果你的程序和单元编译时附加了调试信息(使用$D编译器指令)。
In order for the command-line compiler to find the runtime error with -F, you must compile the program with all the same command-line parameters you used the first time you compiled it.
为了命令行编译器能用-F选项查找运行期间错误,你必须传递与第一次编译时相同的指令列表。
As mentioned previously, you must compile your program and units with debug information enabled for the command-line compiler to be able to find runtime errors. By default, all programs and units are compiled with debug information enabled, but if you turn it off, using a {$D-} compiler directive or a -$D- option, the command-line compiler will not be able to locate runtime errors.
先前提到过,你的程序和单元必须启用调试信息,命令行编译器才能查找运行期间错误。默认情况下,所有的程序和单都是启用调试信息的,除非你用{-D}或-$D-指令关闭它,这样,命令行编译器就不能查找运行期间错误了。
Use packages (-LU) option
使用包(-LU)选项
Use the -LU option to list additional runtime packages that you want to use in the application being compiled. Runtime packages already listed in the Project Options dialog box need not be repeated on the command line.
使用-LU选项来在编译时添加你应用程序中要用到的运行期间包。运行期间包已经在“工程选项”对话框中列举的,不必再在命令行中添加。
Disable implicit compilation (-Z) option
(此选项在delphi6.0/7.0中有不同描述,在此不作翻译)
The -Z option prevents packages and units from being implicitly recompiled later. With packages, it is equivalent to placing {$ IMPLICITBUILD OFF} in the .dpk file. Use -Z when compiling packages that provide low-level functionality, that change infrequently between builds, or whose source code will not be distributed.
Target file extension (-TX) option
目标文件扩展名(-TX)选项
The -TX option lets you override the default extension for the output file. For example,
选项-TX允许你改写默认的输出文件扩展名。例如:
dcc32 MYSTUFF -TXSYS
generates compiled output in a file called MYSTUFF.SYS.
生成的将是一个叫做MYSTUFF.SYS的文件。
Quiet (-Q) option
安静模式(-Q)选项
The quiet mode option suppresses the printing of file names and line numbers ring compilation. When the command-line compiler is invoked with the quiet mode option
安静模式选项禁止在编译时显示文件名及代码行数,如果命令行编译器调用这个选项的话。
dcc32 MYSTUFF -Q its output is limited to the startup right message and the usual statistics at the end of compilation. If any errors occur, they will be reported.

它的输出仅限于起始时行版权信息以及结尾的统计信息。当然,如果发生错误,它也会输出。

DCC32.CFG file
DCC32.CFG配置文件
You can set up a list of options in a configuration file called DCC32.CFG, which will then be used in addition to the options entered on the command line. Each line in configuration file corresponds to an extra command-line argument inserted before the actual command-line arguments. Thus, by creating a configuration file, you can change the default setting of any command-line option.
你可以设置一个编译选项列表到一个叫做DCC32.CFG的配置文件中,它将用于编译时附加到命令行参数后。配置文件的每一行都相当于一个额外的命令行参数插入到实际的命令行参数前(注意,是实际参数前)。因而,你可以使用这个配置文件改变一些命令行参数的默认设置。
The command-line compiler lets you enter the same command-line option several times, ignoring all but the last occurrence. This way, even though you've changed some settings with a configuration file, you can still override them on the command line.
命令行编译器允许你输入相同的命令行参数,它将忽略所有除最后一个之外。这个的话,尽管通过配置文件你可以改变一些设置,你仍然可以覆盖它使用命令行参数。
When dcc32 starts, it looks for DCC32.CFG in the current directory. If the file isn't found there, dcc32 looks in the directory where DCC32.EXE resides.
当dcc32启动时,它查找DCC32.CFG文件在当前目录。如果文件没有找到,dcc32会查找它所在的目录。
Here's an example DCC32.CFG file, defining some default directories for include, object, and unit files, and changing the default states of the $O and $R compiler directives:
以下是一个DCC32.CFG配置文件的例子,定义了关于文件包含、OBJ文件包含、单元文件搜索路径信息,并改变了编译器指令$O和$R的默认值。
-IC:\DELPHI\INC;C:\DELPHI\SRC
-OC:\DELPHI\ASM
-UC:\DELPHI\UNITS
-$R+
-$O-
Now, if you type:
现在,如果你输入:
dcc32 MYSTUFF
the compiler performs as if you had typed the following:
编译器把它当作你输入如下命令:
dcc32 -IC:\DELPHI\INC;C:\DELPHI\SRC -OC:\DELPHI\ASM -UC:\DELPHI\UNITS -$R+ -$O- MYSTUFF

Debug options
调试选项
The compiler has two sets of command-line options that enable you to generate external debugging information: the map file options and the debug info options.
编译器有两个命令行参数可以生成外部调试信息:MAP文件选项和调试信息选项。
Map file (-G) options
Map文件(-G)选项
The -G option instructs the command-line compiler to generate a .map file that shows the layout of the executable file. Unlike the binary format of executable and .dcu files, a .map file is a legible text file that can be output on a printer or loaded into the editor. The -G option must be followed by the letter S, P, or D to indicate the desired level of information in the .map file. A .MAP file is divided into three sections:
选项-G指示命令行编译器生成一个.map文件来查看一个可执行文件的布局。不同于可二进制的可执行文件和.dcu文件,.map文件是一个可读的文本文件,可以被打印或是其它文本编辑器编辑。选项-G后必须跟字符S、P或D,去决定你想要在.map文件列出的信息。一个.MAP文件被分成三个节:
Segment
Publics
Line Numbers
-GS outputs only the Segment section, -GP outputs the Segment and Publics section, and -GD outputs all three sections. -GD also generates a .DRC file that contains tables of all string constants declared using the resourcestring keyword.
-GS选项只输出Segment Section,-GS选项输出Segment和Publics,-GD输出所有的三个Sections.-GD选项也生成一个扩展名为.DRC的文件包含所有的用resourcestring关键字声明的字符串常量。
For moles (program and units) compiled in the {$D+,L+} state (the default), the Publics section shows all global variables, proceres, and functions, and the Line Numbers section shows line numbers for all proceres and functions in the mole. In the {$D+,L-} state, only symbols defined in a unit's interface part are listed in the Publics section. For moles compiled in the {$D-} state, there are no entries in the Line Numbers section.
用默认的编译选项{$D+,L+}编译模块(程序或单元),Publics Section列举所有的全局变量、过程和函数,Line Numbers Section列举模块中所有的过程和函数的行号。如果用{$D+,L-}编译选项编译模块,Publics Section中仅列举在单元的interface部分定义的符号。如果用{$D-}选项编译模块,在Line Numbers Section没有任何入口。
Debug info (-V) options
调度选项(-V)
The -V options (-V, -VN. and -VR), which cause the compiler to generate debug information, can be combined on the command line.
选项-V、-VN、-VR会指示编译器生成调试信息,它们能在命令行中组合使用。
Generate Turbo Debugger debug info (-V) option
生成Turbo Debugger使用的调试信息的选项(-V)
When you specify the -V option on the command line, the compiler appends Turbo Debugger 5.0-compatible external debug information at the end of the executable file. Turbo Debugger includes both source- and machine-level debugging and powerful breakpoints.
当你在命令行中使用-V选项时,编译器会在可执行文件的末尾附加与Turbo Debugger5.0一致的外部调试信息。Turbo Debugger包含代码和硬件级别的强大的断点。
Even though the debug information generated by -V makes the resulting executable file larger, it does not affect the actual code in the executable, and does not require additional memory to run the program.
虽然附加调试信息到查执行文件中会使可执行文件增大,但是它并不影响实际可执行文件中的可执行代码,也不需要额外的内存来启动程序。
The extent of debug information appended to the executable file depends on the setting of the $D and $L compiler directives in each of the moles (program and units) that make up the application. For moles compiled in the {$D+,L+} state, which is the default, all constant, variable, type, procere, and function symbols are known to the debugger. In the {$D+,L-} state, only symbols defined in a unit's interface section are known to the debugger. In the {$D-} state, no line-number records are generated, so the debugger cannot display source lines whe

Ⅲ sublime text 3 for osx 快速编译打开html文件,在windows下快捷键是ctrl + b,在mac下command+b不行

1. 可以直接打开图片
版本3有个很好的特性(对于前端来说):可以直接在ST3中打开图片。

2. Goto Anything功能 — 快速查找(ctrl + P)
输入@+函数名可以快速找到函数。
输入#+文本可以快速进行文件内文本匹配。

3. 多行游标功能(ctrl + D,非常实用)
如何将文件中的某个单词更改为另一个?
方法一:利用查找替换功能:ctrl + H
方法二(推荐):多行游标功能,选中一个后,按ctrl+D可以同时选中另一个,同时多了另一个光标。
但多行游标能完成查找替换功能不能完成的工作。
比如在某些符合条件的语句后面添加新行,同时加入一些新的文本,如何快速的达到这一目的?
- 可以选中某一个模式,然后ctrl+D选中另一个,如果有某些不想添加新行的模式则按ctrl+K,ctrl+D跳过这个进入下一个符合条件的模式行。
- 还可以按Alt + F3快捷键全选所有符合条件的单词,产生多个光标,而不用一个个ctrl+D选中。
- 如果要在每行都加入光标,可以先ctrl+A然后ctrl+shift+L即可。
- 如果想在某个字符的多行后面加上光标,可以将光标放在这个字符后面,按住shift键,然后右键可以向下拖动产生多个光标。

4. 命令模式(应尽可能使用,而不用浪费脑细胞记忆大量命令的快捷键)
比如用ctrl+N新建一个文件后,默认是plain text,没有语法高亮功能,如何设置语法模式?
- 可以通过右下角的语法选择区选择希望设置的语法模式。
- 还有另一种更好的办法,即使用ctrl + shift + P打开命令模式,然后输入set syntax [language]设置为某种语言的语法模式,比如set syntax java则设置为java语法高亮。
- st3支持模糊匹配,你也可以直接输入syntax java或ssjava。
- 若当前已经是某种语言的语法模式,则可以直接输入其它语言进行切换(而不用输入set syntax或syntax了),比如当然为java语法模式,那么直接输入js就可以马上切换为javascript语法模式。
还可以输入minimap隐藏或显示右边的minimap缩影

5. 快速跳转到某一行
按下Ctrl + G,输入行号,可以快速跳转到该行。

6. 快速添加新行
Ctrl + Enter可以在当前行下新建一行。
Ctrl + Shift + Enter可以在当前行上面添加一行。

7. 多行缩进
选中多行后按Ctrl + ]可以增加缩进,按Ctrl + [可以减少缩进。
PS:发现用Tab和Shift + Tab也是可以的。

8. 完整拷贝,避免格式错乱
我们发现,在从别的文件中拷贝一段代码过来的时候,多半只是第一行缩进,后面都乱了,这时可以使用Ctrl + Shift + V进行粘贴,可以在粘贴的过程中保持缩进,这时格式都是正确的。

9. 重新打开关闭的标签
在Chrome里面,如果你不小心关闭了某个标签页并想恢复它,你可以按下Shift + Ctrl + T重新打开它。
在ST3中也一样,如果你不小心关闭了某个文件,可以按下Shift + Ctrl + T快速恢复。连续重复该按键,ST将会按照关闭的先后顺序重新打开标签页。

10. 按住shift + ctrl然后按←或→可快速选中一行中的某一部分,连续按扩大选择范围。
比如你需要将某一部分进行注释(ctrl+/)或删除,使用这个功能就很方便。

11. 上下移动行
定位光标或选中某块区域,然后按shift+ctrl+↑↓可以上下移动该行。

12. shift + ctrl + d可快速复制光标所在的一整行,并复制到该行之前。

13. Ctrl+Shift+M:选中花括号里面的全部内容不包括{}。

14. Ctrl+Shift+K:删除整行。

15. 快速关闭HTML里的标签
写html文件时利用快捷键Alt + .可以快速关闭某个标签,如写<html>后按Alt+.可以快速得到</html>。
但这样还是挺繁琐,可以使用前端插件Emmet插件,直接在新建的html文件里(首先得设置语法模式为html)直接输入!(代表html5格式的html文档)然后按下ctrl+E即可。

Ⅳ 在vba的用户窗体中,有一个文本框textbook1有一个命令按钮commandb

sub commandbutton1_click()
dim i as integer, xx as long '定义变量
xx = 1 '给变量xx赋初值
for i = 1 to 10 '循环
xx = xx * i '用循环计算1*2*3····*10的结果
next i '循环出口
textbook1.text = xx '念耐在文本仔兄春框textbook1中显示尘芦
end sub

Ⅳ 在vba的用户窗体中,有一个文本框textbook1有一个命令按钮commandb

这个简单啊,比较容易实现,上一位回答者的答案似乎可以

Ⅵ 硬件协议sdk如何打包

关注
从事Android开发久了不可避免的会接触对外接口的封装,下面本人就以自己写过的一个例子系统讲讲怎样对应用sdk的开发。

1.封装
我们在与其他公司合作的时候,往往会有技术方面的协作,但我们又不想过多的暴露我们某些技术方面的细节,比如:ip地址、技术参数、核心算法

于是我们会对这部分代码进行封装,这部分需要精通Java的设计模式。
下面上传我的项目:

这里写图片描述

新建一个Android工程,添加一个Model:musicdot。

musicdot是本人自己解析网络音乐的歌曲搜索请求实现的在线搜歌功能包。所以我将要对这部分代码进行封装打包,以达到隐藏具体搜索请求的目的。(由于司准备让整个项目打包成SDK,经过大量查阅打包SDK的博客,和自己的实践,我把打包过程,中间遇到的各种问题,踩过的坑简单的总结一下,让看到的道友少踩些坑。

一、创建一个workspace

可以在桌面新建个testSDK文件夹,在这个文件夹里创建个WorkSpace。如图:

二、创建SDK

1.打开workspace,创建一个project,如图:

2.选择Cocoa Touch Framework,如图:

3.创建framework,把framework添加到workspace里。如图:

三、创建SDKDemo

1.打开TestSDK.xcworkspace文件,创建project ,选择Single View Application。如图:

2.红框里的都选择TestSDK.xcworkspace。

这样就把SDK和demo都创建好了,这样创建SDK加demo可以方便调试,如果sdk中有问题,可以直接在SDK中断点调试。创建后的效果如图:

3.修改build settings 配置参数。如图:

更改参数,在Architectures下增加armv7s,并选中。将Build Active Architecture only设置为NO

四、添带局加你的项目代码到SDK中

如果你的项目用到了Xib,图片,mp3,storyboard等,那么你就要添加一个bundle资源包蠢竖让,把这些资源添加到资源包里。

五、创建bundle资源包。

1.在target中点击右下角的+号,选择macOS,找到Framework&Library,选择Bundle。如图:

2.修改配置文件:

"Base SDK" 设置为 "纤禅IOS"
"Build Active Architecture Only" 设置为 "YES"
"Debug Information Format" 设置为 "DWARF with dSYM File"
"Skip Install" 设置为 "NO"
"Strip Debug Symbols During Copy" 中"Release"模式设置为 "YES"
"IOS Deployment Target" 设置为 "IOS 9.0"(具体根据自己的项目,设置系统版本)
"COMBINE_HIDPI_IMAGES" 设置为 "NO"
3.在Build phases中添加Xib。如图:

4.选择bundle,command + B编译,如图:

编译之后,SDK工程下会多个bundle的文件夹,你可以把图片,MP3,plist文件放到该文件夹里,如图:

5.调用bundle资源包里的资源。

//调用自定义View的Xib

+(MyView *)instancePubView

{

NSArray * nibView = [[NSBundle mainBundle] loadNibNamed:@"testBL.bundle/MyView" owner:nil options:nil];

return [nibView objectAtIndex:0];

}

//调用视图控制器的Xib

-(instancetype)init{

NSBundle * bundle = [NSBundle bundleWithPath:[[[NSBundle mainBundle] resourcePath] :@"testBL.bundle"]];

self = [super initWithNibName:@"LoginViewController" bundle:bundle];

return self;

Ⅶ xcode 如何编译

Xcode 常用编译选项设置
在xcconfig文件中指定即可。
用标准库连接
LINK_WITH_STANDARD_LIBRARIES = YES如果激活此设置,那么编译器在链接过程中会自动使用通过标准库的链接器。
Info.plist 输出编码
INFOPLIST_OUTPUT_FORMAT = binary指定Info.plist文件的输出编码(默认情况下,输出与输入的编码保持不变),这个输出编码能指定“binary”或者“XML”。
生 成调试符号GCC_GENERATE_DEBUGGING_SYMBOLS = NO当启用的时候,详情等级能够通过build的’Level of Debug Symbols’设置去控制。 隐藏内联方法GCC_INLINES_ARE_PRIVATE_EXTERN = YES Objective-C GCGCC_ENABLE_OBJC_GC = Unsupported 优化级别GCC_OPTIMIZATION_LEVEL = Fastest, Smallest [-OS]
None: 不做优化使用这个设置,编译器的目标是减少编译成本,使调试产生预期的结果。
Fast:优化编译将为大函数占用更多的时间和内存使用这个设置,编译器将尝试减少代码的大小和执行时间,不进行任何优化,需要大量编译时间。
Faster:编译器执行几乎所有支持的优化,它不考虑空间和速度之间的平衡与“Fast”设置相比,该设置会增加编译时间和生成代码的性能。编译器不进行循环展开、内联函数和寄存器变量的重命名。
Fastest:开启“Faster”支持的所有的优化,同时也开启内联函数和寄存器变量的重命名选项
Fastest,smallest:优化代码大小这个设置启用“Faster”所有的优化,一般不增加代码大小,它还执行旨在减小代码大小的进一步优化。
C 语言方言GCC_C_LANGUAGE_STANDARD = C89 警告 检查Switch语句GCC_WARN_CHECK_SWITCH_STATEMENTS = YES 隐藏局部变量GCC_WARN_SHADOW = YES 隐式转换成32位的类型GCC_WARN_64_TO_32_BIT_CONVERSION = YES 未完成的Objective-C协议GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = YES 抑制所有的警告GCC_WARN_INHIBIT_ALL_WARNINGS = NO 初始化时没有完整的括号GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES例子(a没有完全的括号,b有):
int a[ 2 ][ 2 ] = { 0, 1, 2, 3 };
int b[ 2 ][ 2 ] = { { 0, 1 }, { 2, 3 } };
不匹配的返回类型
GCC_WARN_ABOUT_RETURN_TYPE = YES 缺少括号GCC_WARN_MISSING_PARENTHESES = YES例子:
{
if( a )
if( b )
foo();
else
bar();
}
{
if( a )
{
if( b )
foo();
else
bar();
}
}
在结构体初始化时缺少字段
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
缺 少函数原型GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES 在文件结尾缺少新行GCC_WARN_ABOUT_MISSING_NEWLINE = YES 选择了多个定义的类型(@Selector)GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO 严格的Selector匹配GCC_WARN_STRICT_SELECTOR_MATCH = YES 把缺少函数原型当作错误GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES 把所有的警告当作错误GCC_TREAT_WARNINGS_AS_ERRORS = YES 未定义的SelectorGCC_WARN_UNDECLARED_SELECTOR = YES 未初始化的自动变量GCC_WARN_UNINITIALIZED_AUTOS = YES 未知的Pragma指令GCC_WARN_UNKNOWN_PRAGMAS = YES 未使用的函数GCC_WARN_UNUSED_FUNCTION = YES 未使用的标签GCC_WARN_UNUSED_LABEL = YES 未使用的参数GCC_WARN_UNUSED_PARAMETER = YES 未使用的值GCC_WARN_UNUSED_VALUE = YES当一个语句计算的结果显式的未使用的时候发出警告 未使用的变量GCC_WARN_UNUSED_VARIABLE = YES 警告-所有过时的函数GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES offsetof宏未定义使用的警告GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = YES
iphone 常用的<app>-info.plist设置
Application requires iPhone environment如 果应用程序不能在ipod touch上运行,设置此项为true;
Application uses Wi-Fi如果应用程序需要wi-fi才能工作,应该将此属性设置为true。这么做会提示用户,如果没有打开wi-fi的话,打开wi-fi。为了节省 电力,iphone会在30分钟后自动关闭应用程序中的任何wi-fi。设置这一个属性可以防止这种情况的发生,并且保持连接处于活动状态
Bundle display name这用于设置应用程序的名称,它显示在iphone屏幕的图标下方。应用程序名称限制在10-12个字符,如果超出,iphone将缩写名 称。
Bundle identifier这个为应用程序在iphone developer program portal web站点上设置的唯一标识符。(就是你安装证书的时候,需要把这里对应修改)。
Bundle version这个会设置应用程序版本号,每次部署应用程序的一个新版本时,将会增加这个编号,在app store用的。
Icon already includes gloss and bevel effects默认情况下,应用程序被设置了玻璃效果,把这个设置为true可以阻止这么做。
Icon file(这个不用多说了)设置应用程序图标的。
Main nib file base name应用程序首次启动时载入的xib文件 这个基本用不到。
Initial interface orientation 确定了应用程序以风景模式还是任务模式启动
Localizations多语言。应用程序本地化的一列表,期间用逗号隔开,例如 应用程序支持英语 日语,将会适用 English,Japanese. Status bar is initially hidden 设置是否隐藏状态栏。你懂的。
Status bar style选择三种不同格式种的一种。
URL types应用程序支持的url标识符的一个数组。
用URL Scheme进行程序跳转
打开info.plist,添加一项URL types
展开URL types,再展开Item1,将Item1下的URL identifier修改为URL Scheme
展开URL Scheme,将Item1的内容修改为myapp
其他程序可通过myapp://访问此自定义URL
参考:http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
IOS后台播放音乐
OS后台播放只是在IOS4.0以后的版本支持。
1,设置后台播放会话
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setActive:YES error:nil];
[session setCategory: error:nil];
2,在info.plist里面添加
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
静态库没法包含category/分类?
如果你导入一个objc静态库,发现很多objc的category 不能调用,可以尝试在主工程中加入linker选项:
-all_load 加入这个一般就够了
-ObjC
让程序最小化再开启时,从头开始:
按下 “Home” 键以后程序可能并没有退出而是转入了后台运行。如果您想让应用直接退出,最简单的方法是:在 info-plist 里面找到 Application does not run in background 一项,勾选即可。
程序退出后任务栏还是有图标,但是程序原来的所有运行状态全部丢失,点击任务栏图标也不过相当于再次启动程序;如果允许后台运行,点击任务栏图标后会恢复程序中断时的界面。
本地化字符串:
在infoPlist.strings里面写
“string1″=”水果”
代码里面写 myLabel.text = NSLocalizedString(@”string1″, nil);
本地化的Bundle display name:
1)创建一个空文件,取名为InfoPlist.strings
2)对InfoPlist.strings进行本地化(Get Info -> Make Localization),然后设置需要的语言(如中文zh)
3)编辑不同的InfoPlist.strings文件,设置显示名字
CFBundleDisplayName = “名字”;
4)(这步不做貌似也可以)编辑Info.plist,添加一个新的属性Application has localized display name, 设置其类型为boolean,并将其value设置为选中状态
default图片的衔接问题:
程序开始后,手动加载default图片,然后进行过渡效果即可。
遍历目录:
NSString *appDocDir = [[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject] relativePath];NSArray *contentOfFolder = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:appDocDir error:NULL];for (NSString *aPath in contentOfFolder) { NSLog(@"apath: %@", aPath); NSString * fullPath = [appDocDir :aPath]; BOOL isDir; if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath isDirectory:&isDir] && !isDir) { [fileList addObject:aPath]; }}
IB:
不论写不写property的retain,由IBOutlet都会为对象加一个retainCount,所以只要连接了,就需要在viewDidUnload与dealloc中release并适当置为nil。
预先在IB里面加载好的文件(比如图片),即使释放了Controller,IB中的文件也不会被释放,直至内存警告,解决办法是较大的资源用代码加载。
UIWebView:
用代码加载UIWebView的内容,navigationType是UIWebViewNavigationTypeOther
CAAnimation:
一定要记得[self.view.layer removeAllAnimations];因为CAAnimation会retain它的delegate
设备型号识别,可通过审核:
+ (NSString*)getDeviceVersion{ size_t size; sysctlbyname("hw.machine", NULL, &size, NULL, 0); char *machine = (char*)malloc(size); sysctlbyname("hw.machine", machine, &size, NULL, 0); NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding]; free(machine); return platform;}
输出:
//@”iPad1,1″
//@”iPad2,1″
//@”i386″
逗号后面数字解释:(i386是指模拟器)
1-WiFi版
2-GSM/WCDMA 3G版
3-CDMA版
AppleTV(2G) (AppleTV2,1)
iPad (iPad1,1)
iPad2,1 (iPad2,1)Wifi版
iPad2,2 (iPad2,2)GSM3G版
iPad2,3 (iPad2,3)CDMA3G版
iPhone (iPhone1,1)
iPhone3G (iPhone1,2)
iPhone3GS (iPhone2,1)
iPhone4 (iPhone3,1)
iPhone4(vz) (iPhone3,3)iPhone4 CDMA版
iPhone4S (iPhone4,1)
iPodTouch(1G) (iPod1,1)
iPodTouch(2G) (iPod2,1)
iPodTouch(3G) (iPod3,1)
iPodTouch(4G) (iPod4,1)
判断ipad/iphone
12UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPadUI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone
或者
1[[[UIDevice currentDevice] model] isEqualToString:@"iPad"];
判断设备是否有摄像头
1[UIImagePickerController isSourceTypeAvailable:];

Ⅷ matlab2020b编译图标在哪里

菜单栏。
在菜单栏中找到编译按钮,然后进行相关的操作,如果菜单中没有出现,在command窗口(命令行窗口)中输入edit回车就行。
matlab编辑器窗口和主窗口分开还原的步骤。首先,在编辑器窗口下,按ctrl+shift+D,此时编辑器窗口和主窗口就合并在一起了。然后,在菜单栏中选择布局-默认,如下图。这样就恢复到原来的布局了。

Ⅸ 请问怎么在xcode里编译c++程序 刚入手mac 用的是 app store 里的xcode 谢谢

create new project -> mac os x下application -> command line tool -> next -> proctName&type [c++] -> next
编写完代码后点击左上角三角run就行了,或者command+B编译,或者直接command+R 运行

热点内容
红点角标算法 发布:2025-07-12 12:11:16 浏览:844
开心消消乐服务器繁忙什么情况 发布:2025-07-12 12:11:14 浏览:239
数据库的封锁协议 发布:2025-07-12 12:10:35 浏览:724
如何配置一台长久耐用的电脑 发布:2025-07-12 11:43:03 浏览:602
昆明桃源码头 发布:2025-07-12 11:38:45 浏览:568
大司马脚本挂机 发布:2025-07-12 11:38:35 浏览:459
数据库实时监控 发布:2025-07-12 11:31:33 浏览:743
vb6反编译精灵 发布:2025-07-12 11:23:12 浏览:998
模拟存储示波器 发布:2025-07-12 11:10:58 浏览:814
怎么查看安卓真实运行内存 发布:2025-07-12 11:08:39 浏览:883