segmentio/analytics-swift

'shared' is inaccessible due to 'internal' protection level

Ravinder-webonise opened this issue · 5 comments

Hey Team i am facing one issue related to Segment SDK.
i have installed Segment SDK using Package Dependancy. Everything working fine.
When i am trying to Track the Event , it showing me error ie :-
'shared' is inaccessible due to 'internal' protection level.
I know how to fix it, but for that i have to edit the framework file , but due tocode security i am not able to edit the Anylytics.swift File . can you please help me here.
Thanks.
For your Reference i have attached the error screenshot.

Screenshot 2024-05-15 at 1 29 36 PM

Nice find, I had no idea that wasn't public, thank you! That method is mostly intended for migration from analytics-ios though. A better path forward would be something like this ...

/**
 An example of implementing multiple Analytics instances in a single application.
 */
extension Analytics {
    static var main = Analytics(configuration: Configuration(writeKey: "1234")
                                    .flushAt(3)
                                    .trackApplicationLifecycleEvents(true))
    
    static var support = Analytics(configuration: Configuration(writeKey: "5678")
                                    .flushAt(10)
                                    .trackApplicationLifecycleEvents(false))
}

Hi @bsneed Thanks for your quick reply. I saw that you have updated the Analytics File and merged with Main Branch. But i have updated my Package many times and also re installed the package but can't see your new changes. i am still getting older code. can you please reverify it once.
Note:- I saw the release of the code which is showing 3 week Ago. Please release the new version of Package Dependancy so that i can use your latest code
For your reference attaching screenshot...
Screenshot 2024-05-15 at 9 03 34 PM

@Ravinder-webonise we have other changes in flight. It won't be in a release until those are complete. As I mentioned, it's best to use the method I referenced above, not shared().

Hi @bsneed yeah i have tried with above alternate which you have mentioned , but it doesn't work for me. I can't use Multiple Analytics instance's with the same Key.
Its throwing the error's.
Note:- why we use multiple keys in a single project ? i tried with multiple instances using single Key , and i got the fatal error , you can't use single key with multiple instances.

Attaching screenshot of it..
Screenshot 2024-05-15 at 9 38 44 PM

You can't have multiple instances with the same key. They need to be different write keys. That behavior is intentional.