Just an FYI the framework, nor any of the files required to build the framework are included with the latest 2.3 DMG, I am not sure if this was deliberate but its very confusing to me that the source is only the .h and .m files and not the actual XCode project you would use to build the framework too?
It is deliberate, because so many people tried to use the framework in their iPhone app. (Which obviously doesn't work.)
The "source" is literally that - classes for you to drop into your existing project, to make it as simple as possible to use. If you want to build the framework, just download it from github.
I can see it being confusing though, and would like to hear suggestions for how to improve the situation.
Sure but the thing is that I did the exact opposite, I tried to drop the source files into my Mac app and it didn't work because you have a conditional include in the JSON.h file...
...It presumes that the target OS must be Mac and that it must be in the form of a framework.
My suggestion would be to include both, one in a folder named iPhone, another in a folder named Mac...
Alternatively you could put up a JSON_(iPhone)2.3.dmg and JSON(Mac)_2.3.dmg
I'm confused; I don't understand why dropping the JSON folder into your application doesn't work for you - it work for me, but only with the conditional you cite above in place...
Okay, so you drop the folder from the DMG into your Classes folder as advised, add the #include "JSON.h", then compile...
You can't use because its not a framework its just a class at this point, and if you use "JSON.h" it says its not able to find the other files because again they are referenced as in JSON.h.
So you have to either edit the Mac includes not to use the framework style include or you have to provide the xcode project so the person can use that to compile the framework them selves.
If you only give the classes then they can't use those.
I don't understand why you can't use in your app. Your Classes folder surely is on your include path? It should just work, I thought.
I'm assuming that you end up with Classes/JSON/JSON.h, and not Classes/JSON.h by the way.
Because if you simply include those files... you should be using #include "JSON.h"
Where as if its an actual real .framework folder it should be #include
However as you don't provide either the source code to make a .framework nor the actual compiled framework that means you are limited to only being able to use #include "JSON.h" and because again your code expects if its a Mac OS not iOS device that the files are in a .framework it looks for the other headers in #include which is again wrong because you are talking about a set of classes not a framework.
Does this make sense?
Hmm... I think I see it now.
Do you have any suggestions for how to make this work properly in all these cases?
I think the first three should be similar, but the last is not. Suggestions?
Well again I think your missing the point...
There is no JSON.framework in the DMG compiled or otherwise and simply creating an XCode Cocoa Framework project and dragging the files in is not enough to build a framework and its already to complicated, you need to add the entire source and XCode project into the DMG, I suggest as either:
It seems like you've fixed the simple iPhone problem in exchange for a more complicated Mac one.
I don't think I'm missing the point. The lack of a JSON.framework or .xcodeproj in the DMG is deliberate. The DMG is meant to be the simplest possible way to get started using JSON in your application, be it for the iPhone or the Mac.
Regardless of whether you're writing an iPhone or Mac application you should be able to just drag the "JSON" folder into your app compile, and go. This works just fine for me. That it doesn't work for you (and others) is a bug. Let that be clear.
Advanced users (like you and I) prefer to link to the framework rather than copying the sources. However, some people want debug information and others don't; I don't want to provide all permutations, so don't want to distribute binaries.
For the Mac it is relatively simple to just do external dependency on the project. You can do that with the unchanged source tree downloaded straight off github. I agree that it's not as well advertised as the DMG, but if you visit the download page you'll find tar/zip files for both the master branch and tag v2.3 ready for download.
Here are two example projects (as I'm sure you don't need, but can be useful to others reading this ticket):
yeah i had this problem too, what i did what just remove those preprocessor directives and run vanilla imports, the assumption being that we would use as a framework if it were not an iphone project...
I've just pushed a new branch, nodmg, where I try to address this problem. Can you please check it out and see if it fixes it?
Get branch as .zip file
What I've done is just use the simple #import "..." style by default, and transform that at build time into the proper framework/library style. I think this should cover all use cases.
experiment with sections #2