i have build a XYZ.framework package for iOS with the folowing folder-structure:
ls XYZ.framework
XYZ -> Libraries/libxyz.a
Headers -> Home/Headers
Home -> SDKs/Current
Libraries -> Home/Libraries
SDKs
ls XYZ.framework/SDKs
4.2
Current -> 4.2
ls XYZ.framework/SDKs/Current
Headers
Libraries
It works fine with one .a library file.
But how to include more than one .a library file?
0) iOS does not allow you to publish dynamic libs at this time (unless that's a recent change)
1) set up your framework's project to include the dependencies
2) add the depends to the build invocation (target dependencies) and link phase.
3) if your framework creates no objects (e.g. exports no symbols, or compiles no files), then you may need to add a dummy file with something such as an inline function (or the image's constructor/destructor).
4) then link to the static depends to produce the final image. this step should merge all images.
Related
I currently have a XCodeProj but want to use the Package.swift file to add dependencies for other libraries.
This project currently generates a binary as a target file, then the binary file takes in arguments and runs some things based on the arguments. The main reason to use the Package.swift is for me to use the argparser using Vapor (not the base ArgumentParser because you have to do the swift run..) or other argument parser libraries.
How can I correctly add the Package.swift file to the XCodeProj? Or how can I add packages to this XCodeProj?
I just created a new project, and installed some pods. When I try to build, I get these two errors:
Showing Recent Issues
Multiple commands produce '/Users/myUser/Library/Developer/Xcode/DerivedData/Demo-eobcppugxuuucmefyvotwbqadppx/Build/Intermediates.noindex/Demo.build/Debug-iphonesimulator/Demo.build/Objects-normal/arm64/AppDelegate.stringsdata':
1) Target 'Demo' (project 'Demo') has compile command for Swift source files
2) Target 'Demo' (project 'Demo') has compile command for Swift source files
Showing Recent Issues
Multiple commands produce '/Users/myUser/Library/Developer/Xcode/DerivedData/Demo-eobcppugxuuucmefyvotwbqadppx/Build/Intermediates.noindex/Demo.build/Debug-iphonesimulator/Demo.build/Objects-normal/arm64/SceneDelegate.stringsdata':
1) Target 'Demo' (project 'Demo') has compile command for Swift source files
2) Target 'Demo' (project 'Demo') has compile command for Swift source files
Turns out I had duplicate swift files in targets -> Build Phases Deleted the ones that where duplicates, and all ok
I had the same problem but in my case, I have same name for two swift files. The solution for that is Go to Targets -> Build Phases -> Compile Sources, and check whether you have the same named Swift files, and remove any one from there.
Another issue of this error is under Targets -> Build Phases -> Copy Bundle Resources, if there are same named bundled resources, remove any one from that.
For me it was a view from an app extension, which was named the same as a view from my main app. Renaming the view from the extension solved the issue.
I am building the static iOS framework upon multiple libraries in Xcode. One of them should be the card.io. I cannot use cocoapods or carthage. So far I imported .frameworks within the .framework and it works pretty well. However card.io uses static library (.a file) with bunch of headers. It works well in dynamic type of .frameworks (or iOS app project) but in static project I get these errors on including of the .a files:
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lCardIO
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lCardIO is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lopencv_core
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lopencv_core is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lopencv_imgproc
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lopencv_imgproc is not an object file (not allowed in a library)
Regarding these errors I downloaded the source codes of card.io and it looks that there is dynamic .framework target waiting for build. I tried to use this one instead of .a files and headers - so my project at least can be builded. Because the card.io does not contatin architectures for simulator (which, by the way, it should with this release 5.2.2) I am not able to test it in unit tests, so when I test this solution on device I get this error:
dyld: Library not loaded: #rpath/CardIO.framework/CardIO
Referenced from: /var/containers/Bundle/Application/55D3AF7F-83F4-4B3D-A667-0FCO93CCC441/App/AppDemo
Reason: no suitable image found.
So far my knowledge+google+stackoverflow is stuck here, because it looks that xcode does not support the .framework within .framework this way.
To this moment I spent two days with this "issue", so the question is: Does exist any solution for including dynamic library into static framework? Or any solution to include card.io into static framework?
EDIT:
Well actually the solution was more stupid than I would think (as always). Just to include card.io in the .framework go to "Project Description -> Build Settings -> Library search paths" and type the path where should xcode look for the libraries. This approach solves the first one issue of this post - this means the implementation of the .a libraries and headers.
At this moment I cannot guarantee it will work in releases based on my framework so I will update this post to confirm it later. I hope it helps someone...
I already read a lot of hints how to add an existing framework to Xcode 4, e.g.:
http://www.thinketg.com/Company/Blogs/11-03-20/Xcode_4_Tips_Adding_frameworks_to_your_project.aspx
But my question is very special.
I want to add a library that has the following structure:
build -> Debug-iphoneos -> library.a
build -> Debug-iphonesimulator -> library.a
build -> Release-iphoneos -> library.a
build -> Release-iphonesimulator -> library.a
If I want to build my project to test it on a simulator, I have to copy the library from the folder "Debug-iphonesimulator" to my project. If I want test it on the device, I have to copy the library from the folder "Release-iphoneos". That's very cumbersome!
Is the a good way to integrate all librarys in my project?
Thank you very much!
A first step is to create universal static library with the lipo command
lipo -create "${PROJECT_DIR}/build/${BUILD_STYLE}-iphoneos/libYourLib.a" "${PROJECT_DIR}/build/${BUILD_STYLE}-iphonesimulator/libYourLib.a" -output "${PROJECT_DIR}/build/libYourLib-${BUILD_STYLE}.a"
After that create 2 different target (for debug and release) and add the correct .a in each.
There is another simple way. Provide the path of .a file in other linker flag with the corresponding target.
Suppose you are building your application for device it should link to device version of .a and when you are building your application for simulator it should link to simulator version on .a
Here is how you should provide the other liker flag:
../../../testApp/DerivedData/testApp/build/Products/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/testApp.a
I am facing a strange issue while compiling my own static library. My library is referring to some other libs and hence in my Target build settings I have give "Library Search Path" to these libs. Now, when I compile and share this static lib & other libs which my static lib needs with other project it fails on compilation as it tend to search for these libs in the path I specified when building the static lib.
If I remove the "Library Search Path" contents while compiling my static lib, it fails at compilation time. I am totally stuck here.
ALong with setting up Header Search Path , Try setting up the Other Linkers Flag too..
Go to “Other Linker Flags” under the “Linker” section, and add “-ObjC” and “-all_load” to the list of flags
Hope that works for you,