Is there a way to include StoreKit.framework from Unity?

Rather than check the generated Xcode project into our repository, I’d like to configure Unity to include StoreKit.framework when the Xcode project is built. But I’m not finding a way to do it.

Anyone know how this might be done?

Thanks…

Near as I can tell, I need to edit the default Xcode project within Unity, itself. This doesn’t strike me as particularly manageable, however, especially in a team environment.

I think what you want is some type of post process build script. Check out prime31. I highly recommend his store plugin. I know he uses these scripts to add the necessary linkage.

You can use the IAP plugin from Prime31 but you can also use NativeToolkit which is also done by Prime31 to implement and add support for IAP. It is fairly easy.

I ended up using the PostprocessBuildPlayer script (see Build Player Pipeline) to patch the project.pbxproj used by Xcode.

This script is run after the Xcode project is created, but before it is run.
In the script, I patch the project.pbxproj to include the references to StoreKit. Here’s what my patch looked like (yours might end up being different). To get the info, I modified an existing project in Xcode, noticed what was changed in the project, and incorporated those changes into a diff.

--- /tmp/project.pbxproj.orig	2012-03-01 16:35:42.000000000 -0800
+++ /tmp/project.pbxproj 2012-03-01 16:39:15.000000000 -0800
@@ -41,6 +41,7 @@
 		56B7961D1442E1C30026B3DD /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 56B796191442E1B80026B3DD /* GameKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
 		56BCBA390FCF049A0030C3B2 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 56BCBA380FCF049A0030C3B2 /* SystemConfiguration.framework */; };
 		56FD43960ED4745200FE3770 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 56FD43950ED4745200FE3770 /* CFNetwork.framework */; };
+		6841D3C615004E26004709DC /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6841D3C515004E26004709DC /* StoreKit.framework */; };
 		7F36C11113C5C673007FBDD9 /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F36C10E13C5C673007FBDD9 /* CoreMedia.framework */; };
 		7F36C11213C5C673007FBDD9 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F36C10F13C5C673007FBDD9 /* CoreVideo.framework */; };
 		7F36C11313C5C673007FBDD9 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F36C11013C5C673007FBDD9 /* AVFoundation.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
@@ -123,6 +124,7 @@
 		56B796191442E1B80026B3DD /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; };
 		56BCBA380FCF049A0030C3B2 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
 		56FD43950ED4745200FE3770 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
+		6841D3C515004E26004709DC /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
 		7F36C10E13C5C673007FBDD9 /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
 		7F36C10F13C5C673007FBDD9 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = System/Library/Frameworks/CoreVideo.framework; sourceTree = SDKROOT; };
 		7F36C11013C5C673007FBDD9 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
@@ -200,6 +202,7 @@
 				56B7959B1442E0F20026B3DD /* CoreGraphics.framework in Frameworks */,
 				56B7960F1442E1770026B3DD /* CoreMotion.framework in Frameworks */,
 				56B7961A1442E1B80026B3DD /* GameKit.framework in Frameworks */,
+				6841D3C615004E26004709DC /* StoreKit.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -246,6 +249,7 @@
 		29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
 			isa = PBXGroup;
 			children = (
+				6841D3C515004E26004709DC /* StoreKit.framework */,
 				56BCBA380FCF049A0030C3B2 /* SystemConfiguration.framework */,
 				5692F3DC0FA9D8E500EBA2F1 /* CoreLocation.framework */,
 				5682F4B10F3B34FF007A219C /* MediaPlayer.framework */,

This system for including other frameworks is pretty kludgy, but it gets around having to change the Unity installation on every machine that might want to build your project (changing the trampoline sample project).

Looks like a great solution. Is the pach you show here goes ‘as is’ in PostprocessBuildPlayer? If not, would you mind sharing your customized PostprocessBuildPlayer file (or the relevant lines) so we can see how you patched the project.pbxkproj? (Since I never used Perl before and on a deadline, this would be very helpful…)