First time in trying to create a cocoapod project.
I used 'pod library create name' command creating the standard template, using the swift language option.
I have added in C-files to the workspace but I don't know how to add a bridging header file so swift can import the C functions.
An attempt resulted in the compiler complaining about using a bridging header in a framework.
Is it actually possible to mix and match swift & (obj-)C files in the same cocoapod workspace/project?
TIA
Mark
Woke up next morning and found the answer.
Sorry for the traffic.
Edit the XXX-umbrella.h file.
Related
I have an iOS Swift project with multiple targets.
Converting the first target to Swift 5 was easy.
Converting the second target to Swift 5, Xcode 10.2 tries to compile files that clearly exist only in the first target and fails (Because it doesn't compile all files of the first target and complains about unresolved identifiers).
What can I do that Xcode compiles only those files, that are part of the target while converting to Swift 5?
How can I convert my project to Swift 5?
Cleaning the Build folder and restarting Xcode 10.2 doesn't help.
I just went through this process and was able to figure out a fairly simple solution from a hint in the last sentence of the Migration Guide https://swift.org/migration-guide-swift5/
When I tried to convert each target individually in my project, the second target would fail because of shared code with the first target that had already been converted. The solution is to create a new scheme that includes all of the targets that need to be migrated in a single pass.
Click on the scheme button to get the drop down and select "New Scheme..."
Create the scheme and then select it in the drop down and choose "Edit Scheme..."
Under the "Build" section use the "+" button to add all of the targets you need to convert to the scheme.
Build the new scheme with the current Swift version to confirm that all targets build correctly.
Use Edit -> Convert -> "To Current Swift Syntax..." to start the conversion
This worked for me in a project with 15 targets with lots of shared Swift code that was in version 4.0.
I found a workaround:
reset project to state before conversion.
convert the target with the fewest classes (not containing the files in the error message of the first attempt)
convert target for target, including more and more files
convert test targets
With this approach I was able to convert my project.
(See also the comment of Cœur, I think their manual conversion would work, too)
It's not clear to me what the issue is, if you could file a bug report at http://bugreport.apple.com, the team at Apple will follow-up with you.
Note that there is a migration guide that you may find helpful here: https://swift.org/migration-guide-swift5
If I understand correctly. You've got one target migrated correctly and another is stuck on the older swift. I had a similar situation, click on the target, go to 'Build Settings', search for 'swift' and then manually change the 'Swift Language Version' to 5. Then since you've already converted the code, it should just compile.
The problem was the swift code was getting compiled every time even with no change in the code.
Trying to figure out why precompile bridging header is not happening in my old app, whereas it happens in any new app.
I am using the latest Xcode 9.2 version.
SWIFT_PRECOMPILE_BRIDGING_HEADER - basically this doesn't seem to work even though its on in build settings.
OK precompile bridging header only precompiles the header itself. It does not precompile the swift code. The apps need both obj-c and swift and a bridging header in order for that to run. Does the old project have this?
I downloaded the SwiftCSV parser.
I want to work with this software. I don't want install with CocoaPods.
How should I proceed?
I would really suggest using CocoaPods, as it just keeps your file & folder structure cleaner.
If you still want to avoid using CocoaPods with Swift you just need to drag and drop the file into the file navigator in Xcode. By doing so, you automatically add the file to the target and the autocomplete functionality should pick it up when using the methods in other files, classes, functions etc.
In your case, take the CSV.swift file and drag and drop it into Frameworks Folder in Xcode.
I'm exploring Swift with Xcode-6 and so far so good although I think the new collections need a little bit of work as I've managed to break the compiler a few times.
Problem is I'm now stuck trying to create the framework package to then use in another project. The project builds without issue and all tests pass successfully. When I go to create Archive (which I assume is what is required) I receive the error:
:0: error: underlying Objective-C module 'Sample' not found
Now I assume this has something to do with the contents of my Sample.h which tells me
// In this header, you should import all the public headers of your framework using statements like #import <Sample/PublicHeader.h>
which is fine except I have only used swift enums, structs and classes for this framework so therefore no .h files exist.
Can anyone shed some light on this one as I can't find any documentation available yet?
EDIT (7/27/2018)
The information in the answer below may no longer be accurate. Your mileage may vary.
I sat down with an engineer and asked this exact question. This was their response:
Xcode 6 does not support building distributable Swift frameworks at this time and that Apple likely won't build this functionality into Xcode until its advantageous for them to do so. Right now, Frameworks are meant to be embedded in your app's project, rather than distributed. If you watch any of the session videos or see the sample projects, this is always the arrangement. Another reason is that Swift is very new and likely to change. Thus your Swift-based framework is not guaranteed to work on the platform you originally built it on.
Slight Update
The engineer mentioned that it's not impossible to make a framework for distribution, just that it's not supported.
I was able to get past the error by going to the target for the framework and on the Build Phases tab under Headers, remove the MyFramework.h file
However I was getting the "Underlying Objective-C module not found" error when I was using a framework to share code between a containing app and an app extension, both of which were pure Swift.
Assuming you are creating a truly pure Swift module, you must disable the Objective-C Compatibility Header and any generated interface headers so the compiler doesn't go off assuming it can find an Objective-C module for the framework.
Do Not remove your public framework header. You'll get a module-map warning at link time if you do.
You might find this useful: Creation of pure swift module
In short: it's possible to make static framework, but there is one issue: it doesn't work in end user' project if "ProjectName-Swift.h" header included.
But, it works fine if you use only swift.
I think it's a bug in XCode 6, or that Apple does not allow archiving the Framework from XCode while in beta.
If you compile to profile XCode generates the framework correctly. (See the Release folder created in DerivedData)
I am trying to build an App using the GData static library libGDataTouchStaticLib.a
I have made all the appropriate linkings in my project settings and have copied GDataXMLNode.h and GDataXMLNode.m to my project.
I am receiving the error below. Can someone help me understand what this is?
ld: duplicate symbol _kGDataXMLXPathDefaultNamespacePrefix in
/Users/myUser/Library/Developer/Xcode/DerivedData/GData-edmqtrniowvhfjgfgngtlfxttvri/Build/Products/Debug-iphoneos/libGDataTouchStaticLib.a(GDataXMLNode.o) and
/Users/myUser/Library/Developer/Xcode/DerivedData/MyApp-grzimbvctfmwhmdluxbuxmskcvzy/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv7/GDataXMLNode.o for architecture armv7
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang failed with exit code 1
You shouldn't have to copy in GDataXMLNode.h and GDataXMLNode.m to your project. I believe the reason you are getting the duplicate symbol error is because the libGDataTouchStaticLib.a library already contains the compiled GDataXMLNode.m class.
I am currently using the GData library in a project I am working on, and got it set up by using these instructions: http://hoishing.wordpress.com/2011/08/23/gdata-objective-c-client-setup-in-xcode-4/, so this answer assumes that you have the same setup. However I have used a slightly different way of importing the headers that was suggested by one of the comments on the above blog.
In your Xcode project remove the GDataXMLNode.h and GDataXMLNode.m files, and make sure that the GData.xcodeproj project is linked into your project the same way as in the above blog, but do not drag the headers directory to your source tree. Add these arguments to the Debug and Release Header Search Paths of your current target instead:
/usr/include/libxml2
${BUILT_PRODUCTS_DIR}/Headers
You can find this under the Build Settings tab of your target. The second argument will import all the GData headers into your project if you have set up the GData.xcodeproj file correctly. Once you have done this you should be able to import the various GData classes including GDataXMLNode.h class wherever you need it by typing this at the top of the appropriate class:
#import "GDataXMLNode.h"
Much credit goes to Kelvin's blog for his great tutorial. Hope that helps!