I am having some difficulty creating a bundle for my application, and placing files in the bundle.
For example, Facebook has developed a bundle for iPhone applications using their framework. In the same way, I also want to create a bundle which can be reused for many applications.
My questions are:
App bundles make it easy for customers to buy up to 10 of your apps or games in a single purchase. You can create app bundles for paid apps or free apps that offer an auto-renewable subscription to access all apps in the bundle. Learn how to set up app bundles and effectively market them on your product page.
The Xcode developer tools include everything you need to create apps for iOS, iPadOS, macOS, tvOS, and watchOS.
First of all, since your question is tagged iPhone, you can only include code in your bundles on the iPhone. So basically you can only use bundles to package up pictures and sound files and other static data.
When you create a new project in XCode, there is an option to make the target a bundle (under Framework & Library), but an assets bundle is just a directory with a .bundle suffix. I generate mine with this little script:
#!/bin/bash
echo "Building assets bundle."
if [ -d ./MyAssets.bundle ]; then
rm ./MyAssets.bundle/*
else
mkdir ./MyAssets.bundle
fi
find ./assets -type f -print0 | xargs -0 -J% cp % ./MyAssets.bundle
(I'm no bash hacker, so this can probably be improved in countless ways. Suggestions welcome!)
This takes a folder hierarchy and flattens it (I detest hierarchies) into a single directory which is named MyAssets.bundle. I trigger this script from a separate build phase when in projects that import the bundle, so that changes are automatically tracked.
If you want to learn how to create framework bundles, it's a bit more complicated (you have to follow certain conventions and include info in plists), but for iPhone bundles, this is pretty much all you will need to know and do.
You could do this too:
Make a folder in finder, add files to it, rename it to bundlename.bundle
drag into Xcode - success!
to access, use the form of PathToMainBundle+"/bundlename.bundle"
Source: https://stackoverflow.com/a/5277452/736384
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With