Divining the proper swiftc target for an Xcode project

I'm trying to dump the AST for all the Swift files in an Xcode project. I think I've mostly figured it out, but want to make sure I'm constructing the swiftc target correctly. Right now, this is how I'm doing it based on some guesswork. I get this indirect property:

   eval CUR_TARGET_NAME='$'$DEPLOYMENT_TARGET_SETTING_NAME

and then construct the target like so:

   ${arch}-apple-${SWIFT_PLATFORM_TARGET_PREFIX}${CUR_TARGET_NAME}

Will that reliably give me an appropriate target? And will it work for both iOS and OS X?

Thanks.

- Nate Petersen

The Swift target triples are the same as LLVM's target triples. Your logic matches what Xcode's currently doing to invoke Swift (and I assume that's where you got it from :-) ), but there's no guarantee that it will continue to work. If you really want something stable-ish, I'd suggest doing a -dry-run xcodebuild and extracting the swiftc lines from that.

Jordan

···

On Mar 4, 2016, at 11:40, Nate Petersen via swift-users <swift-users@swift.org> wrote:

I'm trying to dump the AST for all the Swift files in an Xcode project. I think I've mostly figured it out, but want to make sure I'm constructing the swiftc target correctly. Right now, this is how I'm doing it based on some guesswork. I get this indirect property:

  eval CUR_TARGET_NAME='$'$DEPLOYMENT_TARGET_SETTING_NAME

and then construct the target like so:

  ${arch}-apple-${SWIFT_PLATFORM_TARGET_PREFIX}${CUR_TARGET_NAME}

Will that reliably give me an appropriate target? And will it work for both iOS and OS X?

Thanks.

- Nate Petersen
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Ahh, that is an awesome suggestion! I'll try that.

Thanks!

- Nate Petersen

···

On Mar 7, 2016, at 3:40 PM, Jordan Rose <jordan_rose@apple.com> wrote:

The Swift target triples are the same as LLVM's target triples. Your logic matches what Xcode's currently doing to invoke Swift (and I assume that's where you got it from :-) ), but there's no guarantee that it will continue to work. If you really want something stable-ish, I'd suggest doing a -dry-run xcodebuild and extracting the swiftc lines from that.

Jordan

On Mar 4, 2016, at 11:40, Nate Petersen via swift-users <swift-users@swift.org> wrote:

I'm trying to dump the AST for all the Swift files in an Xcode project. I think I've mostly figured it out, but want to make sure I'm constructing the swiftc target correctly. Right now, this is how I'm doing it based on some guesswork. I get this indirect property:

eval CUR_TARGET_NAME='$'$DEPLOYMENT_TARGET_SETTING_NAME

and then construct the target like so:

${arch}-apple-${SWIFT_PLATFORM_TARGET_PREFIX}${CUR_TARGET_NAME}

Will that reliably give me an appropriate target? And will it work for both iOS and OS X?

Thanks.

- Nate Petersen
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users