Question

This is a pretty specific scenario for the process I'm trying to create. The apps I'm using have a purpose to launch in offline mode so that users can start the app when they don't have any signal/internet connectivity.

The problem:

I'm trying to cache my sqlite db file and some image assets (in PNG/JPG) to my xcode project AFTER I've created the build using:

xcodebuild -target $TARGET_NAME -configuration "AdHoc"

After that command, I can install the given ipa (after I zip up the .app file) on my phone.

However, I didn't cache the app's newly acquired resources. I have an external task that runs the simulator, copies all the images and db files in my resources, and pastes them into my project's directory. I have the following command in a shell script after the xcodebuild command:

find -L $1/$TARGET_NAME/Resources -type f -not -name ".*" -not -name "`basename $TARGET_NAME/Info.plist`" | xargs -t -I {} cp {} $BUILD_DIR/$TARGET_NAME.app

Basically, this is putting my cached resources into the .app file.

This is where I need help. I'm sure you guys will say "No you can't do this because it corrupts the archive and Apple won't let apps install if the .app file or .ipa file has been tampered with.

My question is: How would I cache these given resources into my .app or .ipa? Is there another time in the process where Apple will allow this to be done without corrupting my file?

Of course, you can argue that the user can just launch the app for the first time before they go out to the areas with no cell-service, but I need it so that the app is fully cached before the user even enters it.

Thank you for the help.

Was it helpful?

Solution

I like how it took me 2 weeks to struggle through this, but the moment I asked on S.O., I find the answer myself:

I created a folder named "Cached" under my Resources folder. I dragged the "Cached" folder into xcode (initially empty) but when the "Files & Groups" option shows up, you check the "Create folder references for any added folders". From there everything should be good to go.

I copy the cached images using a basic shell script to the newly created "Cached" folder so the folder will add any resource that was placed in there during build time :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top