How to enable libraries without a framework when writing CodeRunner documents?

I used CodeRunner to collect small pieces of code that are often used in development, but do not necessarily belong to codebase for the project. This is a great summing tool in Objective-C and Cocoa, because I can enable the frameworks installed on my machine.

However, sometimes I want to enable functionality from external sources that are not frameworks like ASIHTTPRequest. If I put the ASIHTTPRequest files in the nearest folder and #include , I get errors about "Undefined symbols for architecture x86_64: _OBJC_CLASS_$_ASIHTTPRequest" , which I assume means that the ASI files simply are not compiled and are not associated with the CodeRunner document - this one file is compiled, not a project. In Xcode, I would add ASIHTTPRequest files to the project and they will be automatically compiled and linked to the rest of the code, which is equivalent when I do not use Xcode?

I can enable custom arguments and flag compilation (the latter contains -std=c99 -framework Foundation by default), and I suspect that I need to fine-tune them somehow, but I could not figure out how to do this.

+4
source share
1 answer

I have earned. Of course, gcc requires some additional parameters to communicate with ASIHTTP modules. Here is what I ended up with:

 -std=c99 -framework SystemConfiguration -framework CoreServices -framework Foundation -lz -I/path/to/asi-header-files -filelist /path/to/list-of-asi-compiled-modules 

I assume that your code simply included paths to ASIHTTPRequest.h header files, etc ... if you use explicit paths there, you don't need the -I switch above. gcc must have a compiled version of the code from ASIHTTPRequest.m and friends in order to link to it. One way to do this is to compile the "Mac" project that comes with the library. This will create .o files in one of those deep-buried DerivedData directories that Xcode likes to do. The one he did for me is:

 ~/Library/Developer/Xcode/DerivedData/Mac-flsjygxmngizhzfwnfgcakejmwkx/Build/Intermediates/Mac.build/Debug/Mac.build/Objects-normal/x86_64 

(I think the “Mac-flsjygxmngizhzfwnfgcakejmwkx” bit will be different for you.) There are many .o files and a “Mac.LinkFileList” file in this directory. This file is the one you specify for the -filelist option for gcc. You will need to remove the links to the main.o, AppDelegate.o and ASIWebPageRequest.o files so that you do not get duplicate characters during the link stage.

In addition to the ASIHTTPRequest headers and .o files, gcc will reference the SystemConfiguration infrastructure, CoreServices, and the zlib library, since ASIHTTPRequest has these dependencies.

If you conduct many tests with this library, I would recommend duplicating the definition of the language "Objective-C" (in the "Preferences" section) as "Objective-C with ASIHTTPRequest" or something else. You can then configure compilation flags to work with ASIHTTPRequest without doing this for all Objective-C code that you run.

You can also copy the .o files and the LinkFileList file to a more permanent location, just in case Xcode clears this assembly tree or something else.

+3
source

Source: https://habr.com/ru/post/1391724/


All Articles