# How to build library for iOS in command line

**URL:** <https://forums.swift.org/t/how-to-build-library-for-ios-in-command-line/72841>\
**Category:** Package Manager\
**Tags:** packagemanager, ios\
**Created:** [June 30, 2024, 10:41am UTC](https://forums.swift.org/t/how-to-build-library-for-ios-in-command-line/72841 "2024-06-30T10:41:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksubox](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ksubox/32/36051_2.png) [@ksubox](https://forums.swift.org/u/ksubox)\
**Post date:** [June 30, 2024, 10:41am UTC](https://forums.swift.org/t/how-to-build-library-for-ios-in-command-line/72841/1 "2024-06-30T10:41:33Z")

</div>

Hello,

I try to build c++ library and swift library, based on c++ library and then include it in iOS application. But I can't find a way to build it from command line. SPM always target MacOSX. I try to use full path to sdk:

```swift
swift build --target cxxLibn --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk

```

But just get warning:

```swift
clang: warning: using sysroot for 'iPhoneOS' but targeting 'MacOSX' [-Wincompatible-sysroot]

```

It would be good to have options to build at least static libraries from command line.

---

<div class="post-metadata">

**Author:** ![valeriyvan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/valeriyvan/32/8705_2.png) [@valeriyvan](https://forums.swift.org/u/valeriyvan)\
**Post date:** [August 24, 2024, 1:31pm UTC](https://forums.swift.org/t/how-to-build-library-for-ios-in-command-line/72841/2 "2024-08-24T13:31:08Z")

</div>

I try to build swift package for iOS with following:

```swift
swift build --triple aarch64-apple-ios-sim --sdk "`xcrun --sdk iphonesimulator --show-sdk-path`"

```

But I get a bunch of errors like

```swift
<unknown>:0: error: unable to load standard library for target 'aarch64-apple-ios12.0-sim'

```

So I am also looking of a way to build swift package for iOS.
