Search Unity

How to add some of App Extensions to Unity ios build

Discussion in 'iOS and tvOS' started by MarsaPalas, Dec 23, 2014.

  1. MarsaPalas

    MarsaPalas

    Joined:
    Oct 28, 2014
    Posts:
    17
    Really, how to do it?

    I want to use, for example, Today Extension for my ios app made in unity. When open my app in Xcode and try to do it with File -> New -> Target -> Application Extension -> Today Extension, I get an error about some missing file.

    Do I need some special way of adding these app extensions or I am doing something fundamentally wrong.
    Is it still not compatible even though unity did made ios 8.1 build available?
    Can this be done, or not?

    Please, give me some answers, because I am wasting my second week on this.
     
  2. MarsaPalas

    MarsaPalas

    Joined:
    Oct 28, 2014
    Posts:
    17
    Did anyone even tried this? Any kind of experiences? Anything???
     
  3. Veemix

    Veemix

    Joined:
    Dec 5, 2014
    Posts:
    25
    What is the error you are getting concerning the missing file?

    You are adding the Today Extension to your project correctly. Make you you switch to the extension's target when building if you want to test the Today Extension's functionality.
     
  4. MarsaPalas

    MarsaPalas

    Joined:
    Oct 28, 2014
    Posts:
    17
    I was getting an error that .appex file is missing, but later I figured the file was built on the other location. At the end, I somehow managed to make it all work.

    Also, by using simulator and trying to run either of targets, xcode would just exit. That is still a problem to me.
     
  5. MarsaPalas

    MarsaPalas

    Joined:
    Oct 28, 2014
    Posts:
    17
    Just to add, after I put watchKit extension to unity ios project, successfully build all that, select watchKit extension as target and try to run it, I get an error saying "Installation failed, Invalid arguments".
    And that ONLY happens with watchKit extension added to UNITY ios apps. running WatchKit extension with NATIVE iOS apps works and running APP extensions with Unity works too, but watchKit + Unity ios doesn't work.

    I really don't know where to look. I found this link http://stackoverflow.com/questions/27031746/installation-failed-invalid-argument-ios-extension talking about that error, but that doesn't help me.

    Any ideas are welcome!

    ps. I know watchKit is made for iOS 8.2 and Unity can build iOS 8.1 max, but I am trying to find some workaround, and so far, it was possible.
     
  6. Streamside7

    Streamside7

    Joined:
    Nov 8, 2013
    Posts:
    9
    I am trying to the same thing and am having this exact same issue. Were you ever able to find a work around MarsaPalas?
     
  7. Galfaroth

    Galfaroth

    Joined:
    Sep 20, 2009
    Posts:
    19
    Bump! Having the same issue with Unity5 b22.
     
  8. Streamside7

    Streamside7

    Joined:
    Nov 8, 2013
    Posts:
    9
    Anyone having any luck with this?
     
  9. schchang1

    schchang1

    Joined:
    Sep 12, 2012
    Posts:
    8
    I have been trying to get Watchkit App to work with Unity for the last few days. Here is my current progress

    - Create an Unity iOS project, set the build option to Simulator SDK and build the xcode project.
    - Following Apple's instructions, add the WatchKit extension and WatchKit app build targets to the xcode project.
    - Change the Unity target's build location to build/Debug-iphones instead of build/Debug-iphonesimulator to fix a file copy failed error.(or the appex files can be copied from the iphoneos folder to the iphonesimulator folder)
    - Fix the embedded binary code signing not consistent with the parent app issue by setting all the tree target's identiity team to the same team.(have to chage the build settings' targted device family to iOS8 also)

    But when it's running on the simulator, I got another error message below
    SPErrorGizmoInstallNeverFinishedErrorMessage
    Looks like the app failed to install on the watch simulator and I cannot find a way to make it work.
    I will keep posting my progress, please also share your progress with the community. Thanks
     
  10. fluidImages

    fluidImages

    Joined:
    Sep 27, 2013
    Posts:
    29
    I have been able to create and add the extension, however I am just getting a blank (black) screen on the secondary watch display.

    Sean
     
  11. Nik0s

    Nik0s

    Joined:
    Aug 16, 2013
    Posts:
    9
    Hi,

    I have written a step by step tutorial on implementing the WatchKit api in Unity - you will also find a WatchKitUnity package which includes the iOS plugin and a WatchKitUnityManager prefab to setup the communication and listeners required

    http://devgallery.com/unity/watchkit-unity

    Please let me know how you get on!
     
  12. QuantumCalzone

    QuantumCalzone

    Joined:
    Jan 9, 2010
    Posts:
    262
    The furthest I got just caused the apple watch to be stuck on loading . No errors or logs at all. Just stuck
     
  13. paradizIsCool

    paradizIsCool

    Joined:
    Jul 10, 2014
    Posts:
    178
    Hi @Nik0s,

    Is it possible to do all these things with postbuild scripts ?

    Regards
     
  14. povilas

    povilas

    Unity Technologies

    Joined:
    Jan 28, 2014
    Posts:
    427
    Not yet at the moment, but we're working on improving the Xcode API so that adding extensions automatically is as painless as possible.
     
  15. Tehelee

    Tehelee

    Joined:
    Jan 26, 2013
    Posts:
    12
    Is there an estimate on when this is coming?
    Will we be able to use an in-editor tool for this, or will it simply be code documentation?
     
  16. povilas

    povilas

    Unity Technologies

    Joined:
    Jan 28, 2014
    Posts:
    427
    The latter.
     
  17. scottgraessle

    scottgraessle

    Joined:
    Jul 24, 2013
    Posts:
    1
    Is there any way to script this with the existing Xcode API? I've tried using reflection to access the existing PBXProject.AddAppExtension() method, but it fails in an AddFile() call. We have a Today Extension and would really like to avoid adding it to the project by hand.
     
    paradizIsCool likes this.
  18. povilas

    povilas

    Unity Technologies

    Joined:
    Jan 28, 2014
    Posts:
    427
    Hi, this is a bit "bitrotten" API which was not exposed precisely because it was not fully tested. We will fix it some day in the future, but for now it's early to say when. We'll get back to this thread once the functionality is released.
     
  19. alejobrainz

    alejobrainz

    Joined:
    Sep 10, 2005
    Posts:
    288
    Hello Povilas. I wanted to know if there has been any advance on this area. Creating extensions is very significant to iOS 10 and allowing you to set them up through the Xcode API makes it viable, especially when using continuous integration systems like cloud build.

    Thanks,

    Alejandro.
     
  20. Buildo77

    Buildo77

    Joined:
    Aug 17, 2015
    Posts:
    2
    ...I agree with brainz. I'm struggling to devise a re-usable (automatable) workflow that involves a Unity-built XCode project *and* an XCode Sticker Pack Extension.
     
  21. alejobrainz

    alejobrainz

    Joined:
    Sep 10, 2005
    Posts:
    288
    Or interactive notifications... I think that fixing the PBXProject.AddAppExtension() API should be much more relevant nowadays...

    @povilas
     
  22. Buildo77

    Buildo77

    Joined:
    Aug 17, 2015
    Posts:
    2
    Last edited: Sep 16, 2016
  23. alejobrainz

    alejobrainz

    Joined:
    Sep 10, 2005
    Posts:
    288
    Hi @Buildo77 Did you have any luck with this?
     
  24. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    531
    I second Brainz's question... adding a vote for this to be fixed if it's not yet working. I found my way to this thread hoping there would be an automated way of adding an extension when compiling.
     
    alejobrainz likes this.
  25. vjhakiwi

    vjhakiwi

    Joined:
    Sep 20, 2016
    Posts:
    1
    Is it working now? Any guide on how to do this?
     
    alejobrainz likes this.
  26. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    531
    while on the topic of the PBXProject class, my current version of MonoDevelop that comes with Unity 5.4.1p1 isn't even recognising the Xcode namespace. Unity doesn't complain about the code, but I get no code completion in MonoDevelop and all classes / methods appear as errors.
     
  27. van_ustwo

    van_ustwo

    Joined:
    Jul 10, 2012
    Posts:
    82
    I wrote an App Extension with my Unity game. Basically as part of Post Build I modified the Xcode project to include my App Extension code. Unity's Xcode Api is open source in their BitBucket account. I modified that and use that instead.
     
  28. alejobrainz

    alejobrainz

    Joined:
    Sep 10, 2005
    Posts:
    288
    Could you share in general terms the steps required to achieve this. I made a manual build and then made a copy of the folder, then added the extension manually on one of them (A simple sticker pack). Then made a diff of the two folders and got this:

    Files Unity-iPhone.xcodeproj/project.pbxproj differ
    New: My Sticker Pack (the new target)
    * Files Unity-iPhone.xcodeproj/xcshareddata/xcschemes/Unity-iPhone.xcscheme differ
    * New: Unity-iPhone.xcodeproj/project.xcworkspace
    * New: Unity-iPhone.xcodeproj/xcuserdata

    I also made a copy of the base project and by just opening it in Xcode, I found the following changes:

    Files Unity-iPhone.xcodeproj/xcshareddata/xcschemes/Unity-iPhone.xcscheme differ
    New: Unity-iPhone.xcodeproj: project.xcworkspace
    New: Unity-iPhone.xcodeproj: xcuserdata

    So my question is if I only need to change the pbxproj and add the target, and if so, could you guide us as to what kind of changes we need to make on the pbxproj.

    Thanks!

    Alejandro.
     
  29. povilas

    povilas

    Unity Technologies

    Joined:
    Jan 28, 2014
    Posts:
    427
    This is known regression. The bug is already fixed, but not released yet. Likely the fix will be before 5.4.2 launches.
     
  30. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    531
    Hey there.. I just managed to get an post compiler setup working to add a sticker extension. As gamePig suggested I used the open source code and modified it a fair bit to get it all working. You're right that it's mostly just the project.pbxproj that needs to be changed. There's far too much code and I'm not at liberty to post it all up, but hopefully I can help you get through hurdles if you get stuck.

    Here's my high level process I went through to figure it all out:
    • First created an empty xcode project, added a new target choosing the sticker pack extension and then added the icons and stickers using xcodes UI.
    • Once the assets for the sticker extension were created in xcode I backed up just the stickers.xcassets folder and the accompanying Info.plist to a folder just outside my Unity project for later use and deleted the empty project.
    • I then created two local svn repositories each with a checkout, you could use git or some other file version control system, but I just wanted quick local repos that I could do easy code comparisons and reverts on.
    • I then compiled my Unity game and duplicated the xcode project and added a copy to each svn checkout, I'll call them Copy A & Copy B. The main reason to have exact clones of the same project is so that later when modifying each copy with different changes, the internal asset guid's will mostly be the same making it easier to wade through the differences. Before committing the project files to each repo, open the xcode projects up because xcode will make a bunch of modifications to user preferences etc. Once that's done, commit all files.
    • Then in Copy A - I again used xcodes native UI to add a new target and used the sticker extension template. Close xcode and overwrite the sticker.xcassets folder and Info.plist. Reopen the project and check that your stickers and icons are appearing.
    • Now for Copy B - this is where the bulk of work is going to happen. I created a method that adds the sticker extension to an xcode project that normally runs as a post-process. But because I didn't want to recompile a new xcode project out of unity (the guid's would be all different), I setup the method to be also triggered by an editor menu option that would let me choose the project folder to run the method on, like Copy B • EditorUtility.OpenFolderPanel("Choose Xcode project folder","",""); This way I could more rapidly change the method and revert the changes, while running a file diff on Copy A and Copy B's project.pbxproj files along the way to figure out what I needed to change.
    • One of the first things my method does is to recursively copy the backed up stickers.xcassets folder and Info.plist so it was sitting in the root folder of the xcode project.

    Hope that helps get you going.
     
    Skjalg and alejobrainz like this.
  31. ToooooooBig

    ToooooooBig

    Joined:
    May 21, 2013
    Posts:
    1
    Sorry for the offtopic, but does anybody know if the extension affects final app size in the App Store?
     
  32. graham-mcintyre

    graham-mcintyre

    Joined:
    Apr 16, 2016
    Posts:
    3
    Povilas - You mentioned that the issue with PBXProject.AddAppExtension() was a regression fixed in unity 5.4.2 but didn't sound sure about the exact release at the time. Did the fix make 5.4.2f2 ?
     
    Last edited: Nov 22, 2016
  33. Skjalg

    Skjalg

    Joined:
    May 25, 2009
    Posts:
    211
    Hi, this was a very interesting read.

    Does anyone have a working solution to share regarding adding a sticker pack (or any other ios extension) to the exported xcode project from unity? perhaps @gamePig or @jason_yak ?
     
    peterahou and alejobrainz like this.
  34. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    531
    Hi everyone, I'm in the process of writing up a more detailed guide on how to achieve a working solution to add a sticker pack extension via post-processing. I'll share this up on made with unity as soon as possible. Merry xmas =)
     
  35. Valkovich

    Valkovich

    Joined:
    Feb 6, 2015
    Posts:
    1
    Hello, did you post the guide?
     
  36. HereIAmItsMe

    HereIAmItsMe

    Joined:
    Jul 16, 2012
    Posts:
    11
  37. WasimBashir

    WasimBashir

    Joined:
    Nov 24, 2017
    Posts:
    9

    FileUtil.CopyFileOrDirectory(Application.dataPath + "/chching.wav", buildPath+"/"+target_name+"/chching.wav");
    proj.AddFile(target_name + "/chching.wav","/chching.wav");


    file is added but not working , when i drag and drop file in xcode its working.

    can you help me with this
     
  38. waldgeist

    waldgeist

    Joined:
    May 6, 2017
    Posts:
    388
    Has this been fixed in the meantime?
     
  39. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    210
    I'm interested on this as well, any idea?
     
  40. Skjalg

    Skjalg

    Joined:
    May 25, 2009
    Posts:
    211
    Yes I'm pretty sure they added a method to add an extension
     
  41. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    210
    Any documentation or tutorial about that?