appsquickly / XcodeEditor

An API for manipulating Xcode project files.
Apache License 2.0
880 stars 134 forks source link

Can not compile with Swift as a framework #49

Open pedropalmero opened 9 years ago

pedropalmero commented 9 years ago

I'm using cocoapods in a MacOSX command line app with this Podfile:

# Uncomment this line to define a global platform for your project
platform :osx, '10.8'

use_frameworks!

target 'EventwoCreateApp' do
    pod 'GBCli'
    pod 'XcodeEditor'
end

When i try to build the project, it fails building because of including of non-modular header inside framework module

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/pedro/Library/Developer/Xcode/DerivedData/EventwoCreateApp-hbqavnbhqvzppravjjsvpcdoxdwl/Build/Products/Debug/Pods-EventwoCreateApp/XcodeEditor.framework/Headers/Pods-EventwoCreateApp-XcodeEditor-umbrella.h"
        ^
/Users/pedro/Library/Developer/Xcode/DerivedData/EventwoCreateApp-hbqavnbhqvzppravjjsvpcdoxdwl/Build/Products/Debug/Pods-EventwoCreateApp/XcodeEditor.framework/Headers/Pods-EventwoCreateApp-XcodeEditor-umbrella.h:20:9: note: in file included from /Users/pedro/Library/Developer/Xcode/DerivedData/EventwoCreateApp-hbqavnbhqvzppravjjsvpcdoxdwl/Build/Products/Debug/Pods-EventwoCreateApp/XcodeEditor.framework/Headers/Pods-EventwoCreateApp-XcodeEditor-umbrella.h:20:
#import "XCKeyBuilder.h"
        ^
/Users/pedro/Library/Developer/Xcode/DerivedData/EventwoCreateApp-hbqavnbhqvzppravjjsvpcdoxdwl/Build/Products/Debug/Pods-EventwoCreateApp/XcodeEditor.framework/Headers/XCKeyBuilder.h:14:9: error: include of non-modular header inside framework module 'XcodeEditor.XCKeyBuilder'
#import <CommonCrypto/CommonDigest.h>
        ^
/Users/pedro/Downloads/EventwoCreateApp/EventwoCreateApp/AppCreator.swift:10:8: error: could not build Objective-C module 'XcodeEditor'
import XcodeEditor

I've tried different solutions, like customizing the modulemap file or adding the framework to the target, but the error is always the same.

¿is there some solution or is it simply a swift limitation?, thanks

hartbit commented 9 years ago

:+1:

iosdevzone commented 9 years ago

I had the same problem and issued a pull request to solve it (#53). This request was merged in commit 9f1a7e63461341ab456fa290f38bc53f24517845. So you should be able to compile as a framework now.

If you are using Swift 2.0 #54 adds lightweight generics which reduces the amount of casting you need to do.

cezheng commented 9 years ago

https://github.com/appsquickly/XcodeEditor/pull/60 has make XcodeEditor able to be nicely integrate with Carthage into Swift projects(the project did not set define modules to be Yes, so previously after linking the framework you still need to add necessary headers to the bridging headers).

I haven't tested Cocoapods yet, but it's totally fine with Carthage.

jasperblues commented 9 years ago

@iosdevzone @cezheng Shall we tag a new version and close this issue off?

cezheng commented 9 years ago

@jasperblues Maybe better to make sure that Cocoapods is fine(not sure if podspec would need an update or not since Carthage reads the xcodeproj's header settings but Cocoapods does not), but currently I don't have a mac at hand to check this out.