kRNCryptorAES256Settings referenced error - ios

I am trying to use RNCryptor in my app to do some data encryption.
Look at the code below:
var encryptedData: NSData = RNEncryptor.encryptData(data, withSettings:kRNCryptorAES256Settings, password: aPassword, error: nil)
Undefined symbols for architecture i386:
"_kRNCryptorAES256Settings", referenced from:
__TFC8UtraceUI24ChatBubbleViewController21textFieldShouldReturnfS0_FCSo11UITextFieldSb
in ChatBubbleViewController.o ld: symbol(s) not found for architecture
i386 clang: error: linker command failed with exit code 1 (use -v to
see invocation)
I am not sure why does it try to look for the constant name with an underscore; ideally it should have tried to look for kRNCryptorAES256Settings which is their in the bridgesupport and other header files.
Any clue what might be going wrong ?
Thanks !

You probably forgot to include the .m files as part of your build. Check the "Build Sources" step in your Build Phases.
If you're working in Swift, you may want to look at the new Swift version. That'll merge to master next week.

Swift cannot deal with C Structs, which is what kRNCryptorAES256Settings is. This issue has nothing to do with the architecture of the devices.
So to go around that, I created my own method in RNEcryptor with the sole reason to abstract the need of the C struct.
+ (NSData *)EncryptDataForSwift:(NSData *)data password:(NSString *)password error:(NSError **)error
{
return [RNEncryptor encryptData:data withSettings:kRNCryptorAES256Settings password:password error:error];
}
I am not sure whether it good idea or not, but this makes my project compilable, as I can call my method via Swift without needing to reference any C-only code:
var encryptedData:NSData = RNEncryptor.EncryptDataForSwift(data, password: Password, error: nil)
Hope this will help someone.

Related

Admob Conversion Tracking in Swift

I tried to set conversion tracking in my iOS game, but I didn't be able to do that. The tutorial can be found here: https://developers.google.com/app-conversion-tracking/ios/?hl=it#usage_and_disclosure
I integrate the GoogleConversionTrackingSDK to my project, load AdSupport framework and type -ObjC in Other linker flags.
I tried to convert this snippet from Obj-C:
[ACTConversionReporter reportWithConversionID:#"MY_ID" label:#"MY_LABEL" value:#"MY_VALUE" isRepeatable:NO];
to Swift:
ACTConversionReporter.reportWithConversionID("MY_ID", label: "MY_LABEL", value: "MY_VALUE", isRepeatable: false)
and I put that in didFinishLaunchingWithOptions method of AppDelegate.swift, but I get the error:
Use of unresolved identifier 'ACTConversionReporter'
If I type in Obj-C bridging header in Swift Compiler - Code Generation in Build Settings "ACTReporter.h" (without qm), I put the header file in the folder of my game or if I type the whole path of "ACTReporter.h" ending with its name, I fail the build and I get 2 errors:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_ACTConversionReporter", referenced from:
type metadata accessor for __ObjC.ACTConversionReporter in AppDelegate.o
ld: symbol(s) not found for architecture armv7 clang: error: linker
command failed with exit code 1 (use -v to see invocation)
I don't know what to do. I hope there is someone who can fix this.
You need to add to your project "YourProjectName-Bridging-Header.h" file
Here you can see how to add the file
in Bridging Header file add #import "ACTReporter.h"
Then it will work for you!

UITest: Undefined symbols for architecture armv7

I'm trying to call a swift singleton from my UITest target. I'm importing the main module: #testable import Ary but when I try to build it says:
Undefined symbols for architecture armv7:
"Ary.DataModelLayerOperation.getter : Ary.DataModelLayer", referenced from:
AryUITests.AryUITests.setUp (AryUITests.AryUITests)() -> () in AryUITests.o
d: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Syntax highlighting works though (the singleton doesn't have access modifiers, so it's marked as internal which should be perfectly fine for access from the test target)...
The function I'm calling is [in an XCTestCase]:
override func setUp() {
super.setUp()
if !DataModelLayerOperation.isUserLoggedIn() {
//do something
}
}
I'm afraid what you want to achieve is not possible at the moment. I have encountered similar problem and asked my question here. I will soon accept the answer that says:
The UI tests are a separate module from the app, therefore not run
inside your app as a logic test would.
I'm hoping this will be improved in the next Xcode versions.

Linker error when implementing NSObject protocol while using enums?

Here is a distilled version of the code I am having trouble with in Swift:
enum E {
case C
}
class Test: NSObject {
var v: E = .C
}
When I attempt to build, I get the following error:
Undefined symbols for architecture x86_64:
"__TWvdvC8TestTest4Test1vOS_1E", referenced from:
__TFC8TestTest4Testm1vOS_1E in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
To reproduce this, simply make a new Swift project and paste the above code right into "AppDelegate.swift". Alternatively, make a new file and stick it in there instead!
Am I missing something obvious or is this yet another Swift bug? I did try deleting all derived data and other forms of voodoo magic.
Thanks for the help!
It seems like the compiler removes the enum if there is only one case?
I can reproduce your issue, it disappears when I add a second case :
enum E {
case C,D
}
class Test: NSObject {
var v : E = .C
}
I noticed a couple things when trying this:
In the current non-beta version of Xcode, I see the error you're referring to (almost certainly a Swift bug). However, if I add an extra value to the enum (case C,D), it compiles just fine
I couldn't reproduce the crash in the latest Xcode beta (Version 6.3 (6D520o)), which leads me to believe that the bug has been fixed in Swift 1.2

Can't allocate anything from my project - static library (using XCTests)

When i try tests like
#interface My_Tests : XCTestCase
- (void)testExample {
XCTAssertTrue(#YES, #"has to be passed");
}
Everything is working fine. However when i try such pattern:
#import "NSString+Additions.h"
//...
- (void)testNameValidation {
NSString *string = #"Harry";
XCTAssertTrue([string stringIsValid], #"Name validation error");
}
I get:
file:///Users/username/project/ProjectTests/ProjectTest.m: test failure:
-[Project_test testNameValidation] failed: (([string stringIsValid]) is true)
failed: throwing "-[__NSCFConstantString stringIsValid]: unrecognized selector
sent to instance 0x2f58ae8" - Name validation error
I can also just do something like this:
#import "MyViewController.h"
//...
- (void)testSomething {
MyViewController *a = [[MyViewController alloc] init];
XCTAssertTrue(#YES, #"Impossible!");
}
I get 2 errors (first and last line):
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_MyViewController", referenced from:
objc-class-ref in MyTest.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Can someone explain me what am I doing wrong..? I can't do anything with my classes. It may be worth adding that i'm trying to test my custom static library and files included in it. I'm using CocoaPods and I've set environment basing on Kiwi description (only to be able to use CocoaPods files in my tests, I was also wondering whether to use Kiwi or XCTests).
PS. This is my first try with unit tests of any type, so please forgive eventual noobish question ;)
The unit tests aren't linked against the static library.
Add the library to the "Link Binary with Libraries" section of the build phases for the test target.

Undefined symbols for architecture armv7 SSZipArchive

Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_SSZipArchive", referenced from: objc-class-ref in
LoginVC.o ld: symbol(s) not found for architecture armv7 clang: error:
linker command failed with exit code 1 (use -v to see invocation)
just solved! I really tried everything, but yeah, it has catched me too now -> CMD+alt+Return, I only have to clean it, and now it works.
Be careful, if you have same problems with SSZipArchive check this:
- check the prefix.pch: You added some objective-C classes here? -->so just move it into
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
...cause minizip is compiling together with objective-classes, and thats a problem for minizip, so move it into #ifdef to work clear.
- clean baby: Just clean like me your project, if you tried many mistakes before [CMD]+[alt]+return - be careful
- add SSZipArchive not as reference: Just create your SSZipArchive to first like:
SSZipArchive
SSZipArchive.h
SSZipArchive.m
minizip(folder)
..just look also thisNiceLink..but it can work anyway as referenced folder, look here..both don't worked for me (cause I don't cleaned after experiments ;))..I have created a folder construct like above on finder, and drag drop it into my project (just click "create groups")
..so I hope it helps you.. :)

Resources