pronebird
pronebird

Reputation: 12230

How to properly include .bundle to Unity3d Package

I have an iOS plugin for unity3d with a static library inside, this library uses some images from .bundle. However I cannot figure out how to include my bundle to Unity Package. When I put my bundle to the package and try to build a project from Unity3d Editor, in the end I don't have my bundle included in generated XCode project.

So I have two questions:

1) Is there any way to get it copied to generated project?

2) Is it possible to specify extra frameworks from within unity3d plugin (I have a dependency to AdSupport.framework) to be included in generated project as well.

Update: you can copy your bundle to Assets/WebPlayerTemplates so Unity3d doesn't import anything from there, this directory also gets exported to unitypackage. The final step is to use postbuild scripts to include your bundle to generated Xcode project, I used XUPorter for this.

Upvotes: 2

Views: 5138

Answers (3)

Mert Celik
Mert Celik

Reputation: 715

Actually, there is a way. Not sure if this is added after your answers/comments but;

  1. Find your .bundle file inside directory(in Unity Editor) and single click on it.
  2. From Inspector panel, only select iOS from Include Platforms enter image description here
  3. Click Apply down in Inspector panel.
  4. When building for iOS, you will see the .bundle when your Xcode project is exported [Check Build Phases/Copy Bundle Resources].

Upvotes: 1

pronebird
pronebird

Reputation: 12230

I discovered there is no way to configure Unity3d in such a way that it includes extra frameworks and bundles to generated Xcode project (i.e. Marmalade SDK allows you to do so via configuration), I use mod_pbxproj and Unity3d console tool to generate XCode project and inject all necessary bundles and frameworks to the project upon build completion.

There's a better option, see question itself.

Upvotes: 1

Kay
Kay

Reputation: 13146

Unity copies every file from folder Assets/Plugins/iOS to the Xcode project's Library folder. That's perfect for your lib file and other stuff but it fails when it commes to directory structures. Resource bundles are directories and thus Unity just copies the .meta file of the directory and refuses to copy the files inside.

A workaround for this is to copy your bundle manually and import them into Xcode (menu File / Add File to "Unity-iPhone"). Afterwards you should always export your iOS project in Append mode (CMD+B does this by default). There are two drawbacks:

  • When you update to a newer version of Unity the project is often replaced and thus your bundle has gone. If your using git for versioning I suggest adding the bundle to repository, Subversion users have to do extra work.
  • Whenever the bundle changes in your library project, you have to copy it. If this happens often enough to get annoyed, you can set up a pre-action in your build process i.e. write a small shell script that copies your resource bundle from libraty project. This can be done in Edit Scheme: Edit Scheme / Build /  Pre-actions
    Again this might get overwritten on Unity updates and you have to set up the pre-action again manually.

Upvotes: 2

Related Questions