小编Ale*_*sov的帖子

如何分发在iOS模拟器上运行的Objective-C和Swift代码?

我有一组Swift和Objective-C文件,它们扩展了XCTest框架中的一些功能.

我很容易创建一个由这些文件组成的Cocoa框架.我将所有文件添加到OS X框架目标中,并且由于其中一些文件导入了XCTest头文件,因此我链接XCTest.framework到了我的框架.用户可以将框架添加到他们的单元测试目标中,前提是他们正在为OS X构建.

问题:如何为构建iOS模拟器的用户执行相同的操作(即:分发此代码)?

我试过的(1):Cocoa Touch框架

我无法创建一个导入的Cocoa Touch框架 - XCTest.framework因此导致以下链接器错误("Quick"是框架的名称):

Ld /Users/modocache/Library/Developer/Xcode/DerivedData/Quick-cajmiuprocunntdhiwsnsfzqydkc/Build/Products/Debug-iphonesimulator/Quick-iOS.framework/Quick-iOS normal x86_64
    cd /Users/modocache/GitHub/modocache/Quick
    export IPHONEOS_DEPLOYMENT_TARGET=8.0
    export PATH="/Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode6-Beta.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -dynamiclib -isysroot /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk -L/Users/modocache/Library/Developer/Xcode/DerivedData/Quick-cajmiuprocunntdhiwsnsfzqydkc/Build/Products/Debug-iphonesimulator -F/Users/modocache/Library/Developer/Xcode/DerivedData/Quick-cajmiuprocunntdhiwsnsfzqydkc/Build/Products/Debug-iphonesimulator -F/Applications/Xcode6-Beta.app/Contents/Developer/Library/Frameworks -filelist /Users/modocache/Library/Developer/Xcode/DerivedData/Quick-cajmiuprocunntdhiwsnsfzqydkc/Build/Intermediates/Quick.build/Debug-iphonesimulator/Quick-iOS.build/Objects-normal/x86_64/Quick-iOS.LinkFileList -install_name @rpath/Quick-iOS.framework/Quick-iOS -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -objc_abi_version -Xlinker 2 -Xlinker -no_implicit_dylibs -mios-simulator-version-min=8.0 -framework XCTest -single_module -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/modocache/Library/Developer/Xcode/DerivedData/Quick-cajmiuprocunntdhiwsnsfzqydkc/Build/Intermediates/Quick.build/Debug-iphonesimulator/Quick-iOS.build/Objects-normal/x86_64/Quick-iOS_dependency_info.dat -o /Users/modocache/Library/Developer/Xcode/DerivedData/Quick-cajmiuprocunntdhiwsnsfzqydkc/Build/Products/Debug-iphonesimulator/Quick-iOS.framework/Quick-iOS

ld: building for iOS Simulator, but linking against dylib built for MacOSX file '/Applications/Xcode6-Beta.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest' …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c ios ios-simulator swift

6
推荐指数
1
解决办法
1165
查看次数

基于范围的循环,唯一指针和移动语义

这是一个类似于我的代码:

for (auto &uptr : vector_of_unique_ptrs) {              // 1
  auto result = do_the_job_with_pointee(uptr.get());    // 2
  record_intermidiate_result(result, std::move(uptr));  // 3
}
Run Code Online (Sandbox Code Playgroud)

在这里,我有一些指向某些对象的独特指针(第1行).

我遍历向量(第1行)并使用指针(第2行)做一些工作.

工作完成后,我需要取一个结果并将所有权转移到其他地方(第3行).

代码编译和执行没有任何问题,但我觉得在迭代期间移动iteratee是不合法的.

我通过公开发布的C++ 11草案"撇去",但没有找到关于这个问题的任何澄清.

任何人都可以告诉我上面的代码是否合法?

c++ unique-ptr move-semantics c++11

3
推荐指数
2
解决办法
1655
查看次数

Objective-C++和operator - >

operator ->和Objective-C 有问题.

我想在ObjC类上使用C++包装器.

所以我创建了我的课程:

@interface User : NSObject

@property (nonatomic, copy) NSString *name;

@end
Run Code Online (Sandbox Code Playgroud)

还有包装类:

class UserWrapper {
    User *_user;
    //  ctors, accessors, etc.

    operator User *(){
        return _user;
    }

    User *operator->(){
        return _user;
    }
};
Run Code Online (Sandbox Code Playgroud)

当我尝试通过operator User*它访问后备对象时,效果很好:

UserWrapper wrapper([User new]);
[wrapper setName:@"alex"];
NSLog(@"%@", [wrapper name]);
Run Code Online (Sandbox Code Playgroud)

但是当我尝试通过访问此对象时 operator ->

UserWrapper wrapper([User new]);
[wrapper setName:@"alex"];
NSLog(@"%@", wrapper->name);
Run Code Online (Sandbox Code Playgroud)

我有以下错误:

Property 'name' found on object of type 'User *'; did you mean to access it with the "." …
Run Code Online (Sandbox Code Playgroud)

c++ objective-c clang objective-c++ clang++

1
推荐指数
1
解决办法
227
查看次数