Particle-Network / particle-ios

Particle iOS SDK
https://particle.network
Apache License 2.0
14 stars 3 forks source link

Alamofire Crash #9

Open hydraCy opened 1 month ago

hydraCy commented 1 month ago

In my project, I use Swift Package Manager (SPM) to include Alamofire. Since Particle uses CocoaPods and also depends on Alamofire, when I call the auth.connect method, it causes a crash in Alamofire's public init(url: URLConvertible, method: HTTPMethod, headers: HTTPHeaders? = nil) method with the error Thread 7: EXC_BAD_ACCESS (code=1, address=0x20), due to method being unable to read data.

SunZhiC commented 1 month ago
  1. If you insist on using SPM to include Alamofire, you need to exclude Alamofire's integration in the Podfile to avoid duplicate integration of Alamofire.
    post_install do |installer|
    installer.pods_project.targets.each do |target|
    if target.name == 'Alamofire'
      target.remove_from_project
    end
    end
    end

    2.Or remove Alamofire from SPM.

hydraCy commented 1 month ago

When I remove Alamofire, RxAlamofire encounters errors, and since Alamofire is also a dependency for other libraries in SPM, I cannot remove it.

SunZhiC commented 1 month ago

When I remove Alamofire, RxAlamofire encounters errors, and since Alamofire is also a dependency for other libraries in SPM, I cannot remove it.

Okey,you can try remove Alamofire in Podfile.

hydraCy commented 1 month ago

This is a very strange phenomenon. If I remove the dependencies of Particle, such as Alamofire and SwiftyJSON, Cocoapods will throw errors during compilation because it is not compatible with SPM. But why does calling certain methods from ParticleAuth cause it to reference libraries from SPM? I cannot remove the duplicate dependencies from Pods because it will cause compilation errors in Particle.

SunZhiC commented 1 month ago

This is a very strange phenomenon. If I remove the dependencies of Particle, such as Alamofire and SwiftyJSON, Cocoapods will throw errors during compilation because it is not compatible with SPM. But why does calling certain methods from ParticleAuth cause it to reference libraries from SPM? I cannot remove the duplicate dependencies from Pods because it will cause compilation errors in Particle.

Looks like above solution will not remove Alamofire from pod, so you have to add Particle SDK manually, you can get all the xcframeworks from the Demo project, then put the Particle SDKs that you need into your project. Then add all the sub dependencies from SPM or Cocoapods.

hydraCy commented 4 weeks ago

This is a very strange phenomenon. If I remove the dependencies of Particle, such as Alamofire and SwiftyJSON, Cocoapods will throw errors during compilation because it is not compatible with SPM. But why does calling certain methods from ParticleAuth cause it to reference libraries from SPM? I cannot remove the duplicate dependencies from Pods because it will cause compilation errors in Particle.

Looks like above solution will not remove Alamofire from pod, so you have to add Particle SDK manually, you can get all the xcframeworks from the Demo project, then put the Particle SDKs that you need into your project. Then add all the sub dependencies from SPM or Cocoapods.

I tried to integrate using xcframeworks, but I encountered a problem. When I include the library with .package(url: "https://github.com/SunZhiC/Base58Swift", from: "1.0.0"), the xcframeworks use import Base58_swift instead of import Base58Swift, causing the xcframeworks to fail to compile.

SunZhiC commented 4 weeks ago

import Base58_swift is right

This is a very strange phenomenon. If I remove the dependencies of Particle, such as Alamofire and SwiftyJSON, Cocoapods will throw errors during compilation because it is not compatible with SPM. But why does calling certain methods from ParticleAuth cause it to reference libraries from SPM? I cannot remove the duplicate dependencies from Pods because it will cause compilation errors in Particle.

Looks like above solution will not remove Alamofire from pod, so you have to add Particle SDK manually, you can get all the xcframeworks from the Demo project, then put the Particle SDKs that you need into your project. Then add all the sub dependencies from SPM or Cocoapods.

I tried to integrate using xcframeworks, but I encountered a problem. When I include the library with .package(url: "https://github.com/SunZhiC/Base58Swift", from: "1.0.0"), the xcframeworks use import Base58_swift instead of import Base58Swift, causing the xcframeworks to fail to compile.

Try again, I had updated this package "https://github.com/SunZhiC/Base58Swift", import from SPM, should use import Base58_swift in file.

hydraCy commented 3 weeks ago

import Base58_swift is right

This is a very strange phenomenon. If I remove the dependencies of Particle, such as Alamofire and SwiftyJSON, Cocoapods will throw errors during compilation because it is not compatible with SPM. But why does calling certain methods from ParticleAuth cause it to reference libraries from SPM? I cannot remove the duplicate dependencies from Pods because it will cause compilation errors in Particle.

Looks like above solution will not remove Alamofire from pod, so you have to add Particle SDK manually, you can get all the xcframeworks from the Demo project, then put the Particle SDKs that you need into your project. Then add all the sub dependencies from SPM or Cocoapods.

I tried to integrate using xcframeworks, but I encountered a problem. When I include the library with .package(url: "https://github.com/SunZhiC/Base58Swift", from: "1.0.0"), the xcframeworks use import Base58_swift instead of import Base58Swift, causing the xcframeworks to fail to compile.

Try again, I had updated this package "https://github.com/SunZhiC/Base58Swift", import from SPM, should use import Base58_swift in file.

I have imported TweetNacl through https://github.com/bitmark-inc/tweetnacl-swiftwrap. Why is the system reporting 'Missing required module 'CTweetNacl''? Is the library I imported correct?

SunZhiC commented 3 weeks ago

import

Try import TweetNacl through cocoapods, I haven't tried import it from SPM.