I’m working on a project for one of my client that will require us to share native C++ code between iOS and Android then consume this code in React Native.

A quick google search led to several toolkits and samples on GitHub. This is great, I’ll have a starting point to play. I have forked two of those to my account:

  1. ReactNativeCPP
  2. Djinnius

Both of them are base on Djinni

ReactNativeCPP

I did no have problems with this one because… the react native code does not call the native code. Sight…

Djinnius

Now the fun begins. If you take a closer look at the forks, you’ll see that you can go up to two levels. If you do, you’ll see that the level of details in the README.md file is decreasing. So, I started applying the instructions very carefully.

The first problem that I had is tied to the npm install`instruction. It tries to rebuild Djinni but fails with 2 distinct errors. I solved it as detailed in this issue.

The second problem was file not found errors. It turns out that two of the instructions where inverted:

sh ./run_djinni.shshould be run before npm install

I was able to compile the code for iOS.

Making it work for Android was another challenge… I’ll let you compare the troubleshooting section between my README.md and the base repo of my fork.

The SDK and NDK locations set aside, the main problem was that the Djinni Java generated C++/Java bridge was not “exposed” to the sample. I’m not an expert in Java so my dirty fix was to copy the file to the sample code directory. May be there is another way. Do not hesitate to comment below.

As could could probably sense now, I felt stuck in snow rotten by the rain (not sure about the correct translation from french on this one :lol:). Hence the snowy picture.

Key takeaways about publishing OSS code

This list is a work in progress. Please feel free to comment the post. There is no formal order of priorities betweens the following paragraphs. Everyone is different and have various expectations.

No more maintained

I think this one is the most important.
Please tell us if you’re not maintaining the repo anymore and if there are pending breaking issues. Looking at the last modified date can’t accurately tell about the fact that the code even compiles.

Known issues

You could have worked for some time then switched priorities. This is totally fine. Please take a moment to tell about known issues in README.md. The layout is not important, facts are.

Comments in the code

I think there is nothing more frustrating than reading uncommented code. Please share your vision, your techniques and how you’re solving problems.

Enable Issues

If you intend to maintain the code with the help of others, please enable issues in your forked repo. This is not the default. I felt stuck, unable to contact the author of the code. There are ways to find the email address though.

Dependencies

Sometimes, your scripts and/or submodules may require global dependencies on the system. Please tell us and/or link to the appropriate documentation. node-gyp does it very well.

Double check on several platforms if possible

Once you’re confident that your repo is ready to be cloned on a computer, think again. My own Djinnius repo did not work as I expected between two Mac machines. I have a desktop computer with a lot of hard drive space. Android Studio is installed an up to date.

However, on my MacBook Air, I’m slightly restricted by available disk space. No Android Studio or XCode installed. I’m just woking with command line tools. There are differences.

I do not work on Windows anymore, nor am I using a linux machine. So I expect to have feedback for other users about their experience on their environment.

Consider anyone as a newbie

Yes please, believe me. I’m not familiar with Java, have done a lot of C++ in another life, and I’m now familiar with React Native and Javascript. This is why I need a small amount of information to be able to solve problems I may encounter. I’m eager to learn about sharing native C++ code between iOS and Android.

Final thoughts

I’m glad I have valuable resources out there to be able to start from an idea and make it work in real life. I’d like to thank all the authors of the repo I forked because it made me up and running very fast. Kudos guys.

One thought on “A tale about using Open Source Software

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.