I have a command line app written in Swift. It does not use the Swift package manager, and instead has a rather complex xcode project.
I want to use ArgumentParser. The documented way to do this is to import the Swift package, which Xcode 11 can do in the GUI.
The problem is that the built executable depends on the ArgumentParser framework's dylib. I need a standalone executable that doesn't depend on dynamic libraries besides those that come with Catalina.
When I use the Swift package manager to build a project that depends on ArgumentParser, it is able to do so without a dynamic library dependency. It seems to link in the swiftmodule file.
Is it possible to build a command line app using Xcode that uses ArgumentParser without requiring me to distribute the ArgumentParser dylib along with my main app binary?
Related
I'm using Carthage for dependency management and have a bunch of warnings in my project:
"Multiple build commands for output file /Users/me/Library/Developer/Xcode/DerivedData/project-ymeymeyme/Build/Products/Debug-iphonesimulator/project.app/Frameworks/Alamofire.framework"
I'm not sure if the best way to take care of this is to just delete from derived data folder, or to remove in Build Phases from Link Binary With Libraries or Embed Frameworks or something?
Any idea? Thanks!
Seems to me that you are bundling the mentioned framework twice. (https://stackoverflow.com/a/5659415/1120481)
You mentioned that your target has a Run Script build phase with /usr/local/bin/carthage copy-frameworks what is recommended in the Carthage README file for iOS, tvOS and watchOS.
You're also asking whether you should remove the framework from Embedded Binaries. Did you add the framework to this list? If yes you may have mixed up the Carthage setup instructions for macOS and iOS, tvOS, watchOS.
If you're building for macOS, remove the script phase.
If you're building for iOS, tvOS or watchOS, remove the framework from Embedded Binaries.
I fixed the issue by changing the order of the Run Script phase that executes /usr/local/bin/carthage copy-frameworks below Embed Frameworks. This happens to be the last build phase for this target.
I currently have an Framework which uses Alamofire, JWT and CryptoSwift which are installed using cocapods.
My framework sucsessfully builds when I use the 'Generic iOS device'. When I go to drag it into my Application and tell it to create a copy, it appears in the 'linked frameworks and libraries' section on the general page. The problem is, when I build my application, I get an error saying that the image is not found. To fix the issue, I removed it from the 'linked frameworks and libraries' section and added it to the 'embedded binaries part'. This however, did not fix my problem.
How can I import a custom framework made out of 3rd party frameworks installed with cocopods? When I write code using my framework, it gives me auto completion so this means that Xcode recognises that my framework is there, however it does not run it on my physical iPhone 6s
I'm working on a project in Xcode and am attempting to install and use the CryptoSwift package via the Swift Package Manager.
I read the documentation on SPM, but I don't see instructions on how to invoke the SPM through Xcode.
The examples often refer to calling $ swift build. Does this mean that the SPM is only accessible from the command line?
And if so, where exactly am I supposed to create the Package.swift file?
I'm reasonably familiar with Xcode, but I don't really understand the meaning of the build settings part of a project, or how Swift modules are used.
EDIT: This question was originally asked for Xcode 7.2, which shipped with Swift 2.1.1. Will gladly accept answers that explain how to do this with current/future versions of Xcode.
Swift Package Manager now support generating Xcode project with
swift package generate-xcodeproj
as mentioned in this answer, but this only works when developing a library, or a command line tool. Not (yet) for (iOS/OS X) graphical application developer:
Note that at this time the Package Manager has no support for iOS, watchOS, or tvOS platforms.
Note:
It might not work well if there is a space in your package name, i.e. change "App Store" to "AppStore".
At present, to use the Swift Package Manager aka SPM, you need to install the development version of Swift 2.2 provided by Apple here. Xcode 7.2 shipped with Swift 2.1.1 and does not work with the SPM unless Swift 2.2-dev is installed.
You can compile with Swift 2.2-dev but you will need to do the build of CryptoSwift on the command line using swift build. When the library and modulemaps are built, you can drag and drop them into Xcode 7.2 using the Finder. SPM puts the required files into a .build directory. But Xcode 7.2 needs to be started with the alternate toolchain. This can be done from the command-line using xcrun launch-with-toolchain /Library/Developer/Toolchains/swift-latest.xctoolchain You should be able to import from the modules/libraries built with the SPM.
Note though, that you cannot submit iOS apps to the Store at the moment that have been built with the 2.2 development version. You can build/run/test things generally without problem, although Playgrounds are not functional and there can be Xcode issues with the debugger.
June 4th, 2019 update. Swift 5 and SPM 5 has added this support and Xcode 11 integrates with SPM.
I'd like to use the excellent stringencoders library in an iOS application. It's a fairly typical c library, with a configure script generated by autoconf and a makefile.
What I'd like to do is compile arm7 and i386 versions on Mac OSX and then use lipo to make a fat binary.
I'm having trouble figuring out how to persuade the build tools to create my platform-specific binaries. There's a few articles out there and even a few scripts but most of them are targeted at XCode 4.2 and don't work with 4.3.
It looks like it should be possible to create a fairly generic build script that can play nicely with configure and make but I'm at a loss as to where to even start.
Have you successfully done anything like this? I'd love some pointers!
BTW: 'import all the sourcecode into your project' is NOT a viable solution. That way lies madness.
Thanks.
I've ported a handful of open source C libraries to iOS (see iOS Ports). I've found the most reliable way to port a library is to build a new Xcode project with a build target for a static iOS Library. It is important to note that Apple will not allow your iOS Application to contain dynamic libraries if you plan to distribute your app on the iTunes App store, so you will be unable to use FAT libraries.
These are the steps I usually follow when porting libraries to iOS which usually built with the GNU Autotools:
Run ./configure with appropriate flags on OS X.
Verify that the library builds correctly on OS X using make.
Create a new Xcode project using the iOS Static Library template.
Add the config.h from the previous configure run to the Xcode project.
Read the automake file (Makefile.am), and add the referenced sources in the automaker targets to the Xcode target for the static library.
Copy the CPP flags (i.e. -DHAVE_CONFIG_H) from the automake file to the build settings in Xcode.
Compile in Xcode and start running down errors (usually by adding missing header include paths or missing source files).
The directory structure I usually use is the following:
project/
project/ported-project.xcodeproj
project/project-x.x.x.tar.gz
project/project-x.x.x
project/project -> project-x.x.x
I know this is not exactly what you asked for in your question, however it is rough outline of the steps I've used for years for porting libraries. The benefit of creating an actual Xcode to compile the ported library is that it makes it easier to integrate the library into multiple Xcode iOS applications.
If you need clarification or more detailed instructions, let me know and I"ll try to write up more extensive instructions and update my answer.
Is it plausible to add the source files (i.e. .c files) to your project directly?
Objective C is a superset of C so i am surprised that the code did not work directly out of the box in XCode 4. Are you missing out something there ? just suggesting
Generate your project files using gyp: http://code.google.com/p/gyp/
I use it to share libraries between win/osx/ios and linux (pi).
I have already successfully used CCmake to compile dcmtk3.6 and build it in an ios environment, but I don't know how to include these compiled file in a new ios project.
I have already moved dcmtk after compiling to a new iphone project, and used #include "dcm2xml.h" but there is error about path.
Try the iiDicom framework in QuickDicom.
http://sourceforge.net/projects/quickdicom/
iiDicom provides an ObjC wrapper for DCMTK, but it has not been updated for a while, so only handles DCMTK 3.5.4. If you've already compiled DCMTK 3.6 for iOS, you should be able to cobble the two together.