nizwar / openvpn_flutter

A package that allow you to connect OpenVPN service with Flutter
https://pub.dev/packages/openvpn_flutter
GNU General Public License v3.0
85 stars 99 forks source link

Android OK - IOS KO #86

Closed Spokplacenta closed 1 year ago

Spokplacenta commented 1 year ago

When I try connection on Android, it's working. When I try on my iPad or iPhone, it's not working. I didn't find any way to handle errors, I've just status and stage : flutter: status : {connected_on: null, duration: 00:00:00, byte_in: 0, byte_out: 0, packets_in: 0, packets_out: 0} flutter: stage : VPNStage.disconnected flutter: stage : VPNStage.connecting flutter: stage : VPNStage.disconnected

In VPN configuration in iPadOS or iOS, i have : "Update required" in vpn's list

What is the way to handle errors ?

OpenVPNAdapter is no longer maintained, is it planned to use tunnel kit instead of openVPNAdapter ?

syedabdulbasit1 commented 1 year ago

@Spokplacenta Did you find anything because I got the same issue, please someone help us.

Spokplacenta commented 1 year ago

Still same problem on Apple's platforms. Did you get any error messages ?

syedabdulbasit1 commented 1 year ago

YES below is the error on console fopen failed for data file: errno = 2 (No such file or directory) Errors found! Invalidating cache...

syedabdulbasit1 commented 1 year ago

I configure it correctly but don't get it where the issue is coming from

Spokplacenta commented 1 year ago

Does your configuration work on android ?

syedabdulbasit1 commented 1 year ago

@Spokplacenta yes it works on android and IOS also You just need to configure VPNExtension build deployment target 15.0.0 and it's working

Spokplacenta commented 1 year ago

Yes, minimum Deployments is on iOS 15.0 everywhere image My problem is when I launch app, I have popup to allow VPN connexion and no connect :

on the VPN list on iPad I have on "AppName - Update required"

image
syedabdulbasit1 commented 1 year ago

@Spokplacenta check your ios OS software version if it is equal to or greater than 15 than it will work, Also add Personal VPN Extension in both Runner and VPNExtension. Sorry for late reply because I was not feeling well due to flu and fever. Screenshot 2023-10-23 at 10 46 16 AM

Spokplacenta commented 1 year ago

Still same problem Runner : image image VPNExtension image image

syedabdulbasit1 commented 1 year ago

Run below command and run again flutter clean && flutter pub get && pod deintegrate && pod install Could you tell me about the Software version of your iPhone?

Spokplacenta commented 1 year ago

Always same error after commands

iPad version 17.0.3

image

PodFile : image

syedabdulbasit1 commented 1 year ago

Add below in runner Info.plist that might help you

<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
   <string>workmanager.background.task</string>
</array>
<key>NSBonjourServices</key>
<array>
    <string>_dartobservatory._tcp</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>
syedabdulbasit1 commented 1 year ago

Have you added code on PacketTunnelProvider.swift?

Spokplacenta commented 1 year ago

yes like this : image

syedabdulbasit1 commented 1 year ago

yes

syedabdulbasit1 commented 1 year ago

Could you show me the error on the console?

Spokplacenta commented 1 year ago

i have no error on the console, this is one of my problems. :/

syedabdulbasit1 commented 1 year ago

make a separate project and start the installation step by step, I know it will take time maximum 20 minutes but you will find the issue may be.

Spokplacenta commented 1 year ago

How is set your libraries in runner ? Runner : image VPNExtension image

On the test, by default I have this but I have a loop...

syedabdulbasit1 commented 1 year ago

VPN EXTENSION: image RUNNER: image

Spokplacenta commented 1 year ago

OK I think my problem come from it

image

first time I resolved this error by deleting "VPNExtension.appex" from runner but I think it's a mistake.

syedabdulbasit1 commented 1 year ago

It might be, but does this fix solve your issue

Spokplacenta commented 1 year ago

no I try to resolve the loop without deleting "VPNExtension.appex"

in the podfile how is implemented VPNExtension target

image

or

image

or it's not important ?

Spokplacenta commented 1 year ago

Full error of the loop

Running Xcode build...                                                  
 └─Compiling, linking and signing...                         3,9s
Xcode build done.                                           26,8s
Failed to build iOS app
Could not build the precompiled application for the device.
Error (Xcode): Cycle inside Runner; building could produce unreliable results.
Cycle details:
→ Target 'Runner': CodeSign /Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app
○ That command depends on command in Target 'Runner': script phase “[CP] Embed Pods Frameworks”
○ Target 'Runner' has copy command from
'/Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/VPNExtension.appex' to
'/Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/PlugIns/VPNExtension.appex'
○ That command depends on command in Target 'Runner': script phase “Thin Binary”
○ Target 'Runner' has process command with output
'/Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/Info.plist'
○ Target 'Runner' has copy command from
'/Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/VPNExtension.appex' to
'/Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/PlugIns/VPNExtension.appex'

Raw dependency cycle trace:

target:  ->

node: <all> ->

command: <all> ->

node: /Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/_CodeSignature ->

command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:CodeSign
/Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app ->

node: /Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/Frameworks/OpenVPNAdapter.framework/
->

directoryTreeSignature: � ->

directoryContents:
/Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/Frameworks/OpenVPNAdapter.framework ->

node: /Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/Frameworks/OpenVPNAdapter.framework
->

command: P2:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:PhaseScriptExecution [CP] Embed Pods
Frameworks
/Users/anthonymarchand/Library/Developer/Xcode/DerivedData/Runner-bvvdwzpkpkpacxfqnvkimsiawobn/Build/Intermediates.noindex/Runner.build/D
ebug-iphoneos/Runner.build/Script-0C23BB664691CBD07860EC02.sh ->

node:
/Users/anthonymarchand/Library/Developer/Xcode/DerivedData/Runner-bvvdwzpkpkpacxfqnvkimsiawobn/Build/Intermediates.noindex/Runner.build/D
ebug-iphoneos/Runner.build/InputFileList-0C23BB664691CBD07860EC02-Pods-Runner-frameworks-Debug-input-files-1a4127a442649eea377babc41d199a
de-resolved.xcfilelist ->

command: P2:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:WriteAuxiliaryFile
/Users/anthonymarchand/Library/Developer/Xcode/DerivedData/Runner-bvvdwzpkpkpacxfqnvkimsiawobn/Build/Intermediates.noindex/Runner.build/D
ebug-iphoneos/Runner.build/InputFileList-0C23BB664691CBD07860EC02-Pods-Runner-frameworks-Debug-input-files-1a4127a442649eea377babc41d199a
de-resolved.xcfilelist ->

node: <target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase5-copy-files> ->

command: P0:::Gate target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase5-copy-files ->

node: <Copy /Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/PlugIns/VPNExtension.appex> ->

CYCLE POINT ->

command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:Copy
/Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/PlugIns/VPNExtension.appex
/Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/VPNExtension.appex ->

node: <target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase4-thin-binary> ->

command: P0:::Gate target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase4-thin-binary ->

node:
<execute-shell-script-18c1723432283e0cc55f10a6dcfd9e02f1eee2015e8ff5ebcd27678f788c2826-target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a7
83a885d8b0b3beb2e9f90bde3f49-> ->

command: P2:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:PhaseScriptExecution Thin Binary
/Users/anthonymarchand/Library/Developer/Xcode/DerivedData/Runner-bvvdwzpkpkpacxfqnvkimsiawobn/Build/Intermediates.noindex/Runner.build/D
ebug-iphoneos/Runner.build/Script-3B06AD1E1E4923F5004D2608.sh ->

node: /Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/Info.plist/ ->

directoryTreeSignature: i ->

directoryContents: /Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/Info.plist ->

node: /Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/Info.plist ->

command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:ProcessInfoPlistFile
/Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/Info.plist
/Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/ios/Runner/Info.plist ->

node: /Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/PlugIns/VPNExtension.appex ->

command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:Copy
/Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/Runner.app/PlugIns/VPNExtension.appex
/Users/anthonymarchand/Developpement/flutter_test_ovpn_ios/build/ios/Debug-iphoneos/VPNExtension.appex

Error launching application on iPhone de Anthony Marchand.
syedabdulbasit1 commented 1 year ago

this is my podfile code

# Uncomment this line to define a global platform for your project
platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

target 'VPNExtension' do
  use_frameworks!
  pod 'OpenVPNAdapter', :git => 'https://github.com/ss-abramchuk/OpenVPNAdapter.git', :tag => '0.8.0'
end
Spokplacenta commented 1 year ago

It's working !!! Probleme solved by changing order of the build phase. I moved Thin Binary at the end of the Build Phases :

image

VPN is now connected on iOS too !

Thanks a lot @syedabdulbasit1 !

syedabdulbasit1 commented 1 year ago

@Spokplacenta Thanks for acknowledge this issue. That's great 😊.