Xcode Playgrounds 无法访问 Sources 文件夹中的 swift 文件 [英] Xcode playgrounds can't access swift files in Sources folder

查看:35
本文介绍了Xcode Playgrounds 无法访问 Sources 文件夹中的 swift 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚升级到 Xcode 6.3,他们为 Playgrounds 提供了一些新的东西.如果您创建一个新的 Playground 并打开项目导航器,您将看到一个 Sources 文件夹,其中有一个SupportCode.swift"文件.在该文件的顶部,它读取

I just upgraded to Xcode 6.3 and they offered something new to the Playgrounds. If you make a new playgrounds and you open the project navigator, you will see a Sources folder and inside that there is a "SupportCode.swift" file. At the top of that file it reads

此文件(以及此 Playground 的 Sources 目录中的所有其他 Swift 源文件)将被预编译为自动提供给 .playground 的框架.

This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to .playground.

我尝试在那里放置一个函数,但它在我的操场上不可用.我究竟做错了什么?我是否必须手动编译 SupportCode.swift 文件?怎么样?

I tried putting a function in to there and it is not available to my playground. What am I doing wrong? Do I have to manually compile the SupportCode.swift file manually? How?

推荐答案

您必须将 public 访问属性添加到源文件夹中的类、方法和属性,以便从主 Playground 文件访问它们它们被编译器视为单独的模块

You have to add public access attribute to your classes, methods and properties in source folder to make them accessible from main playground file as they treated as separate module by compiler

这篇关于Xcode Playgrounds 无法访问 Sources 文件夹中的 swift 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆