Share iTunes files in your application and copy the ringtone file to the application’s document directory.
Install "Application supports iTunes file sharing" on YES in your info.plist file
If necessary, in the application, copy the file with the code below:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0];
NSString * filePath = [[NSBundle mainBundle] pathForResource: @ "MyRingtone" ofType: @ "m4r"];
NSData * mainBundleFile = [NSData dataWithContentsOfFile: filePath];
[[NSFileManager defaultManager] createFileAtPath: [documentsDirectory stringByAppendingPathComponent: @ "MyRingtone.m4r"]
contents: mainBundleFile
attributes: nil];
Now the user can access the ringtone via itunes and add it to their device ringtones.
source share