Import a third-party structure in the "SupportCode.swift" playground

Is there a way to include a structure (not Apple) in the "SupportCode.swift" file in the Sources directory on the playground?

While the structure is successfully imported when the import directive is placed on the playing field itself, I get the error "There is no such module" when I try to import the same infrastructure into SupportCode.swift.

I have a playground built into the workplace, with the necessary frameworks added to it.

+6
source share
4 answers

This is a hack. if you have a file like "Parse.framework", just copy it to the Xcode system frames folder at " /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/ Library / Frameworks "

Now you can import this infrastructure on the playground, as in any other system.

+1
source

This did not work until recently.

To import an external framework, you must have a game field and a target / project of your infrastructure in the Xcode workspace. Once you have this and you create the framework, you can simply import the framework using import .

0
source

If the playground is already in a project that is not a workspace file, you can convert the project to a workspace by choosing File> Save As Workspace, then add the playing field to this workspace.

You can also drag the project framework into the Finder onto the project navigator in the workspace.

Open the playground file in the editor and add the imported custom structure using the import statement.

NOTE. These are the conditions.

  • The structure is in the same workspace as the playground.

  • The structure is already built.

  • If it is an iOS platform, it is built for the 64-bit version of the destination.

  • A work area contains at least one active circuit that creates targets.

  • If it is an Objective-C framework, it installs the Defines Module assembly
    for Yes.

0
source

I found this tutorial exactly as I did in my project.

https://m.pardel.net/using-3rd-party-frameworks-in-swift-playgrounds-fd415f6dba10

Please do not miss to add an empty .swift file to your project as described in this answer fooobar.com/questions/983961 / ...

0
source

Source: https://habr.com/ru/post/983959/


All Articles