Create a cocoa touch framework can not use in main project










1















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










share|improve this question
























  • let a = testClass() or let a: testClass = whatever NSObject you have

    – Alex Bailey
    Nov 13 '18 at 10:46












  • since you have declared tData as static you can directly access by using class name like testClass. tData()

    – guru
    Nov 13 '18 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 '18 at 11:01












  • Is your framework name test? because if not make sure you import the library correctly

    – Arie Pinto
    Nov 13 '18 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 '18 at 11:45















1















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










share|improve this question
























  • let a = testClass() or let a: testClass = whatever NSObject you have

    – Alex Bailey
    Nov 13 '18 at 10:46












  • since you have declared tData as static you can directly access by using class name like testClass. tData()

    – guru
    Nov 13 '18 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 '18 at 11:01












  • Is your framework name test? because if not make sure you import the library correctly

    – Arie Pinto
    Nov 13 '18 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 '18 at 11:45













1












1








1








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










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 10:43









Kuldeep

2,49441634




2,49441634










asked Nov 13 '18 at 10:33









SimonSimon

74




74












  • let a = testClass() or let a: testClass = whatever NSObject you have

    – Alex Bailey
    Nov 13 '18 at 10:46












  • since you have declared tData as static you can directly access by using class name like testClass. tData()

    – guru
    Nov 13 '18 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 '18 at 11:01












  • Is your framework name test? because if not make sure you import the library correctly

    – Arie Pinto
    Nov 13 '18 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 '18 at 11:45

















  • let a = testClass() or let a: testClass = whatever NSObject you have

    – Alex Bailey
    Nov 13 '18 at 10:46












  • since you have declared tData as static you can directly access by using class name like testClass. tData()

    – guru
    Nov 13 '18 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 '18 at 11:01












  • Is your framework name test? because if not make sure you import the library correctly

    – Arie Pinto
    Nov 13 '18 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 '18 at 11:45
















let a = testClass() or let a: testClass = whatever NSObject you have

– Alex Bailey
Nov 13 '18 at 10:46






let a = testClass() or let a: testClass = whatever NSObject you have

– Alex Bailey
Nov 13 '18 at 10:46














since you have declared tData as static you can directly access by using class name like testClass. tData()

– guru
Nov 13 '18 at 10:53





since you have declared tData as static you can directly access by using class name like testClass. tData()

– guru
Nov 13 '18 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 '18 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 '18 at 11:01














Is your framework name test? because if not make sure you import the library correctly

– Arie Pinto
Nov 13 '18 at 11:13





Is your framework name test? because if not make sure you import the library correctly

– Arie Pinto
Nov 13 '18 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 '18 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 '18 at 11:45












1 Answer
1






active

oldest

votes


















0














I think you should try adding the init() method to your testClass



public override init() 
super.init()






share|improve this answer























  • Still appear same error message.....

    – Simon
    Nov 13 '18 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 '18 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 '18 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 '18 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 '18 at 0:58











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















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

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I think you should try adding the init() method to your testClass



public override init() 
super.init()






share|improve this answer























  • Still appear same error message.....

    – Simon
    Nov 13 '18 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 '18 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 '18 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 '18 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 '18 at 0:58
















0














I think you should try adding the init() method to your testClass



public override init() 
super.init()






share|improve this answer























  • Still appear same error message.....

    – Simon
    Nov 13 '18 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 '18 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 '18 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 '18 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 '18 at 0:58














0












0








0







I think you should try adding the init() method to your testClass



public override init() 
super.init()






share|improve this answer













I think you should try adding the init() method to your testClass



public override init() 
super.init()







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 12:05









Arie PintoArie Pinto

8451715




8451715












  • Still appear same error message.....

    – Simon
    Nov 13 '18 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 '18 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 '18 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 '18 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 '18 at 0:58


















  • Still appear same error message.....

    – Simon
    Nov 13 '18 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 '18 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 '18 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 '18 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 '18 at 0:58

















Still appear same error message.....

– Simon
Nov 13 '18 at 12:30





Still appear same error message.....

– Simon
Nov 13 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 at 0:58




















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo