Create a cocoa touch framework can not use in main project
up vote
1
down vote
favorite
I want to learn cocoa touch framework, and I have code same as lots google result, but all not work.
I want to create a reuse code that can do write and read json file, and can called by main project app, so I create a simple cocoa touch framework just for test, I have drag the framework into main project, added it in embedded binaries, but when I build app, it always appears error message at [let a = testClass] this line in main project and below is error message:
'testClass' is unavailable: cannot find Swift declaration for this
class
is anywhere I make mistake?
code of cocoa touch framework:
import Foundation
public class testClass : NSObject {
public static func tData() -> String {
return "path"
}
}
code of app :
import UIKit
import test
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let a = testClass
}
ios swift xcode
|
show 1 more comment
up vote
1
down vote
favorite
I want to learn cocoa touch framework, and I have code same as lots google result, but all not work.
I want to create a reuse code that can do write and read json file, and can called by main project app, so I create a simple cocoa touch framework just for test, I have drag the framework into main project, added it in embedded binaries, but when I build app, it always appears error message at [let a = testClass] this line in main project and below is error message:
'testClass' is unavailable: cannot find Swift declaration for this
class
is anywhere I make mistake?
code of cocoa touch framework:
import Foundation
public class testClass : NSObject {
public static func tData() -> String {
return "path"
}
}
code of app :
import UIKit
import test
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let a = testClass
}
ios swift xcode
let a = testClass() or let a: testClass = whatever NSObject you have
– Alex Bailey
Nov 13 at 10:46
since you have declared tData as static you can directly access by using class name like testClass. tData()
– guru
Nov 13 at 10:53
I change this line to : testClass.tData(), but shows error message : 'testClass' is unavailable: cannot find Swift declaration for this class.......But I have import test already......
– Simon
Nov 13 at 11:01
Is your framework nametest? because if not make sure you import the library correctly
– Arie Pinto
Nov 13 at 11:13
Yes, the name is test. I know that is not good name this, I just want test cocoa framework so just use 'test'.
– Simon
Nov 13 at 11:45
|
show 1 more comment
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I want to learn cocoa touch framework, and I have code same as lots google result, but all not work.
I want to create a reuse code that can do write and read json file, and can called by main project app, so I create a simple cocoa touch framework just for test, I have drag the framework into main project, added it in embedded binaries, but when I build app, it always appears error message at [let a = testClass] this line in main project and below is error message:
'testClass' is unavailable: cannot find Swift declaration for this
class
is anywhere I make mistake?
code of cocoa touch framework:
import Foundation
public class testClass : NSObject {
public static func tData() -> String {
return "path"
}
}
code of app :
import UIKit
import test
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let a = testClass
}
ios swift xcode
I want to learn cocoa touch framework, and I have code same as lots google result, but all not work.
I want to create a reuse code that can do write and read json file, and can called by main project app, so I create a simple cocoa touch framework just for test, I have drag the framework into main project, added it in embedded binaries, but when I build app, it always appears error message at [let a = testClass] this line in main project and below is error message:
'testClass' is unavailable: cannot find Swift declaration for this
class
is anywhere I make mistake?
code of cocoa touch framework:
import Foundation
public class testClass : NSObject {
public static func tData() -> String {
return "path"
}
}
code of app :
import UIKit
import test
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let a = testClass
}
ios swift xcode
ios swift xcode
edited Nov 13 at 10:43
Kuldeep
2,43631434
2,43631434
asked Nov 13 at 10:33
Simon
74
74
let a = testClass() or let a: testClass = whatever NSObject you have
– Alex Bailey
Nov 13 at 10:46
since you have declared tData as static you can directly access by using class name like testClass. tData()
– guru
Nov 13 at 10:53
I change this line to : testClass.tData(), but shows error message : 'testClass' is unavailable: cannot find Swift declaration for this class.......But I have import test already......
– Simon
Nov 13 at 11:01
Is your framework nametest? because if not make sure you import the library correctly
– Arie Pinto
Nov 13 at 11:13
Yes, the name is test. I know that is not good name this, I just want test cocoa framework so just use 'test'.
– Simon
Nov 13 at 11:45
|
show 1 more comment
let a = testClass() or let a: testClass = whatever NSObject you have
– Alex Bailey
Nov 13 at 10:46
since you have declared tData as static you can directly access by using class name like testClass. tData()
– guru
Nov 13 at 10:53
I change this line to : testClass.tData(), but shows error message : 'testClass' is unavailable: cannot find Swift declaration for this class.......But I have import test already......
– Simon
Nov 13 at 11:01
Is your framework nametest? because if not make sure you import the library correctly
– Arie Pinto
Nov 13 at 11:13
Yes, the name is test. I know that is not good name this, I just want test cocoa framework so just use 'test'.
– Simon
Nov 13 at 11:45
let a = testClass() or let a: testClass = whatever NSObject you have
– Alex Bailey
Nov 13 at 10:46
let a = testClass() or let a: testClass = whatever NSObject you have
– Alex Bailey
Nov 13 at 10:46
since you have declared tData as static you can directly access by using class name like testClass. tData()
– guru
Nov 13 at 10:53
since you have declared tData as static you can directly access by using class name like testClass. tData()
– guru
Nov 13 at 10:53
I change this line to : testClass.tData(), but shows error message : 'testClass' is unavailable: cannot find Swift declaration for this class.......But I have import test already......
– Simon
Nov 13 at 11:01
I change this line to : testClass.tData(), but shows error message : 'testClass' is unavailable: cannot find Swift declaration for this class.......But I have import test already......
– Simon
Nov 13 at 11:01
Is your framework name
test? because if not make sure you import the library correctly– Arie Pinto
Nov 13 at 11:13
Is your framework name
test? because if not make sure you import the library correctly– Arie Pinto
Nov 13 at 11:13
Yes, the name is test. I know that is not good name this, I just want test cocoa framework so just use 'test'.
– Simon
Nov 13 at 11:45
Yes, the name is test. I know that is not good name this, I just want test cocoa framework so just use 'test'.
– Simon
Nov 13 at 11:45
|
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
I think you should try adding the init() method to your testClass
public override init() {
super.init()
}
Still appear same error message.....
– Simon
Nov 13 at 12:30
Try removing the lib and adding it again after adding the init, and of course don’t forget the clean and build first the lib then the project
– Arie Pinto
Nov 13 at 12:31
Did it. After 20 min try it again and again(delete cocoa touch project and create a new one), still the same error message...,
– Simon
Nov 13 at 13:00
Ok, try this then, delete your library from the project, and instead of trying to add it from outside, create it directly inside your project by goingFile->New->Target->Cocoa Touch Framework, this should guarantee the link between the project and the lib, and then just add your code directly in the lib which is inside the project.
– Arie Pinto
Nov 13 at 13:05
Sorry, still not work. Would you please send me some website for learn cocoa touch framework, I afraid waste your time.....ha ha :) .
– Simon
Nov 14 at 0:58
|
show 4 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
I think you should try adding the init() method to your testClass
public override init() {
super.init()
}
Still appear same error message.....
– Simon
Nov 13 at 12:30
Try removing the lib and adding it again after adding the init, and of course don’t forget the clean and build first the lib then the project
– Arie Pinto
Nov 13 at 12:31
Did it. After 20 min try it again and again(delete cocoa touch project and create a new one), still the same error message...,
– Simon
Nov 13 at 13:00
Ok, try this then, delete your library from the project, and instead of trying to add it from outside, create it directly inside your project by goingFile->New->Target->Cocoa Touch Framework, this should guarantee the link between the project and the lib, and then just add your code directly in the lib which is inside the project.
– Arie Pinto
Nov 13 at 13:05
Sorry, still not work. Would you please send me some website for learn cocoa touch framework, I afraid waste your time.....ha ha :) .
– Simon
Nov 14 at 0:58
|
show 4 more comments
up vote
0
down vote
accepted
I think you should try adding the init() method to your testClass
public override init() {
super.init()
}
Still appear same error message.....
– Simon
Nov 13 at 12:30
Try removing the lib and adding it again after adding the init, and of course don’t forget the clean and build first the lib then the project
– Arie Pinto
Nov 13 at 12:31
Did it. After 20 min try it again and again(delete cocoa touch project and create a new one), still the same error message...,
– Simon
Nov 13 at 13:00
Ok, try this then, delete your library from the project, and instead of trying to add it from outside, create it directly inside your project by goingFile->New->Target->Cocoa Touch Framework, this should guarantee the link between the project and the lib, and then just add your code directly in the lib which is inside the project.
– Arie Pinto
Nov 13 at 13:05
Sorry, still not work. Would you please send me some website for learn cocoa touch framework, I afraid waste your time.....ha ha :) .
– Simon
Nov 14 at 0:58
|
show 4 more comments
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I think you should try adding the init() method to your testClass
public override init() {
super.init()
}
I think you should try adding the init() method to your testClass
public override init() {
super.init()
}
answered Nov 13 at 12:05
Arie Pinto
668614
668614
Still appear same error message.....
– Simon
Nov 13 at 12:30
Try removing the lib and adding it again after adding the init, and of course don’t forget the clean and build first the lib then the project
– Arie Pinto
Nov 13 at 12:31
Did it. After 20 min try it again and again(delete cocoa touch project and create a new one), still the same error message...,
– Simon
Nov 13 at 13:00
Ok, try this then, delete your library from the project, and instead of trying to add it from outside, create it directly inside your project by goingFile->New->Target->Cocoa Touch Framework, this should guarantee the link between the project and the lib, and then just add your code directly in the lib which is inside the project.
– Arie Pinto
Nov 13 at 13:05
Sorry, still not work. Would you please send me some website for learn cocoa touch framework, I afraid waste your time.....ha ha :) .
– Simon
Nov 14 at 0:58
|
show 4 more comments
Still appear same error message.....
– Simon
Nov 13 at 12:30
Try removing the lib and adding it again after adding the init, and of course don’t forget the clean and build first the lib then the project
– Arie Pinto
Nov 13 at 12:31
Did it. After 20 min try it again and again(delete cocoa touch project and create a new one), still the same error message...,
– Simon
Nov 13 at 13:00
Ok, try this then, delete your library from the project, and instead of trying to add it from outside, create it directly inside your project by goingFile->New->Target->Cocoa Touch Framework, this should guarantee the link between the project and the lib, and then just add your code directly in the lib which is inside the project.
– Arie Pinto
Nov 13 at 13:05
Sorry, still not work. Would you please send me some website for learn cocoa touch framework, I afraid waste your time.....ha ha :) .
– Simon
Nov 14 at 0:58
Still appear same error message.....
– Simon
Nov 13 at 12:30
Still appear same error message.....
– Simon
Nov 13 at 12:30
Try removing the lib and adding it again after adding the init, and of course don’t forget the clean and build first the lib then the project
– Arie Pinto
Nov 13 at 12:31
Try removing the lib and adding it again after adding the init, and of course don’t forget the clean and build first the lib then the project
– Arie Pinto
Nov 13 at 12:31
Did it. After 20 min try it again and again(delete cocoa touch project and create a new one), still the same error message...,
– Simon
Nov 13 at 13:00
Did it. After 20 min try it again and again(delete cocoa touch project and create a new one), still the same error message...,
– Simon
Nov 13 at 13:00
Ok, try this then, delete your library from the project, and instead of trying to add it from outside, create it directly inside your project by going
File->New->Target->Cocoa Touch Framework, this should guarantee the link between the project and the lib, and then just add your code directly in the lib which is inside the project.– Arie Pinto
Nov 13 at 13:05
Ok, try this then, delete your library from the project, and instead of trying to add it from outside, create it directly inside your project by going
File->New->Target->Cocoa Touch Framework, this should guarantee the link between the project and the lib, and then just add your code directly in the lib which is inside the project.– Arie Pinto
Nov 13 at 13:05
Sorry, still not work. Would you please send me some website for learn cocoa touch framework, I afraid waste your time.....ha ha :) .
– Simon
Nov 14 at 0:58
Sorry, still not work. Would you please send me some website for learn cocoa touch framework, I afraid waste your time.....ha ha :) .
– Simon
Nov 14 at 0:58
|
show 4 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279043%2fcreate-a-cocoa-touch-framework-can-not-use-in-main-project%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
let a = testClass() or let a: testClass = whatever NSObject you have
– Alex Bailey
Nov 13 at 10:46
since you have declared tData as static you can directly access by using class name like testClass. tData()
– guru
Nov 13 at 10:53
I change this line to : testClass.tData(), but shows error message : 'testClass' is unavailable: cannot find Swift declaration for this class.......But I have import test already......
– Simon
Nov 13 at 11:01
Is your framework name
test? because if not make sure you import the library correctly– Arie Pinto
Nov 13 at 11:13
Yes, the name is test. I know that is not good name this, I just want test cocoa framework so just use 'test'.
– Simon
Nov 13 at 11:45