Skip to content

Commit 06d7ddc

Browse files
authored
chore(amplify-xcode): update readme (#1347)
* chore(amplify-xcode): update readme * chore(amplify-xcode): deprecation error * chore(amplify-xcode): updates commands and fix typos [ci skip]
1 parent 5786641 commit 06d7ddc

File tree

2 files changed

+63
-179
lines changed

2 files changed

+63
-179
lines changed
Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
1-
# AmplifyXcode
1+
## AmplifyXcode
2+
<img src="https://s3.amazonaws.com/aws-mobile-hub-images/aws-amplify-logo.png" alt="AWS Amplify" width="550" >
23

3-
A description of this package.
4+
AmplifyXcode is a command line tool distributed as part of the Amplify CLI. It aims to provide a seamless integration between Xcode and Amplify CLI during development of Amplify-based applications.
5+
AmplifyXcode exposes three commands that allow to update an Xcode project files with the generated Amplify Swift models and configuration files.
6+
It's designed to be extensible and its core, `AmplifyXcodeCore`, is fully decoupled from the command line interface.
7+
## Platform Support
8+
AmplifyXcode is available on MacOS 10.13 and above.
9+
## License
10+
This program is licensed under the Apache 2.0 License.
11+
12+
## Commands
13+
`amplify-xcode import-config --path project-path`
14+
Imports Amplify project files into the Xcode project located at the provided *project-path*.
15+
16+
`amplify-xcode import-models --path project-path`
17+
Imports Amplify generated Swift models into the Xcode project located at the provided *project-path*.
18+
19+
`amplify-xcode generate-schema --output-path output`
20+
Generates a JSON description of its commands that can be used to programmatically call amplify-xcode from a different environment.
21+
The Amplify CLI reads the output of this command to generate a [NodeJS bridging module](https://github.com/aws-amplify/amplify-cli/blob/master/packages/amplify-frontend-ios/lib/amplify-xcode.js) to safely invoke the above commands as described in the **CLI Integration** section.
22+
23+
## CLI integration
24+
When running `amplify init --quickstart --frontend ios` as described in the [Getting Started guide](https://docs.amplify.aws/start/getting-started/setup/q/integration/ios#add-amplify-to-your-application), the relevant files are automatically added to the Xcode project in a `AmplifyConfig` group.
25+
When running `amplify codegen models`, the `*.swift` files generated under `amplify/generated/models/` are auto-added to the Xcode project in the group called `AmplifyModels`.
26+
27+
## Reporting Bugs/Feature Requests
28+
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
29+
When filing an issue, please check [existing open](https://github.com/aws-amplify/amplify-ios/issues?q=is%3Aissue+label%3Abug+label%3A%22dev+tools%22++is%3Aopen), or [recently closed](https://github.com/aws-amplify/amplify-ios/issues?q=is%3Aissue+label%3Abug+label%3A%22dev+tools%22++is%3Aclosed), issues to make sure somebody else hasn't already reported the issue.
30+
Please try to include as much information as you can, details like these are incredibly useful:
31+
32+
- Expected behavior and observed behavior
33+
- A reproducible test case or series of steps
34+
- Anything custom about your environment or Xcode project/workspace
35+
36+
## Open Source Contributions
37+
Pull requests guidelines https://github.com/aws-amplify/amplify-ios/blob/main/CONTRIBUTING.md#pull-requests
38+
39+
### Setup
40+
AmplifyXcode requires Xcode 11.4 or higher to build.
41+
42+
After you've forked and cloned Amplify repository, navigate to the **AmplifyXcode** folder and open the Swift package:
43+
```
44+
cd AmplifyTools/AmplifyXcode
45+
xed .
46+
```
47+
Xcode will take care of downloading the necessary dependencies.
48+
49+
### Testing
50+
AmplifyXcode has a comprehensive suite of unit tests that you can easily run via Xcode UI or by running
51+
`swift test` in your terminal from within the AmplifyXcode root folder.
52+
53+
While debugging within Xcode, you might also find useful to invoke the executable with specific commands and/or options.
54+
In order to do so you can create a copy of the *amplify-xcode* scheme in the Xcode scheme editor (**Product > Scheme > edit Scheme**) and change the arguments passed to the executable on launch
55+
in the *Arguments* tab.
56+
57+
Running `swift build -c release --disable-sandbox` will generate a release executable located at `.build/release/amplify-xcode`.
58+
59+
### Dependencies
60+
- [Apple Swift Argument Parser](https://github.com/apple/swift-argument-parser)
61+
- [XcodeProj](https://github.com/tuist/xcodeproj)
62+
- [XcodeGen](https://github.com/yonaskolb/XcodeGen)
63+
- [PathKit](https://github.com/kylef/PathKit)

AmplifyTools/amplify-tools.sh

Lines changed: 1 addition & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -13,180 +13,4 @@
1313
# #
1414
###########################################################################################
1515

16-
echo "warning: AmplifyTools has been deprecated. More info: https://github.com/aws-amplify/amplify-ios/blob/main/AmplifyTools/README.md"
17-
18-
if ! which node >/dev/null; then
19-
echo "warning: Node is not installed. Visit https://nodejs.org/en/download/ to install it"
20-
exit 1
21-
fi
22-
23-
# Check for NVM and make sure it's initialized
24-
NVM_PATH="${HOME}/.nvm/nvm.sh"
25-
if [ -f "${NVM_PATH}" ]; then
26-
echo "NVM found, initializing it..."
27-
source "${NVM_PATH}"
28-
fi
29-
30-
set -e
31-
32-
export PATH=$PATH:$(npm bin -g)
33-
34-
# Note the use of tail -1 is important here because when upgrading between versions
35-
# the first time that you run these commands, we have seen this variable take on the value of:
36-
# """
37-
# Scanning for plugins...
38-
# plugin scan successful
39-
# 4.21.0
40-
# """
41-
AMP_APP_VERSION_CURRENT=`npx -q amplify-app --version |tail -1`
42-
AMP_APP_VERSION_MINIMUM="2.17.1"
43-
AMP_APP_VERSION_INVALID=0
44-
45-
AMP_CLI_VERSION_CURRENT=`npx -q amplify --version |tail -1`
46-
AMP_CLI_VERSION_MINIMUM="4.22.0"
47-
AMP_CLI_VERSION_INVALID=0
48-
49-
50-
STRIP_ESCAPE_RESULT=
51-
stripEscapeUtil() {
52-
STRIP_ESCAPE_RESULT=
53-
54-
set +e
55-
HAS_RUBY=0
56-
which ruby > /dev/null 2>&1
57-
if [[ $? -eq 0 ]]; then
58-
HAS_RUBY=1
59-
fi
60-
set -e
61-
62-
if [ ${HAS_RUBY} -eq 1 ]; then
63-
STRIP_ESCAPE_RESULT=`echo "${1}" | ruby -pe 'gsub(/\e\[[0-9;]*m/s, "")'`
64-
else
65-
STRIP_ESCAPE_RESULT=`echo "${1}" | npx -q strip-ansi-cli`
66-
fi
67-
}
68-
69-
VERSION_INVALID=
70-
checkMinVersionCompatibility() {
71-
VERSION_INVALID=0
72-
73-
stripEscapeUtil "${1}"
74-
CURR_VERSION_SAFE="${STRIP_ESCAPE_RESULT}"
75-
CURR_VERSION_MAJOR=`echo "${CURR_VERSION_SAFE}" | tr '.' ' ' | awk '{print $1}'`
76-
CURR_VERSION_MINOR=`echo "${CURR_VERSION_SAFE}" | tr '.' ' ' | awk '{print $2}'`
77-
CURR_VERSION_PATCH=`echo "${CURR_VERSION_SAFE}" | tr '.' ' ' | awk '{print $3}'`
78-
79-
stripEscapeUtil "${2}"
80-
REQU_VERSION_SAFE="${STRIP_ESCAPE_RESULT}"
81-
REQU_VERSION_MAJOR=`echo "${REQU_VERSION_SAFE}" | tr '.' ' ' | awk '{print $1}'`
82-
REQU_VERSION_MINOR=`echo "${REQU_VERSION_SAFE}" | tr '.' ' ' | awk '{print $2}'`
83-
REQU_VERSION_PATCH=`echo "${REQU_VERSION_SAFE}" | tr '.' ' ' | awk '{print $3}'`
84-
85-
if [ -z "${CURR_VERSION_MAJOR}" ] ||
86-
[ -z "${CURR_VERSION_MINOR}" ] ||
87-
[ -z "${CURR_VERSION_PATCH}" ] ||
88-
[ -z "${REQU_VERSION_MAJOR}" ] ||
89-
[ -z "${REQU_VERSION_MINOR}" ] ||
90-
[ -z "${REQU_VERSION_PATCH}" ]; then
91-
VERSION_INVALID=1
92-
return
93-
fi
94-
95-
if [ ${CURR_VERSION_MAJOR} -lt ${REQU_VERSION_MAJOR} ]; then
96-
VERSION_INVALID=1
97-
return
98-
else
99-
if [ ${CURR_VERSION_MINOR} -lt ${REQU_VERSION_MINOR} ]; then
100-
VERSION_INVALID=1
101-
return
102-
else
103-
if [ ${CURR_VERSION_PATCH} -lt ${REQU_VERSION_PATCH} ]; then
104-
VERSION_INVALID=1
105-
return
106-
fi
107-
fi
108-
fi
109-
}
110-
111-
checkMinVersionCompatibility "${AMP_APP_VERSION_CURRENT}" "${AMP_APP_VERSION_MINIMUM}"
112-
AMP_APP_VERSION_INVALID=${VERSION_INVALID}
113-
114-
checkMinVersionCompatibility "${AMP_CLI_VERSION_CURRENT}" "${AMP_CLI_VERSION_MINIMUM}"
115-
AMP_CLI_VERSION_INVALID=${VERSION_INVALID}
116-
117-
if [ ${AMP_CLI_VERSION_INVALID} -eq 1 ]; then
118-
echo "error: Minimum version required of Amplify CLI is not installed."
119-
echo " Min required version: (${AMP_CLI_VERSION_MINIMUM})"
120-
echo " Found Version: (${AMP_CLI_VERSION_CURRENT})"
121-
echo ""
122-
echo "To install the latest version, please run the following command:"
123-
echo " npm install -g @aws-amplify/cli@latest"
124-
exit 1
125-
else
126-
echo "Found amplify-cli version: (${AMP_CLI_VERSION_CURRENT}), Required: >= (${AMP_CLI_VERSION_MINIMUM})"
127-
fi
128-
129-
echo "Found amplify-app version: (${AMP_APP_VERSION_CURRENT}), Required: >= (${AMP_APP_VERSION_MINIMUM})"
130-
if [ ${AMP_APP_VERSION_INVALID} -eq 1 ]; then
131-
echo " Using: npx amplify-app@latest"
132-
NPX_AMP_APPCMD="npx amplify-app@latest"
133-
else
134-
echo " Using: npx amplify-app"
135-
NPX_AMP_APPCMD="npx amplify-app"
136-
fi
137-
138-
139-
if ! test -f ./amplifytools.xcconfig; then
140-
${NPX_AMP_APPCMD} --platform ios
141-
fi
142-
143-
. amplifytools.xcconfig
144-
amplifyPush=$push
145-
amplifyModelgen=$modelgen
146-
amplifyProfile=$profile
147-
amplifyAccessKey=$accessKeyId
148-
amplifySecretKey=$secretAccessKey
149-
amplifyRegion=$region
150-
amplifyEnvName=$envName
151-
152-
if $amplifyModelgen; then
153-
echo "modelgen is set to true, generating Swift models from schema.graphql..."
154-
amplify codegen model
155-
# calls amplify-app again so the Xcode project is updated with the generated models
156-
${NPX_AMP_APPCMD} --platform ios
157-
fi
158-
159-
if [ -z "$amplifyAccessKey" ] || [ -z "$amplifySecretKey" ] || [ -z "$amplifyRegion" ]; then
160-
161-
AWSCLOUDFORMATIONCONFIG="{\
162-
\"configLevel\":\"project\",\
163-
\"useProfile\":true,\
164-
\"profileName\":\"${amplifyProfile}\"\
165-
}"
166-
else
167-
AWSCLOUDFORMATIONCONFIG="{\
168-
\"configLevel\":\"project\",\
169-
\"useProfile\":true,\
170-
\"profileName\":\"${amplifyProfile}\",\
171-
\"accessKeyId\":\"${amplifyAccessKeyId}\",\
172-
\"secretAccessKey\":\"${amplifySecretAccessKey}\",\
173-
\"region\":\"${amplifyRegion}\"\
174-
}"
175-
fi
176-
177-
if [ -z "$amplifyEnvName" ]; then
178-
AMPLIFY="{\"envName\":\"amplify\"}"
179-
else
180-
AMPLIFY="{\"envName\":\"${amplifyEnvName}\"}"
181-
fi
182-
PROVIDERS="{\
183-
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
184-
}"
185-
186-
if $amplifyPush; then
187-
if test -f ./amplify/.config/local-env-info.json; then
188-
amplify push --yes
189-
else
190-
amplify init --amplify $AMPLIFY --providers $PROVIDERS --yes
191-
fi
192-
fi
16+
echo "error: AmplifyTools has been deprecated. More info: https://github.com/aws-amplify/amplify-ios/blob/main/AmplifyTools/README.md"

0 commit comments

Comments
 (0)