IsraelHikingMap / Site

Israel Hiking Map has maps, route planning, and travel information for Israel. This repository holds the files needed for running the Israel Hiking Map site and apps.
https://israelhiking.osm.org.il/
Other
80 stars 32 forks source link

[iOS] Support open with #1196

Closed HarelM closed 3 years ago

HarelM commented 4 years ago

Feature

Currently only Android supports open-with/share with due to CI limitation of the plugin that I have chose to use: https://github.com/j3k0/cordova-plugin-openwith/issues/82 So I'm adding this plugin only when building Android. I have looked for an iOS only alternative and it seems that the other plugin has this issue too: https://github.com/EternallLight/cordova-plugin-openwith-ios/issues/23 And so I have written some comments and found out there's another fork that should work for iOS and Android and CI: https://github.com/missive/cordova-plugin-openwith I'll need to give it a go.

A few users have already encountered issues with the fact that this is not part of the app, which raises the priority of this issue.

HarelM commented 4 years ago

@EtienneLem Thanks for the info in the issue there. I'll be happy to update the readme of your project with stuff that I find that are incorrect/confusing. Let me know if you want a pull request or that I just write it here, I'll start here so I won't forget. The first few comments:

  1. Installation can't be made using the following line: cordova plugin add cordova-plugin-openwith --variable IOS_URL_SCHEME=cordovaopenwithdemo as there's no plugin with this name in npm. Probably need a git source until this is released to npm.
  2. Also this part is confusing: "This is a bit modified version of cordova-plugin-openwith by Jean-Christophe Hoelt for iOS" Since you are using a fork of the cordova-plugin-openwith-ios I thought it doesn't support android although it is written there multiple times (it might just be me though).
  3. When installing with the suggested line above (and git) I'm getting: Failed to install 'cordova-plugin-openwith': Error: Variable(s) missing: IOS_BUNDLE_IDENTIFIER This error is clear, but the documentation should have the example with it
  4. I worked hard to get a lot of files working in Android, but I'm not sure how to do it on iOS, worth adding a file type in iOS and Android as an example, see my intent config here: https://github.com/IsraelHikingMap/Site/blob/master/IsraelHiking.Web/config.xml#L34 I don't have a clue on how to translate it to iOS plist, but I guess I'll need to learn...
  5. My build still fails with the following error message:
    fatal error: 'ShareViewController.h' file not found
    #import "ShareViewController.h"

    Which I think I had with the original plugin as well :-( See here: https://github.com/j3k0/cordova-plugin-openwith/issues/82 Build output can be seen here: https://ci.appveyor.com/project/IsraelHikingHost/site/builds/31830135/job/05c7ump151duw7l6

HarelM commented 4 years ago

@EtienneLem any updates on this? I'm not sure what I'm doing wrong... :-(

EtienneLem commented 4 years ago

This is maybe fixed with https://github.com/missive/cordova-plugin-openwith/commit/17008a89cb269b101e6cd0e2d969a8cf3b10b227.

HarelM commented 4 years ago

@EtienneLem Thanks for the update! I'll try to use the latest version you mentioned in a few days and report back here what had changed and if this was successful or not. Thanks again!

HarelM commented 4 years ago

@EtienneLem I have created another build with the latest changes in tour branch adn now I'm getting the following error:

error: "ShareExt" requires a provisioning profile with the App Groups feature. Select a provisioning profile in the Signing & Capabilities editor. (in target 'ShareExt' from project 'Israel Hiking Map')

Build can be found here: https://ci.appveyor.com/project/IsraelHikingHost/site/builds/32231667/job/65e54xvaj8vewcsx

The relevant commit can be seen above and is only changing the package.lock file obviously.

EtienneLem commented 4 years ago

Right. Cordova really isn’t friendly with multi-targets. We are actually building the iOS app with Fastlane and can set the proper provisioning profiles that way.

So we use cordova prepare to initialize all the plugins / xcode, but instead of doing cordova compile, we use fastlane.

HarelM commented 4 years ago

@EtienneLem I was hoping this is handled by the plugin code as well :-( I was able to sign my app in appveyor CI (took me a while to get it right I must admit) and was hoping to avoid adding another dependency like fastlane. Having said that, when I was researching the iOS app signing all the answers was to use fastlane, so I probably need to embrace the fact that I need another tool... If you have an example repo that uses faslane let me know so I'll be able to reduce some of the effort of understanding what I need to configure in order to make fastlane up and running...

HarelM commented 4 years ago

Fastlane on windows: https://blog.vertica.dk/2019/08/15/automated-android-deployment-with-fastlane-on-windows/ Transporter on windows: https://help.apple.com/itc/transporteruserguide/en.lproj/static.html#aria-apd28806d5ebc904 This is probably the next step in term of CI and local development... Relevant issue for questions? https://github.com/fastlane/fastlane/issues/11687

HarelM commented 4 years ago

@BenjaminPoncet I've took the latest code of the fovea open with plugin and I'm still getting the following error:

fatal error: 'ShareViewController.h' file not found
#import "ShareViewController.h"

Any chance you know how to overcome this? Build log can be found here: https://ci.appveyor.com/project/IsraelHikingHost/site/builds/34262543/job/6uakm64ae1eqxq4q Relevant brach that is begin built is the fastlane-1266 Any help would be appreciated... I've been trying for a long time to make this work... :-((

HarelM commented 4 years ago

A related article: https://discuss.bitrise.io/t/unable-to-assign-provisioning-profile-for-app-extension/8481

HarelM commented 4 years ago

@yuanjilee I saw a post on fastlane issue with what seems to be the same issue I'm facing. How did you manage to solve the problem? Are you using two provisioning profiles one for the app and the second one for the share extention? When I use two profiles I get a basically the problem described here: https://stackoverflow.com/questions/55238974/bitrise-ionic-shareext-appex-requires-a-provisioning-profile#

HarelM commented 3 years ago

Ok, so an initial commit was merged to master and now the plugin is used in the iOS build in my CI and it completes successfully. yay! I still don't have a clue how to make it associate GPX files on iOS though... :-( @EtienneLem @j3k0 @NiklasMerz if you guys can direct me how to do it it would be great as I'm pretty clueless when it comes to iOS, file association and the fact that all this needs to run in a CI server without human intervention...

HarelM commented 3 years ago

According to a report from our Facebook group it seems that the app is now listed in some share options but does not open the file when selected. I need to better understand how fix this.

HarelM commented 3 years ago

https://stackoverflow.com/questions/2774343/how-do-i-associate-file-types-with-an-iphone-application The above might be an easier solution...?

HarelM commented 3 years ago

This might be relevant for this issue: https://github.com/apache/cordova-ios/issues/1020

HarelM commented 3 years ago

Thanks for the info! I ended up not using this plugin after all since the UX around it is not so good - i.e. the current plugin opens a dialog with an option to see an image you share and the plugin enforces only one type of file that can be used etc. In the end, it seems that cordova already has some kind of mechanism to support opening files without any plugin and this is what I ended up using, along side webIntent in Android. The problem when using this plugin in CI is that cordova-ios still does not support multiple provisioning profiles and this requires a fork I did for cordova-ios which was not merged unfortunately... See issue #1391 for the complete solution and the relevant service code which utilizes both webIntent and cordova-ios build it handleOpenURL. In my case it proved to be a simple and elegant solution that requires a lot less tinkering with xcode and post cordova build things which is very critical for me since I'm only releasing builds which were built on my CI and never release a build which I prepare locally.

Also I've talked with the guys that sent the following PR which solves some of the issues I've listed above: https://github.com/missive/cordova-plugin-openwith/pull/2