Build libnoise on iOS!


libnoise 是一个 Cpp 的噪声库 写了一个简易的教程 怎么把这个东西做成一个可以 iOS 用的 lib

1.Download libnoise from
2.Navigate to libnoisesrc-1.0.0/noise/src, and select files like this:

No makefile, just .h and .cpp files, and don't select win32 folder, you are building in Xcode.

3.On your current Xcode project menu, Select File/New/Target/iOS/Frameworks & Library/Cocoa Touch Static Library, hit next and name it "libnoise" or whatever :-)
4.Now, Drag files you selected in Finder to Xcode like this:

Things to remember to check:

  • Copy items if needed
  • Create Groups
  • Add to targets, just select the new library we have created.

And now our project will looks like this: (I made a group from these files so you will see a top folder named libnoise)

5.Switch your target to libnoise (or whatever you named it when creating library target), we will check something.

6.Navigate to Build Phases/Compile Sources, see if all .cpp files are in there.

7.Jump back the target to your app, make sure Build Phases/Compile Sources have these:

  • Xcode's target are on your app
  • Target Dependencies have libnoise
  • Link Binary With Libraries have libnoise.a

8.Add libc++.tbd in General Tab, or in Build Phases.
9.Create a UIViewController (like NoiseDebuggerViewController), and change NoiseDebuggerViewController.m to

  • import "noise.h"

  • paste these codes to viewDidLoad():
noise::module::Perlin myModule;
double value = myModule.GetValue(1.25, 0.75, 0.5);
NSLog(@"Value : %f",value);

and Press Run, make sure you have real iDevice plugged in instead of Simulator.
See the Log!

Value : 0.686347

Now you have libnoise on iOS! We are ready to use it for procedural planet generation on iOS!