Hey , every one:
I don't know whether my step was right or not...I want to create a closed-source swift framework, that can be distributed or released to client for use, and I follow the steps below:
step 1:
Create a new project, choose [Framework] and select the project's directory to save;
step 2:
Do some configuration:
Edit the scheme [Run], select the [Build Configuration] to [Release]
Choose [TARGETS]->[Build Settings] ,change [Build libraries for Distribution] to [YES]
[Build Settings] again, [Deployment], change [Skip Install] to [NO]
step 3:
Add a new swift file to code some simple functions ,like:
then, save ,select [Product]->[Clean Build Folder], ...click to build finally
step 4:
Copy the xxxx.framework to my App project root directory path, the directory looks like:
----[macOSApp]
----macOSApp.xcodeproj
----[macOSFramework.framework]
step 5:
In my App project, choose [TARGETS]->[General], under [Frameworks, Libraries, and Embedded Content], add my framework, then in some app swift file, import the framework, and try to call the functions ,like:
the Xcode highlight the function name, pubFunc .....
but ! but ! yes , but!
the wired thing is that, when I [control + command + mouse_click] on the function name [pubFunc], Xcode jump into my framework source file immediately ! and present the functions definition all over...
I think the framework shoud be .... more private...
I don't know , is some where, or some configurations...i missed ???
please help , thanks !
I don't know whether my step was right or not...I want to create a closed-source swift framework, that can be distributed or released to client for use, and I follow the steps below:
step 1:
Create a new project, choose [Framework] and select the project's directory to save;
step 2:
Do some configuration:
Edit the scheme [Run], select the [Build Configuration] to [Release]
Choose [TARGETS]->[Build Settings] ,change [Build libraries for Distribution] to [YES]
[Build Settings] again, [Deployment], change [Skip Install] to [NO]
step 3:
Add a new swift file to code some simple functions ,like:
Code Block swift import Foundation private func pvtFunc() -> Int { return 10; } public func pubFunc() -> Int { return pvtFunc() + 1; }
then, save ,select [Product]->[Clean Build Folder], ...click to build finally
step 4:
Copy the xxxx.framework to my App project root directory path, the directory looks like:
----[macOSApp]
----macOSApp.xcodeproj
----[macOSFramework.framework]
step 5:
In my App project, choose [TARGETS]->[General], under [Frameworks, Libraries, and Embedded Content], add my framework, then in some app swift file, import the framework, and try to call the functions ,like:
Code Block swift Import macOSFramework class ViewController: NSViewController { ... var a = pubFunc(); ... }
the Xcode highlight the function name, pubFunc .....
but ! but ! yes , but!
the wired thing is that, when I [control + command + mouse_click] on the function name [pubFunc], Xcode jump into my framework source file immediately ! and present the functions definition all over...
I think the framework shoud be .... more private...
I don't know , is some where, or some configurations...i missed ???
please help , thanks !
You should build the framework as an XCFramework so that it is correctly packaged for distribution. Please see Create an XCFramework.