Skip to content

repackage files for ios #2010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
qqq1010440810 opened this issue Nov 19, 2024 · 12 comments
Open

repackage files for ios #2010

qqq1010440810 opened this issue Nov 19, 2024 · 12 comments

Comments

@qqq1010440810
Copy link

I modified code in mailcore2 How do I repackage files for ios,Thanks.

@jsflax
Copy link

jsflax commented Dec 1, 2024

I have filed a pull request to have SPM build from source: #2011

If you wish to use the new Package, please use https://github.com/jsflax/mailcore2/ as your Swift Package dependency:

In Xcode click File -> Swift Packages -> Add Package Dependency...
Paste the following URL: https://github.com/jsflax/mailcore2
On the Choose Package Options screen, under Rules switch from Version to Branch (Branch: master) will be the default
Click Next -> Next -> Finish

@gamifyscience
Copy link

Thank you @jsflax for the commit. I spent days chasing missing header files before taking your forked branch. I was unable to build on iOS even though the initial MacOS build has little or no issues. Your solution solved the initial build blockers.
I am experiencing a ton of iOS crashes working with gmail, and my next course of action is to write thread safety wrappers and try to isolate mailcore2, as it is really out of date [from iOS 18].

@hussnainahmaddd
Copy link

hussnainahmaddd commented Mar 9, 2025

Hello @jsflax, I am using your https://github.com/jsflax/mailcore2/ as a package in my swift app that works perfectly on a simulator but it crashes on real device, can you guide me how can i fix it. Currently i am getting Thread 14: EXC_BREAKPOINT (code=1, subcode=0x22cfce344) when i run my code on real device
and this is my implementation where its crashing

 guard let fetchOperation = session.fetchMessagesOperation(withFolder: folder, requestKind: requestKind, uids: range) else {
            print("Failed to create fetch operation.")
            isFetching = false
            completion(.failure(NSError(domain: "IMAPService", code: -6, userInfo: [NSLocalizedDescriptionKey: "Failed to create fetch operation"])))
            return
        }

        fetchOperation.start { error, messages, _ in
            self.isFetching = false
            print("Completed fetching unseen emails from folder: \(folder)")

            if let error = error {
                print("Fetch operation error: \(error.localizedDescription)")
                completion(.failure(error))
                return
            }

            guard let messages = messages, !messages.isEmpty else {
                print("No new or unseen messages found.")
                completion(.failure(NSError(domain: "IMAPService", code: -2, userInfo: [NSLocalizedDescriptionKey: "No new or unseen messages found"])))
                return
            }

            var emails: [EmailEntity] = []
            let dispatchGroup = DispatchGroup()

            for message in messages {
                if !message.flags.contains(.seen) { // Filter unseen messages
                    dispatchGroup.enter()
                    self.fetchEmailDetails(for: message, folder: folder) { result in
                        switch result {
                        case .success(let email):
                            emails.append(contentsOf: email.emails)
                        case .failure(let error):
                            print("Failed to fetch email details: \(error.localizedDescription)")
                        }
                        dispatchGroup.leave()
                    }
                }
            }

            dispatchGroup.notify(queue: .main) {
                if let lastMessage = messages.last {
                    self.nextEmailUIDs[folder] = UInt64(lastMessage.uid + 1)
                }

                if emails.isEmpty {
                    print("No new unseen emails were successfully fetched.")
                    completion(.failure(NSError(domain: "IMAPService", code: -6, userInfo: [NSLocalizedDescriptionKey: "No new unseen emails were successfully fetched"])))
                } else {
                    completion(.success(emails))
                }
            }
        }

I am looking forward to your reply. It will be a great help. Thanks

@jsflax
Copy link

jsflax commented Mar 9, 2025

What line is it crashing on?

Are you able to use swift concurrency (async/await)? That would simplify your threading logic.

@hussnainahmaddd
Copy link

It is crashing on fetchOperation.start { error, messages, _ in

@jsflax
Copy link

jsflax commented Mar 9, 2025

@hussnainahmaddd It would help to see the full stack trace. @gamifyscience mentioned isolation issues which could be causing this, though I'm not sure why building with SPM would cause this versus building another way. That said, I'm happy to help debug it.

@hussnainahmaddd
Copy link

Hello @jsflax , i am not able to get full stack trace aswell and its not even throwing this crash on crashlytics. Is there anyway we can connect or Can you perhaps guide me through how i can use your repo as package. may be i missed something.

@hussnainahmaddd
Copy link

Hello @jsflax , These are the stack trace

Image

@hussnainahmaddd
Copy link

session.isVoIPEnabled = false
it solved my issue

@jsflax
Copy link

jsflax commented Mar 11, 2025

@hussnainahmaddd did you set VoIP off for macOS or iOS? I believe it should be false for macOS.

@hussnainahmaddd
Copy link

for ios

@gamifyscience
Copy link

following up on this thread - I landed at the same place with the crashes on iOS. VoIP enabled was the root cause. I recommend starting there for any iOS apps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants