I need to read / write Xcode project definition files (myproject.xcodeproj/project.pbxproj) - is there any formal specification of the file format which I can use to create a parser?
You can start with this introduction. Then look at some kind of reference here.
There is also Apple's description of core concepts (projects, targets, workspaces, schemes).
As best I know, it is an internal implementation detail of Xcode. It would be surprising if there were a formal definition.
pbxproj files seem to be implemented using some internal implementation of NSCoder; "isa" is Objective-C's internal name for a "class name", and the mention of "archive" reminds of NSArchiver/NSKeyedArchiver, concrete implementations of NSCoder.
pbxproj looks like an archive of a dictionary of objects which probably serve as Xcode's internal in-memory model of project. It refers to numerous class names which seem to be Xcode's model classes.
I am unaware of a formal spec of either the archive format nor the classes. That is what I came to ask on SO today in fact: which NSCoder is here used by Apple. On the other hand, writing something that would decode this object tree, and then identify the purpose and connections between objects, is how I was going to proceed.
Related
I am using TreeHugger to generate code at runtime. I could not find many documents related to it. My question is, if I generate classes using treehugger, will I be able to access those classes in future?
To be precise: I want to read data coming from files like CSV and create classes at runtime . Can I use that class in future, say in the next class generated at runtime.
I am really new to scala, please forgive if I am not clear in explaining.
Thanks a lot!
I've done something similar, so I'll share what I've learned:
Treehugger ultimately generates code (strings) at runtime to be used in a subsequent, separate run (or I suppose to be eval'd at runtime, but I never got that to work).
So the course of action depends on what you mean by "runtime":
Are your .csv files only available at runtime? If you have access to the files at compile time (as is often the case), then are examples of your two options: experimental (scala macros) or traditional (sbt plugin) -- both approaches are similar but have subtle pros and cons.
If you only have access to the files at runtime, but still need to generate and "type" the classes and make the compiler expect them, then it seems to me that somebody has made a bad design mistake! But if you find yourself stuck in this circumstance, then it is possible to define and load classes at runtime with a bytecode-engineering library and some type-checker black magic (runtime type provider).
Just starting to learn scala for a new project. Have got to the point where I would like to define different properties files for the different environments the app is going to run on, ideally in a similar way to Rails - very lightweight, just one different properties file per environment that is loaded based on its name. I don't really care if it's a java properties file, YML or scala code.
In the spirit of not reinventing the wheel I've been looking to see if there is some accepted standard Scala way of doing this but I can't find one, I've found a few similar but not identical questions here where people suggest using system properties in the startup script but this feels like it would end up being a nightmare.
I could obviously implement it if needs be but feels like the sort of thing that should already exist. So - does it?
I'm using sbt if that makes a difference.
I know of Configgy. Also, Akka/Play 2.0 will be using Config, which looks nice too. See blog about the latter.
Basically, Configgy has been used for a while now, but has been deprecated, while Config will be all-new. However, having Config as the default Typesafe Stack configuration tool will probably make it the preferred tool for that pretty fast.
I have written a Configgy replacement called Configrity. It can use different input formats (like YAML), it's immutable, supports functional patterns and uses type class to convert automatically the values to the desired type.
I have written BeeConfig, a replacement for java.util.Properties except that it is a Scala API and uses UTF-encoded configuration files. It supports string interpolation, chaining and a bunch of other features. But its main objective is simplicity.
Bitbucket | Blog post
Rick
I am facing an issue where I am getting a compile time error which says duplicate symbol _OBJC_CLASS_$_XYZ in lib1 and lib 2. Looks like the class name is same in both the libs.
How to get rid of this situation? Any clue.
Simple: Change the name of one of the classes. (No, this really isn't simple as you have to change every usage of that class name in the library). Since objective-c is a dynamic language, there cannot be two classes with the same name. Classes are used at runtime to determine everything about the objects you create. To avoid naming conflicts, you should always use prefixes when creating shared libraries.
See Code Naming Basics, specifically the "Class and Protocol Names" section.
Looks like you must rename one of them or have only one loaded at any given time.
What is the best way to solve an Objective-C namespace collision?
Trying to code to an interface so that unit testing and design are better. Some things that I am coding doesn't seem to have any other implementation other than the obvious one. Is there a naming convention for this?
If you've only got one implementation, why not name your interface after it? You can always refactor the name later, if a second implementation comes along.
Most of the time, we do name our interfaces after the implementation that inspired them. If we then find that we get a second implementation of that interface, we'll either rename the original implementation to be more specific or rename the interface to be more general.
I need to define simple classes and interfaces (Ex. IClassInterface) in a language neutral way and then use a variety of code generation tools to generate the code files in a variety of languages such as C#, Java, etc... Does anyone know of a standard; ratified or otherwise; that I can use for the neutral representation. I know UML is often used for creating diagrams, but I am actually looking for something that can easily be parsed, extended, and used to drive other automated processes. Maybe this is actually possible with UML, although I am not sure what the markup language might look like if one exists.
I could create my own definition using XML or something similar, but I would prefer to avoid reinventing the wheel if possible.
UML
I think you might be looking for XMI (XML Metadata Interchange)
There is IDL (for example, Google's protocol buffers), and WSDL, which can be used to produce interfaces and classes by many web service frameworks. (You typically do not have to use the generated code as an actual webservice.)
The wikipedia entry for IDL lists a number of implementations of IDL. Although IDL is mainly for describing interfaces, some implementations also use it to describe objects (e.g. Microsoft IDL.)