I have to share my source code with someone else but I don't want them to look in certain classes (or categories). Can I compile them into binary file with h file outside? Something like iOS framework that displays only header files.
You can put them in a custom framework and link to your project. Look here.
Related
My project is in Swift and I integrated a third party library for a feature which was all hard coded in Objective-C. Now I want to access my swift files from the Objectiv-C code for smooth navigation and data accessibility.
I tried everything mentioned [here], and a file like -Swift.h is generated under Objective C generated header name.
But no file is created under Derive Data folder.
I can't share the code as it is not allowed on my part, but when I import the file as #import "-Swift.h", it shows "No file Found".
I added forward declaration too. But of no use. Please help with this.
1:
Summary of problem
I'm building a calendar app in Swift, and I'd like to start with the UI in this repo: https://github.com/erichoracek/MSCollectionViewCalendarLayout
This repo is written in Objective-C.
However, I'm not sure how to build on top of this Github repo using Swift.
Example of the UI I'd like to use in my calendar:
What I've tried
I successfully installed this library with CocoaPods.
I ran $pod install.
I successfully ran import MSCollectionViewCalendarLayout.
I added a new CollectionViewController on my Storyboard, and assigned it to my custom CalendarViewController class
I tried (dumbly) with the code below in class CalendarViewController,but I get this error message:
"Cannot assign value of type 'MSCollectionViewCalendarLayout.Type' to type 'UICollectionViewLayout'"
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView.collectionViewLayout = MSCollectionViewCalendarLayout
}
I understand I probably have to use self.collectionView.register(cellClass:forCellWithReuseIdentifier:)...but how?
There's some documentation titled "Usage" in the Github, but unfortunately I'm still lost as to how to use it:
There's also an Example.xcworkspace included, written in Objective-C. I've gone through most of it. They include header (.h) and implementation (.m) files for each of the elements that they use.
There's a good answer to a tangential problem here: https://stackoverflow.com/a/45540130/3979651, but this doesn't directly solve my problem. I'd like to import this Cocoapods library, instead of writing on top of Objective-C files. But I'm also not entirely sure if this is the right / best way to do it.
Summary of questions
How do I link my CollectionViewController to MSCollectionViewCalendarLayout so that it has the same UI?
How do I use self.collectionView.register(cellClass:forCellWithReuseIdentifier:) in this case?
Do I have to write a new file for each element, like in the Example? (Event cell, Day Column Header, etc.)
Or, would it be easier to just copy and paste the Example element files (.h and .m) into my app? If so, how do I build on top of those files?
What I'd like to accomplish
I would like to import MSCollectionViewLayout like a library, attach it to my own CollectionViewControllers, and build my own functionality on top of this, all using Swift.
Thank you all in advance! Hopefully I can commit the correct answers here to the repo's README.md file.
You can better use one of the below repos which are purely written in Swift and has the same UI as of MSCollectionViewLayout
1) CalendarKit
2) Calendar
Note: I personally used these libraries and these are easy to
integrate with your existing application.
I am developing an iOS Real Framework with XCode. This Framework (A) needs an external framework (B) to compile. For example:
A FRAMEWORK
+Frameworks
-B FRAMEWORK
It is imported in A by using:
#import<BFRAMEWORK/bframework.h>
I create the A.framework to be linked in a project.
The problem is when I link this A Framework in a project. The project returns "BFRAMEWORK/bframework.h" not found.
I want to include B framework in A.framework so not to need to add B framework also in my project. For example:
MY PROJECT
+Frameworks
-A.Framework (with B Framework included inside).
Do you know how to do this? or another way to do this?
Thank you!
I was able to create this structure with iOS-Universal-Framework: https://github.com/kstenerud/iOS-Universal-Framework.
I created a Static iOS Framework 'FrameworkB' with 1 method, which is imported in a second Static iOS Framework 'Framework A' with 1 method that's calling FrameworkB's method. I then created an iPad app which imports FrameworkA and calls the method. Code runs fine and prints from FrameworkA (which fetches from FrameworkB) and of course FrameworkB is not imported. Please note that all frameworks have to be built for the same profile (i used iPad), otherwise you'll get linker errors.
Maybe you add BFramework in compile sources?
Or add headers in header search paths?
or set dependency in build settings.
I think you are looking for OTHER_LDFLAGS = -ObjC
I'm following the book of Programming in Objective-C by Stephen G. Kochan. I was trying the code and to improve the class example by myself. I opened a project in Mac OS X / Applications / Command Line Tool and the program executes successfully.
When I opened the project as IOS / Framework & Library / Cocoa Touch Static Library, XCode separates class and implementation files normally. When I try to compile, XCode says it has built successfully but there is no output in the console.
I just followed the book and I am sure there is nothing wrong about Class or the implementation files. "NSLog(#""); files stays in there". According to the book, files are separated by 3:
Interface Part (class part)
Implementation Part (Which instances located in)
int main (int argc, char *argv[]) part.
But when I open the project as cocoa-static library, I get only 1 *.m file. I cannot add any additional *.m file with add -> new file.
My question is, is there any relative problem with my file structure that I am working on? Should I need also separate implementation part and the main part?
I would really appreciate if someone could help with this probelem. I really got stuck and having struggling to proceed next step of the book because I can not try code examples anymore...
Sounds like you're trying to run a static library project. You can't do this - you need to make an app that uses your static library to be able to run at and see the output.
Are the images and sound files that are used inside the Unity IDE somehow compiled into libiPhone-lib.a inside XCode? I'm looking for a way to access the audio files and images inside XCode/Objective-C. As far as I can tell by looking at the exported XCode project, there are no sound files or other resources anywhere to be seen
They are compiled into the lib as a byte code which is then interpreted at runtime. Disclosure of this would destroy Unity's business model, as everyone would make corrections into unity-produced code. It is more easy for them to interpret bytecode rather than translating it into human-readable language like C or objective-c.
The answer is: yes, they are compiled into lib.
If you want to access them from objective-c layer, you have to add them to project again in a usual xCode way ,so their data will be doubled in the project.