code style

顯示具有 xcode 標籤的文章。 顯示所有文章
顯示具有 xcode 標籤的文章。 顯示所有文章

9/30/2016

How to load dynamic library with Unity plugin on Mac OSX

When develop Unity plugin on Mac, you might want to load third party dynamic library. But it usually occurs "fail to load" situation. That is because loading path is different between development and production environment.

For instance, when you develop in Edit mode, the loading path will be
 ./Assets/Plugins/osxplugin.bundle/Contents/Resources/thirdparty.dylib

But when you build a release version, the loading path will be
./Contents/Plugins/osxplugin.bundle/Contents/Resources/thirdparty.dylib

Mac OSX provide a command line tool to modify that.

$ install_name_tool -id @loader_path/thirdparty.dylib thirdparty.dylib

You could use otool to check dylib status.

eg.
$ otool -L libcurl.dylib 
libcurl.dylib:
 @loader_path/libcurl.dylib (compatibility version 0.0.0, current version 0.0.0)
 /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
 /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)

Now, you can develop and build a unity app without dylib loading issue.

9/03/2015

How to induce low memory warnings on iOS device?

It's difficult to test game function in low memory scenario.

Someone suggests using iOS simulator to do the test.

Someone says write codes to allocate large chunk of memory to induce that, or call private method
[[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)];

Rather than writing code in the project, you could use Xcode debugger to execute the private function.

Edit the action of breakpoint and enter
expr (void)[[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)];
Voilà, mission completed.

By the way, my indie game "Nimble Jump" Android version is in beta testing now.
Please try it and give some feedback. Thank you!
play.google.com/apps/testing/com.jbyu.ninja.