xendit / xendit-sdk-ios-src

MIT License
7 stars 11 forks source link

Flutter Support #49

Closed flushr closed 1 year ago

flushr commented 2 years ago

Hi, I'm trying to use this SDK inside a Flutter plugin, but whenever I tried to run in the iOS simulator using Apple Silicon (M1), it keeps returning this error:

Error (Xcode): Building for iOS Simulator, but linking in dylib built for iOS, file '/Users/user/Documents/Projects/xendit_test/ios/Pods/Xendit/CardinalMobile.framework/CardinalMobile' for architecture arm64

In the plugin project, I've added this line inside the Podspec:

s.dependency 'Xendit', '3.5.0'

While in the app project, as from so many solutions from the internet, I've added these lines inside Podfile:

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

But keeps getting the error, while for Android there is no problem.

Does the SDK can be used in Flutter for iOS Simulator?

Note: I'm new to iOS development.

Thank you in advance.

eraseac commented 2 years ago

I was able to build/run it in flutter after so many try. I am trying to run createToken but i am getting this error Unsupported value: <XENCCToken: 0x600002fc8f00> of type XENCCToken.

Please advice what this means.

flushr commented 2 years ago

Hi @eraseac,

Great to hear you can run it in Flutter, if you don't mind can you share on how to get it running? Been trying it since, even using Swift Package Manager, but the build always failed.

I've also looked at latest version 3.6.0, which has a new Cardinal Mobile SDK, but in cocoapods is still on version 3.5.0.

eraseac commented 2 years ago

I just added the dependency on the podspec 'Xendit', '3.5.0'.

Didnt need to do anything on the podfile.

Then imported it in the SwiftPlugin in the classes folder.

From there, everything is straight forward as an ordinary flutter ios plugin.

It took me a while on the ViewController as it was always returning nil.

I am able to validate the Cards, which returns correctly.

I am still stuck on the Unsupported value and still troubleshooting it

eraseac commented 2 years ago

@flushr Just sharing. so the actual error that xcode was throwing is "unsupported value for standard codec". which there are a lot of articles on this issue.

I will do a clean code setup again and try the 3.6.0 version. How did you install 3.6.0 in xcode? Through the Package Dependencies?

flushr commented 2 years ago

@eraseac I haven't installed 3.6.0 through cocoapods, since it's still on version 3.5.0. But I tried to install 3.6.0 through Swift Package Manager and still cant build, even though there are no additional codes, just create a new project and adding the dependencies through either cocoapods or Swift Package Manager.

eraseac commented 2 years ago

@flushr i tried 3.6.0 through swift package manager, but Xendit Module cant be found on the swift flutter plugin. I reverted back to 3.5.0 via cocoapod and was able to resolve the issue on getting a token. I am now on trying to get an authentication id to be used for charging.

Same process, added the dependency on the podspec

s.dependency 'Flutter' s.platform = :ios, '13.0' s.dependency 'Xendit', '3.5.0'

and updated this on the file as it wouldn't allow me run it on the simulator initially

s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }, it initially had i386

flushr commented 2 years ago

@eraseac seems like flutter doesn't support swift package manager for dependencies yet when looking at this issue, only through cocoapods for now.

I've tried to change the podspec as in your reply above, can confirm that it works well in the simulator. Now, I will also try to create token and authentication, will update on this again, hopefully there will be no more errors.

eraseac commented 2 years ago

@flushr Yup it doesn't for now, to be able to do i saw somewhere that you have to create a flutter swift package. I didn't want to do it now, so i just reverted back to cocoapods.

Good to know

flushr commented 2 years ago

@eraseac finally I have successfully called the createToken method using version 3.5.0, and getting the CC token, but did not get the Unsupported value error. I have tried createAuthentication method, but still receive API_VALIDATION_ERROR.

eraseac commented 2 years ago

@flushr good to know. i actually was able to make it work already... have a full flutter plugin package and using it on a project.

just make sure you have set the key/token from their dashboard and you have an account setup

flushr commented 2 years ago

@eraseac great to hear, finally I was able to make it work too. thank you for your help on this issue.

eraseac commented 2 years ago

NO worries @flushr ... we are all here to learn. Good Luck!