Wednesday, September 3, 2014

Building Bitcoin Core with XCode

For this walkthrough I'll be using Bitcoin Core version 0.9.3, XCode 5.1.1 with the command line tools package installed, and Homebrew (http://brew.sh/).

1. Download the source code:
git clone git@github.com:bitcoin/bitcoin.git bitcoin

2.  Install dependencies:
brew install autoconf automake libtool berkeley-db4 boost miniupnpc openssl pkg-config protobuf qt

3. After dependencies are installed, you need to make sure you have the correct version of openssl:
openssl version
You should see OpenSSL 1.0.1h 5 Jun 2014. If you do not then, you need to ask Brew to force create the proper links:
brew link openssl --force

4. Build bitcoind:
./autogen.sh
./configure
make

If you encounter an error about not being able to find Boost System like I did, try force linking boost as well:
brew link boost --force

5. Verify that you can run bitcoind:
cd src
./bitcoind

6. You will probably see an error about your bitcoin.conf file. Follow the given instructions to setup your bitcoin.conf file in the appropriate place. If you want to use Bitcoin testnet which is a good idea for development, make sure to enable that option in the bitcoin.conf file.

7. Create a new project in XCode. When it asks for the type, you can just select "Empty".

8. Add a target named bitcoind in XCode (Editor->Add Target). When it asks for a Template select "Other->External Build System". We do this because Bitcoin Core uses Makefiles. We could instead setup the build using XCode's buid settings, but that would be pretty pointless from my perspective because Makefiles work just fine, and since Bitcoin Core uses the Makefile system, everything is auto configured for us. If you were to contribute to Bitcoin Core you would also need to use their Makefile system to make sure your changes work under those conditions.

9. Go to the new target settings and enter the path to your cloned Bitcoin Core code folder:


9. Try building. You should be able to build, but not run.

10. Edit the scheme to add the run executable:

11. Add the entire Bitcoin Core src folder into the project file list (Right click on the project click "Add Files").

12. Create a breakpoint to see if you can stop on it when you run the application. I made one in bitcoind.cpp just under the start of the main function:

13. Try running the application. In my case it did not stop on the breakpoint.

14. In the scheme options add a custom working directory. It should point to the src folder of the Bitcoin Core source code. This is the same folder that contains bitcoind:

15. Save your project, close XCode and reopen it. I don't know why, but for me it didn't work till I did this.

16. Run and hopefully now it hits the breakpoint. You're in!

**Special thanks to Gavin Andresen for writing up command line instructions which were referenced in writing this**

10 comments:

  1. Hi,
    Two years on and I'd like to thank you for this great article!

    In Xcode8, the breakpoint stopped on the first run for me.
    Thanks again,
    Teddy Gott

    ReplyDelete
  2. Great Information sharing .. I am very happy to read this article .. thanks for giving us go through info.Fantastic nice. I appreciate this post.

    ReplyDelete
  3. For building fully offline including attaching signatures to unsigned builds, the detached-sigs repository and the bitcoin git repository with the desired tag must both be available locally, and then gbuild must be told where to find them. It also requires an apt-cacher-ng which is fully-populated but set to offline mode, or manually disabling gitian-builder's use of apt-get to update the VM build environment. coin-banks

    ReplyDelete
  4. The very fact that it doesn't have a central authority raises some questions. So this friend of mine asked me a few questions which I will uphold and will try to explain as well. how to buy bitcoins online

    ReplyDelete
  5. Despite the fact that enlisting the perfect individuals for your business sounds self-evident, it can be a truly intense activity for entrepreneurs.digital business transformation

    ReplyDelete
  6. Just admiring your work and wondering how you managed this blog so well. It’s so remarkable that I can't afford to not go through this valuable information whenever I surf the internet! JUBELIRERSTRATEGIES

    ReplyDelete
  7. For most people who are just getting their feet wet in the world of investing website, the stock market proves to be the most popular option. It’s as if every investment guru advocates investing in stocks as a means of growing money over the long term. Compound interest is a real thing, and it has helped a lot of people reach financial freedom.

    ReplyDelete
  8. Bitcoin website is programmed to decide which block chain contains valid transactions. The users of Bitcoin Core only accept transactions for that block chain, making it the Bitcoin block chain that everyone else wants to use, They individually run their own Bitcoin Core full nodes, and each of those full nodes separately follows the exact same rules to decide which block chain is valid go there.

    ReplyDelete
  9. Its block chain is much faster and more sophisticated than Bitcoin and it features smart contract functionality. How to trade Bitcoin- Ethereum may revolutionize the way we handle contracts, mortgages, loans, wills, deeds, and many other things in the near future, including how we use the internet for cryptocurrency trading course.

    ReplyDelete
  10. This is a full-included wallet: make different delivers to get bitcoins, send bitcoins effectively, track exchanges, and go down your wallet.
    guide about lending

    ReplyDelete