Creating A Central Location For My Packages

I’ve got several different applications that I’m working on that each will be sharing some of the same code. Here is the directory structure.

/Path/to/central/location/package1/package1.lua /Path/to/central/location/package2/package2.lua /Path/to/central/location/application1/main.lua /Path/to/central/location/application2/main.lua  

In each of those main.lua files I have this line.

package.path = package.path .. ";/Path/to/central/location/package1/?.lua" package.path = package.path .. ";/Path/to/central/location/package2/?.lua"  

Is there some way I can replace the “;/Path/to/central/location/” part with something to indicate the parent directory like

";../package1/?.lua" ";../package2/?.lua" 

This doesn’t seem work.

I don’t think that’s going to work the way you want it.  Apps on devices operate in a “jail” or a “sandbox”.  You cannot access files outside of the file the root bundle lives in.  So going up a level and down a level isn’t going to work.

What would work is to use a symbolic link:

ln -s …/package1/x.lua x.lua

this creates a virtual directory entry in your current folder for a file elsewhere on the file system.  This should be enough to make the simulator happy and it should do a physical copy of the file when it builds for device.   I haven’t tried it, but it should work correctly.

I don’t think that’s going to work the way you want it.  Apps on devices operate in a “jail” or a “sandbox”.  You cannot access files outside of the file the root bundle lives in.  So going up a level and down a level isn’t going to work.

What would work is to use a symbolic link:

ln -s …/package1/x.lua x.lua

this creates a virtual directory entry in your current folder for a file elsewhere on the file system.  This should be enough to make the simulator happy and it should do a physical copy of the file when it builds for device.   I haven’t tried it, but it should work correctly.