Xcode: есть ли разница между фреймворком и модулем в проекте? - PullRequest
0 голосов
/ 04 августа 2020

Я только начинаю разработку Xcode и iOS. Я должен воспроизвести проект iOS на tvOS. Одна из структур - JSQCoreDataKit

В исходном проекте iOS эта структура существует в двух местах: СТУПКИ: . enter image description here
FRAMEWORKS.
enter image description here

I installed the framework following the manual instructions in this ссылка . Итак, в новом проекте он установлен как обычный фреймворк: enter image description here.

The problem I have faced is : Some of the code that works in the original project, relies on a code that is defined in the PODS folder:
EXAMPLE:

func saveChanges() {
    stack.mainContext.performAndWait {
        saveContext(self.stack.mainContext)
    }
}

saveContext function exists in:

enter image description here

And this is its definition(just in case):

public func saveContext(_ context: NSManagedObjectContext, wait: Bool = true, completion: ((SaveResult) -> Void)? = nil) {
    let block = {
        guard context.hasChanges else { return }
        do {
            try context.save()
            completion?(.success)
        }
        catch {
            completion?(.failure(error as NSError))
        }
    }
    wait ? context.performAndWait(block) : context.perform(block)
}

So while in the original project where Pods exists, this works fine.
In the new project, where it doesn't exist, and the framework is installed manually, I get this error:

Use of unresolved identifier 'saveContext'

But, the framework gets imported successfully with no errors :

import JSQCoreDataKit

One last thing, adding the framework with the manual method described in this ссылка здесь не отображается: введите описание изображения здесь

1 Ответ

1 голос
/ 20 августа 2020

Привет, у меня тоже была та же проблема, которую я решил !!

Итак, Framework и pod разные. Pod = Library

Когда их использовать ??

1. Фреймворк - используйте его, если хотите скрыть лог c в коде. В основном используется в банковских платформах. В фреймворке файлы и папки не видны, все скрыто.

2.Pod - в основном используется, чтобы вы могли делиться своим кодом, и люди также могли видеть и редактировать его. Также видна структура файлов и папок.

Просто go на youtube и ищите How to create framework. Как создать библиотеку. Вы получите его.

Надеюсь, вы его получите!

...