Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode - adding it to library #1300

Closed
changheon1 opened this issue Oct 16, 2018 · 11 comments
Closed

Xcode - adding it to library #1300

changheon1 opened this issue Oct 16, 2018 · 11 comments
Labels
state: needs more info the author of the issue needs to provide more details

Comments

@changheon1
Copy link

Using XCode and Cmake for my project.
screen shot 2018-10-16 at 6 49 18 pm

I am stuck on how to get json to be added to the library.
What I want to do is:
I have my codes inside work/src/ folder and have json files inside work/vendor.
Inside build I have done the cmake commands. (cmake -G Xcode ../work)
after it builds I run my code in XCode but the
#include <nlohmann/json.hpp> is not found and I get heaps of errors in the json file.

I think this occurs because I am not adding a 'Link Binary with Libraries' for XCode but it's weird how I don't have that in 'Build Phase'
screen shot 2018-10-16 at 6 55 38 pm

Any help would be appreciated!

@changheon1
Copy link
Author

Okay.. I've finally added #include <nlohmann/json.hpp> and it doesn't throw an error on that but not I am getting endless errors on the actual json.hpp file
screen shot 2018-10-16 at 9 11 05 pm

I think I'm the only one with this kind of issue but I really hope to fix this...
Any help would be appreciated thanks..

@nlohmann
Copy link
Owner

That is really strange, because we can compile and run the unit tests with Xcode. Could you try to compile the unit tests?

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Oct 16, 2018
@jaredgrubb
Copy link
Contributor

This looks like a too-early version of C++. What version of C++ are you compiling with? (Eg, can you copy-paste the command line that is being executed to compile this?)

@nlohmann
Copy link
Owner

FWIW: The library is tested with Xcode 6.4-10.0, see https://github.com/nlohmann/json#supported-compilers.

@changheon1
Copy link
Author

Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I did update my mac 2 days ago with Xcode because it wouldn't update the build, also my lecturer has updated that because of the same reason.

So what I've tried is:

  1. If I use cmake browse source just on the json-3.3.0 and compile, it generates no errors whereas if I do the browse source on my work folder and generates it, it generates heaps of errors as you can see for the second image.
  2. I went into the 'build -> vendor -> json-3.3.0' and opened the project folder then built it, generates just hundreds of errors. Weird how this one looks the same with step 1) with no error version but still generates errors.

44149981_364011757474513_9018590787910238208_n

Maybe it's not the version of the Xcode or the c++ version, I may be missing out a step since it did generate no errors for the first step.
Cheers.

@changheon1
Copy link
Author

Maybe the c++ or the Xcode version.. I've tried heaps of other way but getting same error.

Tried only building using json and it thought it wouldn't generate any errors but after making a main.cpp and #include <nlohmann/json.hpp> then using json=nlohman::json it generated same errors as before.
Any suggestions for this issue?

@jaredgrubb
Copy link
Contributor

Can you copy-paste the command line invocation used? The fact that you're getting a failure around "enable_if_t" suggests that you probably don't have C++14 turned on. Or just look in your Build Settings to see what the version of C++ you have enabled.

@changheon1
Copy link
Author

I used
cmake -G Xcode (filename)

Couldn't find anything to allow c++ 14 or similar to my build setting

@changheon1
Copy link
Author

screen shot 2018-10-17 at 1 37 24 pm

I did find enabling c++14 but still generates same errors...

@nlohmann
Copy link
Owner

Could you please try the following just to make sure it's nothing fundamentally wrong:

  • In Terminal.app, go to the directory where you put the contents of this repository.
  • mkdir build
  • cd build
  • cmake .. -GXcode
  • open nlohmann_json.xcodeproj
  • In Xcode, select scheme "ALL_BUILD" and build it.
  • Select scheme "RUN_TESTS" and run it.

This should finish without error (though take a while).

@nlohmann
Copy link
Owner

Any news on this?

@nlohmann nlohmann closed this as completed Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs more info the author of the issue needs to provide more details
Projects
None yet
Development

No branches or pull requests

3 participants