我刚刚升级到 XCode 7.3,它似乎破坏了我的 PROJECT_NAME-Bridging-Header.h
BBCategoryType 是一个在名为 BBCategory.h 的文件中定义的枚举,该文件在我的 PROJECT_NAME-Bridging-Header.h 中导入:
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import "BBCategory.h"
我还注意到,如果我删除 PROJECT_NAME-Bridging-Header.h,我会收到相同的错误 - 如果我将它添加回项目,我会收到相同的错误 - 就好像 XCode 7.3 甚至无法识别PROJECT_NAME-Bridging-Header.h 了。我已验证在我的build设置中也正确引用了桥接 header 。我已按照此处的所有说明进行操作以确保正确设置:
How to call Objective-C code from Swift
这是 BBCategory.h 的内容,它没有改变并且在升级到 XCode 7.3 之前完全正常工作,这肯定是问题开始的时候:
#import "PCFCategory.h"
/**
* Category class that is a subclass of PCFCategory.
*/
@interface BBCategory : PCFCategory
/**
* Enum that describes the type of Category, used in BBSubMenuViewController and PCFCategoryMap+BBAdditions.
*/
typedef NS_ENUM(NSUInteger, BBCategoryType) {
/// BBCategoryTypeFeatured for Featured Category.
BBCategoryTypeFeatured,
/// BBCategoryTypeNormal for Normal Category.
BBCategoryTypeNormal,
/// BBCategoryTypeHome for Home Category.
BBCategoryTypeHome,
/// BBCategoryTypeError if the category type is unknown
BBCategoryTypeError
};
这可能是 XCode 7.3 的一些错误,还是我需要进行一些更改才能使其正常工作?
这让我觉得 XCode 7.3 无法识别桥接 header 。一切都与 XCode 7.1、7.2 一起工作 - 7.3 就坏了
最佳答案
虽然这在 Objective-C 中是有效的,但它似乎对 Swift 隐藏了它(我不确定这是否有意为之 - 绝对想知道是否还有其他人对此有更多了解)。
因此,您可以通过将枚举移到@interface 之外来修复它。
#import "PCFCategory.h"
/**
* Enum that describes the type of Category, used in BBSubMenuViewController and PCFCategoryMap+BBAdditions.
*/
typedef NS_ENUM(NSUInteger, BBCategoryType) {
/// BBCategoryTypeFeatured for Featured Category.
BBCategoryTypeFeatured,
/// BBCategoryTypeNormal for Normal Category.
BBCategoryTypeNormal,
/// BBCategoryTypeHome for Home Category.
BBCategoryTypeHome,
/// BBCategoryTypeError if the category type is unknown
BBCategoryTypeError
};
/**
* Category class that is a subclass of PCFCategory.
*/
@interface BBCategory : PCFCategory
...
关于objective-c - XCode 7.3 破坏了 Bridging-Header.h?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36461494/
类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc
我已经从我的命令行中获得了一切,所以我可以运行rubymyfile并且它可以正常工作。但是当我尝试从sublime中运行它时,我得到了undefinedmethod`require_relative'formain:Object有人知道我的sublime设置中缺少什么吗?我正在使用OSX并安装了rvm。 最佳答案 或者,您可以只使用“require”,它应该可以正常工作。我认为“require_relative”仅适用于ruby1.9+ 关于ruby-主要:Objectwhenrun
如果您尝试在Ruby中的nil对象上调用方法,则会出现NoMethodError异常并显示消息:"undefinedmethod‘...’fornil:NilClass"然而,有一个tryRails中的方法,如果它被发送到一个nil对象,它只返回nil:require'rubygems'require'active_support/all'nil.try(:nonexisting_method)#noNoMethodErrorexceptionanymore那么try如何在内部工作以防止该异常? 最佳答案 像Ruby中的所有其他对象
我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121
我正在尝试为我的iOS应用程序设置cocoapods但是当我执行命令时:sudogemupdate--system我收到错误消息:当前已安装最新版本。中止。当我进入cocoapods的下一步时:sudogeminstallcocoapods我在MacOS10.8.5上遇到错误:ERROR:Errorinstallingcocoapods:cocoapods-trunkrequiresRubyversion>=2.0.0.我在MacOS10.9.4上尝试了同样的操作,但出现错误:ERROR:Couldnotfindavalidgem'cocoapods'(>=0),hereiswhy:U
我正在使用Heroku(heroku.com)来部署我的Rails应用程序,并且正在构建一个iPhone客户端来与之交互。我的目的是将手机的唯一设备标识符作为HTTPheader传递给应用程序以进行身份验证。当我在本地测试时,我的header通过得很好,但在Heroku上它似乎去掉了我的自定义header。我用ruby脚本验证:url=URI.parse('http://#{myapp}.heroku.com/')#url=URI.parse('http://localhost:3000/')req=Net::HTTP::Post.new(url.path)#boguspara
在Ruby(尤其是Rails)中,您经常需要检查某物是否存在,然后对其执行操作,例如:if@objects.any?puts"Wehavetheseobjects:"@objects.each{|o|puts"hello:#{o}"end这是最短的,一切都很好,但是如果你有@objects.some_association.something.hit_database.process而不是@objects呢?我将不得不在if表达式中重复两次,如果我不知道实现细节并且方法调用很昂贵怎么办?显而易见的选择是创建一个变量,然后测试它,然后处理它,但是你必须想出一个变量名(呃),它也会在内存中
最近,我安装了OSXMavericks,它似乎弄乱了我的开发环境。我在运行“railsnewfirst_app”后收到此消息:Youruseraccountisn'tallowedtoinstalltothesystemRubygems.Youcancancelthisinstallationandrun:bundleinstall--pathvendor/bundletoinstallthegemsinto./vendor/bundle/,oryoucanenteryourpasswordandinstallthebundledgemstoRubygemsusingsudo.Pass
如thisanswer中所述,Array.new(size,object)创建一个数组,其中size引用相同的object。hash=Hash.newa=Array.new(2,hash)a[0]['cat']='feline'a#=>[{"cat"=>"feline"},{"cat"=>"feline"}]a[1]['cat']='Felix'a#=>[{"cat"=>"Felix"},{"cat"=>"Felix"}]为什么Ruby会这样做,而不是对object进行dup或clone? 最佳答案 因为那是thedocumenta
升级到OSXYosemite后,我现有的pow.cx安装不起作用。升级到最新的pow.cx无效。通过事件监视器重新启动它也没有成功。 最佳答案 卸载(!)并重新安装解决了这个问题。curlget.pow.cx/uninstall.sh|shcurlget.pow.cx|sh 关于ruby-on-rails-OSXYosemite更新破坏了pow.cx,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/q