xcode 编译可以编vc么,如果用vc的语言,可以在xcode 编译上编译出来么?

/blog/123/
[Update:&&provided a much much easier way to make Xcode notice new changes, the new simpler script is now included in the instructions.
Thanks Joachim!]
If you don’t see a problem with the way that Xcode manages ‘Resources’ (images, sounds etc.) then you probably have nothing to learn from this article. Xcode usually manages just fine if you only have a small project, with limited changes to resources, and
only a couple of applications and one person ever modifying them.
But, Xcode’s directory management is broken enough to become really annoying in larger projects. I’ll explain why, as well as offer a solution. This article focuses on iPhone development. A very similar problem exists when developing for Mac OS X, with a similar
but simpler solution, but I won’t go into it here.
Usually when you want to have an image or sound or any other resource in your iPhone application, you add it to Xcode, it is silently added to the ‘Copy Bundle Resources’ build phase, it might get converted or stripped back (pngs get quite heavily modified)
and then gets copied into the app bundle. You can then access it at runtime with NSBundle methods. Easy.
The problem only shows up when you want to have some kind of directory structure on disk. There are many reasons why you might want to do this. In a game, perhaps your levels are themselves directories. Perhaps you want to switch between different versions
of resources, or simply like to be a little more organized than having all of your resources at one level in one big-ass directory.
Xcode offers two options when you add a directory to the project. You can either add it as the default yellow ‘group’ or as a blue ‘folder reference’. The problem is, that both have pretty major limitations (and bugs).
The group option will never notice if the directory contents are added or removed. Every time you add or remove a file or directory in the file system, you will also have to change it in Xcode. Also, the directory structure is lost when it’s copied to the iphone
app, and so inside your app bundle is just a big list of all your resources in the base directory. As a result of this, duplicate filenames become an issue. If any files within your directory structure on disk contain the same filename, the build process silently
screws everything up. It appears to be ‘first in wins’, with only one of the resources making it into the app bundle. So it’s no good if you have a bunch of different level packages each containing a different ‘Terrain.png’ file.
Which means you have to use the other option, blue ‘folder references’. This&should&be the better option of the two no matter what you are doing. When you add or remove files, it usually gets noticed. You can safely have duplicate names, and you don’t
have to repeat your moving/renaming/adding etc. in Xcode. But the problem is, that when you externally change a file within a folder reference, Xcode doesn’t notice. So every time you modify an image file, you do a new build, fire it up, and think ‘It looks
the same as before’. Thats because it&is&the same as before. You need to do a clean build (or delete the app) to force Xcode to copy the resource directory structure again.
This is a pain, and if you’re like me, you will nearly always forget, wasting large amounts of time slowly making an image darker, but it still looks too light! Half an hour later realizing it never got copied to the app bundle.
So. A solution.
I made a top level directory I called ‘GameResources’ inside of which are all the app’s resource files and sub-directories. It is important not to call this directory ‘Resources’, as it seems to confuse Xcode into giving a lot of ‘Application is already installed’
1) Add your single resource directory (named anything but ‘Resources’) to your project in the Resources section as a blue ‘Folder Reference’
2) Right click on your app target, select Add-&New Build Phase-&New Run Script Build Phase
3) In the resulting ‘Info’ window, change the shell to /bin/tcsh and copy and past the script below into the ‘Script’ text view.
touch -cm ${SRCROOT}/../../GameResources
How it should look:
4) Change the directory to your resource directory. In my case it is ‘GameResources’, a couple of levels above the source directory, but usually if your resources are located in the same directory as your Xcode project it would be simply ${SRCROOT}/MyResources
5) Change the order of the build phases (by dragging the Run Script one you just created) so that it is run just after the Copy Bundle Resources build phase. This may not be necessary, but it feels right. Leave the ‘Copy Bundle Resources’ build phase alone,
it doesn’t do any harm, and is needed for distribution builds.
6) Before this, you probably used [[NSBundle mainBundle] resourcePath] or pathForResource:. These won’t work anymore, as all your resources are now inside ‘GameResources’ or whatever. [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@”GameResources”]
or similar will need to be used instead.
A couple of notes – You can edit the script by double clicking the ‘Run Script’ build phase, it’s not entirely obvious. And if you have renamed your debug configuration you probably need to modify the if statement at the top of the script.&
And finally, this might not work at all for any number of reasons. I probably won’t be able to help you with any problems, but hopefully it will save someone some time and frustration.&
Maybe someone at Apple might even see this, notice the hoops we have to jump through, and be more inclined to fix the damn thing properly!
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:49929次
积分:1331
积分:1331
排名:第13352名
原创:84篇
转载:14篇
(1)(4)(6)(1)(2)(11)(5)(5)(1)(1)(2)(1)(1)(1)(4)(4)(3)(2)(3)(2)(1)(1)(4)(2)(1)(4)(1)(1)(3)(5)(5)(7)(2)(1)(1)(1)随笔 - 837&
评论 - 63&
&&&&&&&&&&&
此帖纯粹讨论怎样更改xcode配置来使其支持创建iphone上的dylib工程文件,不涉及任何其他破解话题!测试机器:10.6 with Xcode3.2最近在研究如何创建iphone上的dylib文件,google出来的都是toolchain的东西,使用makefile来编译的,像我这种习惯IDE的人来说非常之不爽,所以花了一天时间来破解了下Xcode来让它可以创建编译iphone上的dylib文件的工程。简单说下分析思路吧首先xcode支持创建iphone static libtary和Cocoa的dynamic linrary的工程,通过不同编译对比可以发现Xcode通过productType = "com.apple.product-type.library.dynamic";配置来确定工程类型的。打开**.xcodeproj/project.pbxproj文件,搜索productType=定位,可以发现如下图所示的内容[attachment=10545]&可以创建一个iphone的static工程把static改成dynamic编译看看,可以发现xcode提示不支持dynamic类型的工程,无法编译,那我们让他支持就好了。我们需要修改以下文件/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/iPhoneOSProductTypes.xcspec/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/iPhoneOSPackageTypes.xcspec在iPhoneOSProductTypes.xcspec中添加下列片段// Dynamic library&&&&{&& Type = ProductT&&&&&&&&Identifier = com.apple.product-type.library.&&&&&&&&Class = PBXStaticLibraryProductT&&&&&&&&Name = "Dynamic Library";&&&&&&&&Description = "Dynamic library";&&&&&&&&IconNamePrefix = "TargetLibrary";&&&&&&&&DefaultTargetName = "Dynamic Library";&&&&&&&&DefaultBuildProperties = {&&&&&&&&&&&&FULL_PRODUCT_NAME = "$(EXECUTABLE_NAME)";&&&&&&&&&&&&MACH_O_TYPE = "mh_dylib";&&&&&&&&&&&&REZ_EXECUTABLE = YES;&&&&&&&&&&&&EXECUTABLE_PREFIX = "";&&&&&&&&&&&&EXECUTABLE_SUFFIX = ".$(EXECUTABLE_EXTENSION)";&&&&&&&&&&&&EXECUTABLE_EXTENSION = "dylib";&&&&&&&&&&&&PUBLIC_HEADERS_FOLDER_PATH = "/usr/local/include";&&&&&&&&&&&&PRIVATE_HEADERS_FOLDER_PATH = "/usr/local/include";&&&&&&&&&&&&INSTALL_PATH = "/usr/local/lib";&&&&&&&&&&&&DYLIB_INSTALL_NAME_BASE = "$(INSTALL_PATH)";&&&&&&&&&&&&LD_DYLIB_INSTALL_NAME = "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)";&&&&&&&&&&&&DYLIB_COMPATIBILITY_VERSION = "1";&&&&&&&&&&&&DYLIB_CURRENT_VERSION = "1";&&&&&&&&&&&&FRAMEWORK_FLAG_PREFIX = "-framework";&&&&&&&&&&&&LIBRARY_FLAG_PREFIX = "-l";&&&&&&&&&&&&LIBRARY_FLAG_NOSPACE = YES;&&&&&&&&&&&&STRIP_STYLE = "debugging";&&&&&&&&&&&&GCC_INLINES_ARE_PRIVATE_EXTERN = YES;&&&&&&&&&&&&CODE_SIGNING_ALLOWED = NO;&&&&&&&&};&&&&&&&&PackageTypes = (&&&&&&&&&&&&com.apple.package-type.mach-o-library&& // default&&&&&&&&);&&&&},在iPhoneOSPackageTypes.xcspec中添加下列片段// Mach-O dynamic library&&&&{&& Type = PackageT&&&&&&&&Identifier = com.apple.package-type.mach-o-&&&&&&&&Name = "Mach-O Dynamic Library";&&&&&&&&Description = "Mach-O dynamic library";&&&&&&&&DefaultBuildSettings = {&&&&&&&&&&&&EXECUTABLE_PREFIX = "";&&&&&&&&&&&&EXECUTABLE_SUFFIX = ".dylib";&&&&&&&&&&&&EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)";&&&&&&&&&&&&EXECUTABLE_PATH = "$(EXECUTABLE_NAME)";&&&&&&&&};&&&&&&&&ProductReference = {&&&&&&&&&&&&FileType = compiled.mach-o.&&&&&&&&&&&&Name = "$(EXECUTABLE_NAME)";&&&&&&&&&&&&IsLaunchable = NO;&&&&&&&&};&&&&},文件附上,可以直接下载替换,替换/修改前做好备份[attachment=10546]现在再编译应该不会提示工程不支持了,那么剩下的就是改变其编译选项了,就是libtool的参数问题。我们需要修改下列文件/Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/Libtool.xcspec/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS Build System Support.xcplugin/Contents/Resources/iPhoneLinkerOptions.xcspec在Libtool.xcspec中添加下列片段{&& Identifier = com.apple.pbx.linkers.&&&&Type = L&&&&Class = PBXLinkerSpecificationL&&&&Name = "Libtool";&&&&Description = "Create a dynamic library using Apple Mach-O Librarian (libtool)";&&&&IsAbstract = Y&&&&&& // This is an internal tool, so we keep it out of the user interface&&&&BinaryFormats = (mach-o);&&&&Architectures = (ppc, ppc7400, ppc7450, ppc970, ppc64, i386, x86_64);&&&&CommandLine = "$(LIBTOOL) -dynamic -arch_only $(arch) -compatibility_version $(DYLIB_COMPATIBILITY_VERSION) -current_version $(DYLIB_CURRENT_VERSION) [options] [special-args] -o $(OutputPath)";&&&&&&// 'special-args' includes the input files&&&&RuleName = "Libtool $(OutputPath) $(variant) $(arch)";&&&&ExecDescription = "Create Dynamic Library $(OutputPath:file)";&&&&InputFileTypes = (&&&&&&&&compiled.mach-o.objfile&&&&);&&&&Outputs = (&&&&&&&&// We're a linker-like task, so we expect to be given an output path in 'OutputPath'.&&&&&&&&"$(OutputPath)"&&&&);&&&&CommandOutputParser = XCGccCommandOutputP&&&&Options = (&&&&&&&&// LIBTOOL&&&&&&&&{&& Name = LIBTOOL;&&&&&&&&&&&&Type = P&&&&&&&&&&&&DefaultValue = "$(PLATFORM_DEVELOPER_BIN_DIR)/libtool";&&&&&&&&},&&&&&&&&// SDK&&&&&&&&{&& Name = SDKROOT;&&&&&&&&&&&&Type = P&&&&&&&&&&&&CommandLineFlag = "-syslibroot";&&&&&&&&&&&&IsInputDependency = Y&&&&&&&&},&&&&&&&&// Search paths&&&&&&&&{&& Name = LIBRARY_SEARCH_PATHS;&&&&&&&&&&&&Type = PathL&&&&&&&&&&&&FlattenRecursiveSearchPathsInValue = Y&& // causes any paths that have a '/**' suffix to be replaced with matching paths&&&&&&&&&&&&CommandLinePrefixFlag = "-L";&&&&&&&&},&&&&&&&&// Input file lists&&&&&&&&{&& Name = __INPUT_FILE_LIST_PATH__;&&&&&&&&&&&&Type = P&&&&&&&&&&&&DefaultValue = "$(LINK_FILE_LIST_$(variant)_$(arch))";&&&&&&// this is set up for us as a read-only property&&&&&&&&&&&&CommandLineFlag = "-filelist";&&&&&&&&&&&&IsInputDependency = Y&&&&&&&&},&&&&&&&&{&& Name = auxiliary_file_&&&&&&&&&&&&Type = PathL&&&&&&&&&&&&CommandLineFlag = "-filelist";&&&&&&&&&&&&IsInputDependency = Y&&&&&&&&},&&&&&&&&// Various flags&&&&&&&&{&& Name = ALL_OTHER_LIBTOOLFLAGS;&&&&&&&&&&&&Type = StringL&&&&&&&&&&&&DefaultValue = "$(LD_FLAGS) $(SECTORDER_FLAGS) $(OTHER_LDFLAGS) $(OTHER_LDFLAGS_$(variant)) $(OTHER_LDFLAGS_$(arch)) $(OTHER_LDFLAGS_$(variant)_$(arch)) $(OTHER_LIBTOOLFLAGS) $(OTHER_LIBTOOLFLAGS_$(variant)) $(OTHER_LIBTOOLFLAGS_$(arch)) $(OTHER_LIBTOOLFLAGS_$(variant)_$(arch)) $(PRODUCT_SPECIFIC_LIBTOOLFLAGS)";&&&&&&&&&&&&CommandLinePrefixFlag = "";&&&&&&&&},&&&&&&&&{&& Name = EXPORTED_SYMBOLS_FILE;&&&&&&&&&&&&Type = P&&&&&&&&&&&&Condition = "$(SEPARATE_SYMBOL_EDIT) == NO";&&&&&&&&&&&&CommandLineFlag = "-exported_symbols_list";&&&&&&&&&&&&IsInputDependency = Y&&&&&&&&},&&&&&&&&{&& Name = UNEXPORTED_SYMBOLS_FILE;&&&&&&&&&&&&Type = P&&&&&&&&&&&&Condition = "$(SEPARATE_SYMBOL_EDIT) == NO";&&&&&&&&&&&&CommandLineFlag = "-unexported_symbols_list";&&&&&&&&&&&&IsInputDependency = Y&&&&&&&&},&&&&&&&&{&& Name = AdditionalCommandLineA&&&&&&&&&&&&Type = StringL&&&&&&&&&&&&CommandLinePrefixFlag = "";&&&&&&&&},&&&&&&&&{&& Name = MACOSX_DEPLOYMENT_TARGET;&&&&&&&&&&&&Type = S&&&&&&&&&&&&SetValueInEnvironmentVariable = "MACOSX_DEPLOYMENT_TARGET";&&&&&&&&},&&&&);},在iPhoneLinkerOptions.xcspec中搜索BasedOn = "default:com.apple.pbx.linkers.libtool";替换成BasedOn = "default:com.apple.pbx.linkers.libtooldynamic";这样修改后编译iphone的library工程师都会使用dynamic的参数来编译,注意:如果要编译iphone static library这里需要将libtooldynamic修改回libtool并重启Xcode(唯一的小缺陷,应该可以通过hook xcode编译设置函数来动态修改,很麻烦,需要很多时间去找到相应的方法,找了一会儿就没高兴继续,先将就用吧)做好以上工作后就可以创建并编译iphone上dynamic library的工程了。这里附上工程和target模板文件[attachment=10547]解压此zip得到Cocoa Touch Dynamic Library文件夹,将其放到/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Library/下面[attachment=10548]解压此zip得到Dynamic Library.trgttmpl文件,将其放到/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Target Templates/Cocoa Touch/下面重启Xcode就可以看到了,如图[attachment=10549]&&[attachment=10550]&测试结果[attachment=10551]&使用otool查看编译出来的dylib文件[attachment=10552]&成功!谨记!!!!!需要修改文件来切换回编译static library!!!
阅读(...) 评论()iOS用Xcode作为编译环境Object-C作为编写语言,那么Mac上的程序,编写语言和编译环境又是什么呢?
| 更新于 日
如题,小白比较好奇
。。。有种搜索叫google。
@ 我感觉楼主是来调戏你们的,你们还这么认真。。。
本帖有3个回复,因为您没有注册或者登录本站,所以,只能看到本帖的10条回复。如果想看到全部回复,请注册或者登录本站。
),然后在出现的“enter code here”处贴入你的代码。
回复特定回复的时候,请点击该回复右侧的回复链接,系统将自动创建楼号和@通知。
@他人的时候注意,id后面请加一个空格。
使用左侧工具栏“贴链接”按钮()创建的优酷、土豆、youtube视频链接,将自动生成播放区域,不需要使用其他包含方式。
如果要创作长篇格式复杂的帖子,本站建议Mac用户使用,离线写好,贴入即可。xcode编译完后,可执行文件在哪里?_macbookair吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:39,312贴子:
xcode编译完后,可执行文件在哪里?收藏
这个吧里能回答你这个问题的人不多
在debug的product里面。。。
登录百度帐号我的游戏推荐游戏
后查看最近玩过的游戏
为兴趣而生,贴吧更懂你。或}

我要回帖

更多关于 xcode 编译 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信