Gotta weird problem here. I built a dynamic framework called: TestFramework
I am able to successfully import TestFramework framework into my Objective-C app. However, it is only able to build for either the device architectures or the simulator architectures.
How can I set it so that I can run my Objective-C app using this swift framework for any architecture?
Right now, I achieve either architecture by deleting the framework from the app, rebuild the .framework file (chose either device or simulator) then re-deploy this framework into the app project. It's rather annoying to do this since I want to be able to use this framework in any project (simulator or device).
I am able to use CocoaPods but I haven't set this up yet.
In the framework I have a class called: "Testing" (see way below in the question). I am able to access this class in my objective-c app. Instantiate a "Testing" object, call it's public functions or whatever. Code compiles! However, the issue is I get an error when I try to build for the architecture that the framework wasn't compiled for. The error:
ld: warning: ignoring file /Users/kersan/projects/TestApp2/TestApp2/TestFramework.framework/TestFramework, missing required architecture x86_64 in file /Users/kersan/projects/TestApp2/TestApp2/TestFramework.framework/TestFramework (2 slices)
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$__TtC13TestFramework7Testing", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is a screenshot of my configs and some code:
TestFramework.h:
#import <UIKit/UIKit.h>
//! Project version number for TestFramework.
FOUNDATION_EXPORT double TestFrameworkVersionNumber;
//! Project version string for TestFramework.
FOUNDATION_EXPORT const unsigned char TestFrameworkVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <TestFramework/PublicHeader.h>
Testing.swift:
//
// Testing.swift
// TestFramework
//
//
import Foundation
@objc open class Testing : NSObject {
open var testDescription : String?
open func printDesc() -> String {
print("testDescription: \(testDescription)")
return "Testing class -> Hello World"
}
}
ViewController in my Objective-C app:
//
// ViewController.m
// TestApp2
//
//
#import "ViewController.h"
#import "TestFramework/TestFramework-Swift.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
Testing *testing = [[Testing alloc] init];
[testing printDesc];
[_label setText:testing.printDesc];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end