Skip to content

Commit

Permalink
Add Xcode project for building framework
Browse files Browse the repository at this point in the history
  • Loading branch information
natecook1000 committed Nov 15, 2024
1 parent 34eec0d commit da723f6
Show file tree
Hide file tree
Showing 10 changed files with 874 additions and 1 deletion.
23 changes: 22 additions & 1 deletion Sources/Algorithms/RandomSample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,28 @@
//===----------------------------------------------------------------------===//

// For log(_:) and root(_:_:)
#if swift(>=5.11)
#if ALGORITHMS_DARWIN_ONLY
internal import Darwin

extension Double {
@_transparent
internal static func root(_ x: Double, _ n: Int) -> Double {
guard x >= 0 || n % 2 != 0 else { return .nan }
if n == 3 { return cbrt(x) }
return Double(signOf: x, magnitudeOf: pow(x.magnitude, 1/Double(n)))
}

@_transparent
internal static func log(_ x: Double) -> Double {
Darwin.log(x)
}

@_transparent
internal static func log(onePlus x: Double) -> Double {
Darwin.log1p(x)
}
}
#elseif swift(>=5.11)
internal import RealModule
#elseif swift(>=5.10)
import RealModule
Expand Down
39 changes: 39 additions & 0 deletions Xcode/Algorithms.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Algorithms open source project
//
// Copyright (c) 2023 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//

PRODUCT_NAME = Algorithms
PRODUCT_BUNDLE_IDENTIFIER = org.swift.Algorithms

SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator watchos watchsimulator appletvos appletvsimulator
ARCHS = $(ARCHS_STANDARD)

MACOSX_DEPLOYMENT_TARGET = 12.0
IPHONEOS_DEPLOYMENT_TARGET = 15.0
WATCHOS_DEPLOYMENT_TARGET = 8.0
TVOS_DEPLOYMENT_TARGET = 15.0

MARKETING_VERSION = 1.2

CURRENT_PROJECT_VERSION = 1
VERSIONING_SYSTEM = apple-generic
VERSION_INFO_PREFIX =
DYLIB_COMPATIBILITY_VERSION = $(CURRENT_PROJECT_VERSION)
DYLIB_CURRENT_VERSION = $(CURRENT_PROJECT_VERSION)

INSTALL_PATH = $(LOCAL_LIBRARY_DIR)/Frameworks
SKIP_INSTALL = YES
DYLIB_INSTALL_NAME_BASE = @rpath
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks @loader_path/Frameworks

ENABLE_TESTABILITY = NO
ENABLE_TESTABILITY[config=Debug] = YES

GENERATE_INFOPLIST_FILE = YES
566 changes: 566 additions & 0 deletions Xcode/Algorithms.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7D489E3E29CE969D00499B21"
BuildableName = "Algorithms.framework"
BlueprintName = "Algorithms"
ReferencedContainer = "container:Algorithms.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:Algorithms.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7D489E4629CE969D00499B21"
BuildableName = "AlgorithmsTests.xctest"
BlueprintName = "AlgorithmsTests"
ReferencedContainer = "container:Algorithms.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7D489E3E29CE969D00499B21"
BuildableName = "Algorithms.framework"
BlueprintName = "Algorithms"
ReferencedContainer = "container:Algorithms.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
32 changes: 32 additions & 0 deletions Xcode/Algorithms.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"configurations" : [
{
"id" : "CF37E70B-D810-4CF2-AB41-571BAFF72572",
"name" : "Default",
"options" : {

}
},
{
"id" : "33436295-E24E-439B-9B8E-4602E0A6C8BB",
"name" : "TSan",
"options" : {
"threadSanitizerEnabled" : true
}
}
],
"defaultOptions" : {
"codeCoverage" : false
},
"testTargets" : [
{
"parallelizable" : true,
"target" : {
"containerPath" : "container:Algorithms.xcodeproj",
"identifier" : "7D489E4629CE969D00499B21",
"name" : "AlgorithmsTests"
}
}
],
"version" : 1
}
23 changes: 23 additions & 0 deletions Xcode/AlgorithmsTests.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Algorithms open source project
//
// Copyright (c) 2023 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//

PRODUCT_NAME = AlgorithmsTests
PRODUCT_BUNDLE_IDENTIFIER = org.swift.AlgorithmsTests

SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator watchos watchsimulator appletvos appletvsimulator
ARCHS = $(ARCHS_STANDARD)

CURRENT_PROJECT_VERSION = 1
MARKETING_VERSION = 1.0

GENERATE_INFOPLIST_FILE = YES

ENABLE_TESTABILITY = NO
5 changes: 5 additions & 0 deletions Xcode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Xcode build files

The project file here can be used to build a variant of this package with Xcode. The project file is a regular Xcode project that builds the code base using the ALGORITHMS_NATIVE_BUILTINS configuration, producing a single framework bundle. Build settings are entirely configured via the provided xcconfig files.

Beware! The contents of this directory are not source stable. They are provided as is, with no compatibility promises across package releases. Future versions of this package can arbitrarily change these files or remove them, without any advance notice. (This can include patch releases.)
88 changes: 88 additions & 0 deletions Xcode/Shared.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Algorithms open source project
//
// Copyright (c) 2023 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//

SDKROOT = macosx

CODE_SIGN_STYLE = Automatic
CODE_SIGN_IDENTITY = -
CODE_SIGN_IDENTITY[sdk=iphoneos*] = "iOS Developer"
CODE_SIGN_IDENTITY[sdk=watchos*] = "iOS Developer"
CODE_SIGN_IDENTITY[sdk=appletvos*] = "iOS Developer"

SWIFT_VERSION = 5.5
ONLY_ACTIVE_ARCH[config=Debug] = YES

SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) ALGORITHMS_DARWIN_ONLY

SWIFT_COMPILATION_MODE[config=Release] = wholemodule
SWIFT_COMPILATION_MODE[config=Debug] = singlefile

SWIFT_OPTIMIZATION_LEVEL[config=Release] = -O
SWIFT_OPTIMIZATION_LEVEL[config=Debug] = -Onone

SWIFT_EMIT_LOC_STRINGS = NO
SWIFT_INSTALL_OBJC_HEADER = NO

COPY_PHASE_STRIP = NO

DEBUG_INFORMATION_FORMAT[config=Release] = dwarf-with-dsym
DEBUG_INFORMATION_FORMAT[config=Debug] = dwarf

ALWAYS_SEARCH_USER_PATHS = NO

ENABLE_TESTABILITY = NO
ENABLE_USER_SCRIPT_SANDBOXING = YES
DEAD_CODE_STRIPPING = YES

GCC_DYNAMIC_NO_PIC = NO
GCC_NO_COMMON_BLOCKS = YES
GCC_OPTIMIZATION_LEVEL[config=Debug] = 0

GCC_C_LANGUAGE_STANDARD = gnu11
CLANG_CXX_LANGUAGE_STANDARD = gnu++20
CLANG_ENABLE_MODULES = YES
CLANG_ENABLE_OBJC_ARC = YES
CLANG_ENABLE_OBJC_WEAK = YES
ENABLE_NS_ASSERTIONS[config=Release] = NO
ENABLE_STRICT_OBJC_MSGSEND = YES
GCC_PREPROCESSOR_DEFINITIONS[config=Release] = DEBUG=1 $(inherited)

CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES
CLANG_WARN_BOOL_CONVERSION = YES
CLANG_WARN_COMMA = YES
CLANG_WARN_CONSTANT_CONVERSION = YES
CLANG_WARN_DOCUMENTATION_COMMENTS = YES
CLANG_WARN_EMPTY_BODY = YES
CLANG_WARN_ENUM_CONVERSION = YES
CLANG_WARN_INFINITE_RECURSION = YES
CLANG_WARN_INT_CONVERSION = YES
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES
CLANG_WARN_STRICT_PROTOTYPES = YES
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
CLANG_WARN_UNREACHABLE_CODE = YES

GCC_WARN_64_TO_32_BIT_CONVERSION = YES
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE
GCC_WARN_UNUSED_FUNCTION = YES
GCC_WARN_UNUSED_VARIABLE = YES
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES
CLANG_WARN_SUSPICIOUS_MOVE = YES
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
GCC_WARN_UNDECLARED_SELECTOR = YES
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
CLANG_ANALYZER_NONNULL = YES
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE

0 comments on commit da723f6

Please sign in to comment.